Feature request: Check if any import matches
See original GitHub issueContext
Our codebase is moving to a new arch and I want to add a warning if a module hasn’t been migrated yet. Essentially, I want to check if a type of dependency exists.
Let’s say I want to check if all the controller modules have been migrated, which I can simplify into a check to see if they extend the new base controller, for eg:
class 'AbcController' extends 'GenericController'
Expected Behavior
I want to check if AbcController contains an import for GenericController:
{
name: 'no-clean-arch-controller',
severity: 'warn',
"from": { "path": "^src\/api\/([^/]+)\/([a-zA-Z]+Controller.ts)"},
"to": {
"pathNot": "src\/framework\/GenericController.ts"
},
}
with the result:
no-clean-arch-controller: src/api/x/abcController.ts → src/framework/GenericController.ts
Current Behavior
It currently tells me about all the imports that aren’t GenericControllerImpl, and nothing
no-clean-arch-controller: src/api/x/abcController.ts → src/example/some-import.ts
no-clean-arch-controller: src/api/x/abcController.ts → src/example/another-import.ts
Possible Solution
A boolean to signify that there’s no dependency from A to B would be helpful.
Considered alternatives
I tried to make it work with allowed, but it became too complex and didn’t solve my issue anyway.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
add check to allow importing of matching software so long ...
Feature request - add check to allow importing of matching software so long as supported_architectures have unshared values #1076.
Read more >Request Matching — requests-mock 1.9.4.dev26 documentation
The most simple way to match a request is to register the URL and method that will be requested with a textual response....
Read more >Python's Requests Library (Guide)
In this tutorial on Python's "requests" library, you'll see some of the most useful features that requests has to offer as well as...
Read more >Understanding Client Matching Using the Data Import Tool (DIT)
Regular Matching goes through a multi-step comparison to determine a match, leveraging the Yaro-Winkler string metric for some of the fields.
Read more >Choose when to run jobs - GitLab Docs
When a match is found, the job is either included or excluded from the pipeline, depending on the configuration. See the rules reference...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was using dependency-cruiser@9.9.0-beta-3, just updated to beta-4, it works as expected, thank you so much!
Just a ping: I’ve done some polishing (published in beta-2, 3 and 4). Most notable change, only for the new required rules: the
from
attribute was renamed tomodule
so in the future it’s possible to use the ‘from’ attribute for other useful things. E.g. to make sure each source file has an associated spec file in the unit tests folder that directly points to it: