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

Respect up-the-tree .gitignore files #531

Open
alecmev opened this issue Feb 29, 2024 · 6 comments
Open

Respect up-the-tree .gitignore files #531

alecmev opened this issue Feb 29, 2024 · 6 comments
Labels
feature request Feature request

Comments

@alecmev
Copy link

alecmev commented Feb 29, 2024

I have a .gitignore in my ~ with the following contents:

.scratch/

This allows me to plop .scratch directories all over the place and put not-for-remote stuff there like personal notes, half-baked code snippets, etc. Knip, unfortunately, doesn't look at ~/.gitignore and reports code files in .scratch directories as unused.

I don't want to add .scratch to the repo .gitignore because it has nothing to do with the project. I don't want to store these files outside of the repo because I want to keep them close to the packages they're related to.

@alecmev alecmev added the feature request Feature request label Feb 29, 2024
@webpro
Copy link
Owner

webpro commented Feb 29, 2024

Does something like npm do the same eg when publishing?

@alecmev
Copy link
Author

alecmev commented Feb 29, 2024

Doesn't look like it, unfortunately:

https://stackoverflow.com/q/12534699/242684
semantic-release-action/typescript#10 (comment)

Though I wouldn't treat npm's choices as gospel 😅

@alecmev
Copy link
Author

alecmev commented Feb 29, 2024

To frame this a little bit differently, how else could I tell Knip to ignore **/.scratch/** without polluting the configuration?

@webpro
Copy link
Owner

webpro commented Feb 29, 2024

I'm not against the feature per se, but I also don't want unexpected results. What might be a feature to you, could be a hard-to-track and tricky-to-overcome issue to someone else.

So if other tools use it as well it's common/expected behavior.

To frame this a little bit differently, how else could I tell Knip to ignore **/.scratch/** without polluting the configuration?

You can use ignore at the root config with this pattern. If you don't fancy that you could perhaps use a knip.ts and make it more DRY.

@alecmev
Copy link
Author

alecmev commented Mar 1, 2024

I'm struggling to find examples. Prettier doesn't respect .gitignore, nor does ESLint. Biome, however, does (at least intends to). Outside of JavaScript, RipGrep does too, and fd. Can you maybe suggest some more projects to take a look at?

I'm not against the feature per se, but I also don't want unexpected results. What might be a feature to you, could be a hard-to-track and tricky-to-overcome issue to someone else.

On the one hand, I agree, changes like this require justification. On the other hand, Git is the common denominator here. If a file ultimately isn't committed, does it make sense to ever take it into consideration?

@TheKnarf
Copy link

It should probably just follow whatever git check-ignore does?

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

No branches or pull requests

3 participants