-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Adding ignore-path flag referencing a file in node_modules not respecting ignore config #9227
Comments
Thanks for reporting, I can reproduce this. |
How can I help fix this? |
From investigating just now, I think the issue was introduced in e395919, where we switched to resolving ignore patterns from the location of the I think the problem is that in addition to resolving ignore patterns that appear in the The cause of the issue seems to be here. edit: I think this would also need to be changed in a similar way, too. |
Thanks for that insight! So, if I understand you correctly, the fix would be changing this: Lines 229 to 251 in c8bf687
to: contains(filepath, category) {
let result = false;
const absolutePath = path.resolve(this.options.cwd, filepath);
- const relativePath = pathUtil.getRelativePath(absolutePath, this.baseDir);
+ const baseDir = category === "default" ? this.options.cwd : this.baseDir;
+ const relativePath = pathUtil.getRelativePath(absolutePath, baseDir);
if ((typeof category === "undefined") || (category === "default")) {
result = result || (this.ig.default.filter([relativePath]).length === 0);
}
if ((typeof category === "undefined") || (category === "custom")) {
result = result || (this.ig.custom.filter([relativePath]).length === 0);
}
return result;
} Also, what's a good place to write tests for this changed behavior? in |
I think that's almost right, although I think that would have the issue where Something like this should work: contains(filepath, category) {
let result = false;
const absolutePath = path.resolve(this.options.cwd, filepath);
- const relativePath = pathUtil.getRelativePath(absolutePath, this.baseDir);
if ((typeof category === "undefined") || (category === "default")) {
+ const relativePath = pathUtil.getRelativePath(absolutePath, this.options.cwd);
result = result || (this.ig.default.filter([relativePath]).length === 0);
}
if ((typeof category === "undefined") || (category === "custom")) {
+ const relativePath = pathUtil.getRelativePath(absolutePath, this.baseDir);
result = result || (this.ig.custom.filter([relativePath]).length === 0);
}
return result;
} Also, after I commented before I noticed another place that might also need to be changed in a similar way (to resolve default patterns from the
Yes, I think that's the right place to put them. |
Hi, We have the same problem. @not-an-aardvark @kentcdodds any chance of seeing this fixed? |
I'd love for this to be fixed, but my pull request hit a wall and I don't have any more time for it. |
Working on this. |
This fixes an issue where the default ignore patterns, such as `/node_modules`, would always be resolved from the location of an `.eslintignore` file. As a result of the bug, the `node_modules` folder in the project root directory would not be ignored if an `.eslintignore` file in a subdirectory was being used.
Thank you! 👏 |
Still getting this error with latest eslint 5.6.1. I am on windows. Any ideas? |
@cemremengu May you please create a new issue? It's possible that a different set of circumstances can lead to the same behavior, but it's hard to tell without more information. |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using? N/A
Please show your full configuration: N/A
Configuration
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
I expected the eslintignore to be applied
What actually happened? Please include the actual, raw output from ESLint.
It is not. I get an error indicating that eslint is processing files in
node_modules
.Here's the contents of
node_modules/kcd-scripts/dist/config/eslintignore
:I think that the docs indicate that the patterns here will be relative to the
.eslintignore
file, so I changed the eslintignore file to various patterns (including../../../node_modules/
,**/node_modules/**
). None of those combinations seemed to work. I think there may be a bug here, but I'm uncertain... Happy to dig in more if someone can tell me I'm not missing something obvious.To reproduce: https://github.com/kentcdodds/eslint-config-issue
Install deps and run
npm run broken
andnpm run working
.Thanks!
The text was updated successfully, but these errors were encountered: