antoine-coulon / skott

All-in-one devtool to automatically analyze, search and visualize project modules and dependencies from JavaScript, TypeScript (JSX/TSX) and Node.js (ES6, CommonJS)
MIT License
669 stars 25 forks source link

Support ignore patterns to prevent files from being included in the emitted graph #34

Closed antoine-coulon closed 1 year ago

antoine-coulon commented 1 year ago

Thanks again to @pigoz for that other feature request.

The issue #33 will deal with node filtering directly in the webapp meaning that the graph has internally all the files.

However for other display modes that are not dynamic, we might want to have the same feature which is preventing some specific files to be included in the emitted graph. As of now, skott internally has already a set of files to ignore but it's opinionated and not flexible nor configurable.

Consequently the idea would be to provide an ignorePatterns option discarding a set of files from the analysis. This feature could be seemlessly combined with the webapp node filter feature.

skott --ignorePattern "/**/config/*"
AntonNiklasson commented 1 year ago

Would this also add support for ignoring files completely from the checks? Or is there already a way of doing that? I have a setup where I want to explicitly allow something that's currently reported as a circular dependency.

antoine-coulon commented 1 year ago

Circular dependencies checks are decoupled from the graph construction, in the current model they will be done after the emission of the graph.

Consequently as of today, there is no solution to apply ignore patterns on the checks only. Since this PR got merged, skott is able to discard files that are matching the patterns in all .gitignore that will be found during the file directory traversal, but the thing with this approach is that "gitignored" modules won't be added at all in the graph, letting no room for filtering circular dependencies.

I have a setup where I want to explicitly allow something that's currently reported as a circular dependency.

Actually with skott the only consequence of circular dependencies is to have them displayed in a specific way (red both in the cli and webapp) and make the process exit with an error code by default (but this can be disabled by a CLI flag).

Would you please mind opening a specific issue doing a little specification of your problem, describing what this prevents you from achieving and how you would expect it to be resolved? I have no problem implementing it, but there are many ways of solving that issue, whether it's from the visualization part (where you could filter out thing) or from the graph construction part.