You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Previously it was possible to write a contract like this:
[importlinter:contract:core-factories]
name = "Factories should be split into subpackages"
type = forbidden
allow_indirect_imports = true
source_modules =
tests.factories
forbidden_modules =
tests.factories.domain_a
tests.factories.domain_b
This stopped working in 2cdb36f - essentially, the bug was a feature.
Although this is quite a "dumb" use of import linter - it's little more than a grep - it makes sense to express such contracts alongside other more powerful ones for the same codebase.
Would it be possible to support this again?
Suggestions
Introduce a separate contract type for this scenario - awkward as the intent is the same.
Introduce a flag to treat the source modules as modules and not packages*.
Something more clever where the linter recognises the contract is within the same package.
*Treating modules as packages seems to be the default / intended behaviour.
The text was updated successfully, but these errors were encountered:
Thanks Ben for these suggestions. I agree we should support this somehow.
I'm leaning towards adding an as_packages flag which, if it was set to false, would allow you to do this. That would fit in well with the terminology of Grimp, the underlying static analysis library: many of the methods there allow you to specify whether to treat the modules as_packages.
Having had more time to mull this over, I think it would the as_packages flag would be a good addition. Let me know if you would be interested in submitting a pull request!
Previously it was possible to write a contract like this:
...to prevent the following imports:
This stopped working in 2cdb36f - essentially, the bug was a feature.
Although this is quite a "dumb" use of import linter - it's little more than a
grep
- it makes sense to express such contracts alongside other more powerful ones for the same codebase.Would it be possible to support this again?
Suggestions
*Treating modules as packages seems to be the default / intended behaviour.
The text was updated successfully, but these errors were encountered: