Skip to content

feat: check imports and barrels in the layer validator #25

Open

Description

@Statyk7

Description

The validator reads only pubspec.yaml files. Several rules in the reference are about what packages import and export, and can be checked by scanning import and export directives in lib/**/*.dart with a regular expression. That keeps the script dependency-free (dart:io only).

Requirements

  • Cross-feature presentation imports target a dedicated barrel. A dependency on another feature's _presentation "has to target a dedicated barrel" (Dependency rules in project_structure.md, and Widgets that own state in presentation.md). Flag package:cart_presentation/cart_presentation.dart imported from another feature, and accept a subfeature barrel such as package:cart_presentation/cart_badge.dart.
  • No imports of another package's src/. package:x/src/... imported from outside x is an error. Implemented in feat(validator): check imports and barrels #31 as deep-import, which covers any import past a root barrel, since the reference's own layout puts folders directly under lib/.
  • The data barrel does not export internals. {f}_data.dart must not export data sources, DTOs or mappers (data.md).
  • Each layer has a primary barrel. lib/{feature}_{layer}.dart exists (project_structure.md). Implemented in feat(validator): check imports and barrels #31 as lib/{package}.dart, which also fits backend packages such as auth_data_firebase.
  • Warning: a workspace dependency declared in pubspec.yaml but never imported. It adds an edge to the graph that can cause a false cycle or hide a violation. Depends on feat: add severity levels and suppressions to the layer validator #21.
  • Incremental mode (--file) and full mode (--all) both run the new checks. Decide whether the hook should also run on .dart edits, or only on pubspec edits. Decided in feat(validator): check imports and barrels #31: the hook runs on .dart edits and reports only the findings located in the edited file.
  • Each rule has a fixture and a test case.
  • The Hooks section of README.md and the ## Hooks section of CLAUDE.md are updated if the hook's trigger changes.
  • All CI/CD checks are passing.
  • There is no drop in the test coverage percentage.

Additional Context

The ffca-layer-auditor agent covers barrel hygiene and DTO leakage with an LLM today. Once these checks are deterministic, the agent can rely on the validator's output for them.

Activity

  1. self-assigned this
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureA new feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions