๐ Knip's gitignore parser does not handle `*#` correctly
Sjlver opened this issue ยท 5 comments
Sjlver commented
Prerequisites
- I'm using the latest version
- I've read the relevant documentation
- I've searched for existing issues
- I've checked the list of known issues
- I've read the issue reproduction guide
Reproduction url
Sorry, don't have one
Reproduction access
- I've made sure the reproduction is publicly accessible
Description of the issue
We have the following entry in one of our .gitignore files:
*#
I think it's supposed to ignore emacs backup files (or whatever other tool appends #
to files).
Knip seems to misinterpret it:
$ yarn run knip --debug
...
[project-dir] Glob options
{
patterns: [
'project-dir/**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}',
'!back/package.json',
'!back/tsconfig.json',
'!back/tsconfig.*.json'
],
cwd: '/redacted',
dir: '/redacted/project-dir',
gitignore: true,
absolute: true,
dot: true,
ignore: [
'project-dir/**/*',
]
}
[project-dir] Project paths (0)
[]
This results in no project files being found.
webpro commented
Sorry, don't have one
Can you explain why it wouldn't be helpful in this case?
mcous commented
I hit this exact issue today, made a simple reproduction repository here: https://github.com/mcous/knip-795
mcous commented
.gitignore
contents
node_modules
*#
Relevant output of knip --debug
[*] Parsed gitignore files
{
gitignoreFiles: [ '.git/info/exclude', '.gitignore' ],
ignores: Set(5) {
'.git',
'**/node_modules/**',
'.yarn',
'**/node_modules',
'**/*'
},
unignores: []
}
If I remove *#
from the .gitignore
:
[*] Parsed gitignore files
{
gitignoreFiles: [ '.git/info/exclude', '.gitignore' ],
ignores: Set(4) { '.git', '**/node_modules/**', '.yarn', '**/node_modules' },
unignores: []
}
Easy workaround is to use knip --no-gitignore
Sjlver commented
Woohoo, thanks a lot!