Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Ignore Patterns #79

Open
rypete opened this issue Aug 15, 2023 · 12 comments
Open

Multiple Ignore Patterns #79

rypete opened this issue Aug 15, 2023 · 12 comments
Labels
core enhancement New feature or request

Comments

@rypete
Copy link

rypete commented Aug 15, 2023

I have a few different patterns I want to ignore via --ignorePatterns but it seems this can only accept one pattern? It would be great if this could accept an array similar to --fileExtensions

@jakebiesinger
Copy link

I also happened to need this today... it's hacky, but you skott is using https://www.npmjs.com/package/minimatch under the hood, so you can use {} with comma-separated lists, e.g.,

--ignorePattern '{src/file1.ts,src/path/to/file2.ts,src/api/**/*.ts}'

Note the surrounding ' since your shell may try to interpolate otherwise.

@jakebiesinger
Copy link

I'm now using a silly command to grab this from a file if it exists:

npx skott --fileExtensions=.ts,.tsx --showCircularDependencies --ignorePattern '{'$([[ -e .skottSkips ]] && cat .skottSkips)'}' --displayMode raw

you shove your list into a file .skottSkips and it'll be pulled in

@rypete
Copy link
Author

rypete commented Aug 16, 2023

The above are very helpful, thanks. What I ended up doing was temporarily putting the paths I wanted to ignore into my .gitignore file before running skott.

@antoine-coulon
Copy link
Owner

antoine-coulon commented Aug 18, 2023

Hello folks and thanks for opening that issue @rypete!

"ignorePattern" is a pretty new feature for skott so I wanted to collect few feedbacks about the ability of ignoring specific set of files before going further as there is currently the "ignorePattern" option, the "fileExtensions" option that can be also considered as a filter even though it does not really allow fine grained file filtering and also the ".gitignore" support.

If you guys are facing some use cases where you would want multiple patterns to be provided at once I can definitely work on that to make skott support it.

Are you both @jakebiesinger @rypete using skott via the API? For the CLI it would probably require a skott config file as I'm afraid for the CLI itself it would be too verbose and error prone to allow multiple ignore patterns.

FYI I'm currently on vacation till the end of the next week so don't expect quick replies until there but I will catch up asap :)

@jakebiesinger
Copy link

I'm using skott via the CLI and would love it if there were a config file I could set and forget.

For the large typescript codebase I'm working in now, we prevent PRs containing circular imports everywhere except in a set of "context" files, where we set up helper methods that dynamically import at method call time via await import ('./some/file').doSomeThing().

Skott has found literally hundreds of circular imports that madge missed due to some shortcomings in how they're parsing extended tsconfig files (pahen/madge#322) so we're cutting over to use skott everywhere.

@antoine-coulon
Copy link
Owner

Glad to hear that it helps you out!

I'll work asap on introducing a skott config file that will enable support for all API options when using the CLI (+ multiple ignore patterns that will be available both from the CLI using the config file or directly through the API).

If you ever think of other feature suggestions that could be useful for you or if you ever encounter any issues let me know, I'm trying hard to make skott a tiny tool that fits developers needs and expectations (it's only the beginning) so I'm happy when I get feedbacks and feature requests like this :)

@rypete
Copy link
Author

rypete commented Aug 19, 2023

I'm using the CLI but not the config file. My use case is a lot simpler than @jakebiesinger and I only needed it for a showcase demo.

@antoine-coulon
Copy link
Owner

Thanks for the input, by the way the config file is not yet available, we were just discussing about the possibility of implementing it.

Without that config file I hardly see how we could easily provide multiple ignore patterns using the CLI

@rypete
Copy link
Author

rypete commented Aug 22, 2023

One way might be, and what I also tried, was to use the --ignorePatterns flag multiple times. I noticed the underlying system turned it into an array. This might be useful but I will of course use whatever you come up with.

Something like skott --ignorePatterns="**/*.test.ts" --ignorePatterns="**/*.js" etc

@antoine-coulon
Copy link
Owner

Could actually be one way to do it, didn't think about that actually, thanks!

I'm back from vacation so you'll get updates pretty soon, stay tuned!

@antoine-coulon antoine-coulon added enhancement New feature or request core labels Aug 28, 2023
@eppisapiafsl
Copy link

You need to use brackets { } to ignore multiple files

This worked for me

--ignorePattern='{commons/Store/{Redux/types/StateMachineContext.ts,ExerciseTherapySessionState/actions/transition.ts},commons/Utils/TestMocks/Provider.tsx}'

@antoine-coulon
Copy link
Owner

antoine-coulon commented Oct 30, 2023

Thanks for the tip @eppisapiafsl

This is what can be used until I investigate in providing a way to stack multiple patterns without losing too much DX. Hopefully we'll find a middle ground between easy configuration and nice DX still.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants