Skip to content

Normalize .. token when matching a file with a DisallowPattern #12

@WilliamHarvey97

Description

@WilliamHarvey97

I have a flutter app in which I am doing Feature Sliced Design. Feature Sliced Design prohibits cross-imports between different slices in a same layer and I would like to use this package to enforce this rule in my project.

For a slice in my layer, I want to disallow the import of all the slices in this layer except for my current slice.

For example:

Files under lib/src/entities/a cannot import files under lib/src/entities/b but still can import other files under lib/src/entities/a.

I think a rule like this in analysis_options.yaml could be appropriate:

import_rules:
  rules:
    - target: "lib/src/entities/**"
      disallow: "lib/src/entities/**"
      exclude_disallow:
        - "$TARGET_DIR/../**"
      reason: "No cross-imports between layers"

It would be fairly easy to accept the use of .. in the matches method of the Disallow rule. One could even use the normalize method from the path package https://pub.dev/documentation/path/latest/path/Context/normalize.html.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions