dependency_validator icon indicating copy to clipboard operation
dependency_validator copied to clipboard

Ignore sub-packages

Open fzyzcjy opened this issue 3 years ago • 3 comments

For example:

/mypackage
  ...some code...
  /example
    ...some code...
    pubspec.yaml
  pubspec.yaml

then when considering mypackage, should not consider files in example subpackage

fzyzcjy avatar May 26 '22 13:05 fzyzcjy

Personally, I like this idea since we also commonly use nested packages and have to ignore them like so:

# pubspec.yaml
dependency_validator:
  exclude:
    - app/**

My only concern is that this would be inconsistent with how the Dart analyzer works. Right now, if you have a directory structure like the one you outlined, running the analyzer from the root mypackage will also analyze the example subpackage. You have to specify an exclude in analysis_options.yaml to avoid that. In other words, it doesn't really seem like there's precedent for Dart tooling being aware of subpackages and handling them differently than any other subdirectory.

Given that and the fact that this would be a behavioral change that consumers might be relying on, I'm hesitant to introduce this (at least in a minor release). Using the exclude option is at least an easy way to accomplish the same thing. What do you think?

evanweible-wf avatar May 27 '22 15:05 evanweible-wf

My only concern is that this would be inconsistent with how the Dart analyzer works. Right now, if you have a directory structure like the one you outlined, running the analyzer from the root mypackage will also analyze the example subpackage. You have to specify an exclude in analysis_options.yaml to avoid that. In other words, it doesn't really seem like there's precedent for Dart tooling being aware of subpackages and handling them differently than any other subdirectory.

The problem is, a dependency in subpackage should not be added to the parent's yaml! So it is indeed a bug.

fzyzcjy avatar May 27 '22 23:05 fzyzcjy

Hello, would you be able to potentially add an option to easily toggle on/off sub packages without having to explicitly set to exclude each package?

DanielSmith1239 avatar Aug 18 '22 02:08 DanielSmith1239