When running eslint from another directory and using --ignore-path, paths are not relative to .eslintignore location
See original GitHub issueWhat version of ESLint are you using? 3.1.1
What parser (default, Babel-ESLint, etc.) are you using? default
Please show your full configuration: Project structure:
.eslintignore
.eslintrc
bar.js
src/foo.js
.eslintrc
{
"root": true,
"extends": "eslint:recommended"
}
.eslintignore
src/foo.js
What did you do? Please include the actual source code causing the issue.
$ eslint foo.js --ignore-path ../.eslintignore
C:\dev\eslint-bug\src\foo.js
1:1 error 'test' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
What did you expect to happen?
Expected C:\dev\eslint-bug\src\foo.js
to be ignored
What actually happened? Please include the actual, raw output from ESLint.
Errors were reported for C:\dev\eslint-bug\src\foo.js
:
C:\dev\eslint-bug\src\foo.js
1:1 error 'test' is not defined no-undef
✖ 1 problem (1 error, 0 warnings)
In Configuring ESLint it says “Paths are relative to .eslintignore
location or the current working directory”. As a user, I would assume that if I passed in --ignore-path
that it would ignore files as if I had called ESLint from that directory.
I see that there have been a lot of issues opened regarding ESLint ignore and parent directories, but after eslint/eslint#5694, ignoring files in SublimeText with SublimeLinter-eslint has been broken. There is an open PR to fix an existing issue with loading .eslintignore in SublimeLinter-eslint (roadhump/SublimeLinter-eslint#145), but it doesn’t work after ESLint 2.5.0.
There is an option in the CLIEngine to specify a cwd
. If my above process is “working as intended” (or perhaps I have misinterpreted the documentation), then it would be great to be able to pass in a --cwd
option for the command line so that the relative paths can be loaded correctly.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:30 (27 by maintainers)
Top GitHub Comments
It seems reasonable to me to use a provided
--ignore-path
directory as the base dir when we convert the filename to a relative path. I’ve tried a possible implementation of this and it seems to work and not break any of our existing tests, would be happy to submit a PR if this is accepted by the TSC.Or would it be a bugfix? I can’t think of a single reason why someone would want the behavior of the
.eslintignore
file to depend on cwd when linting is performed. I doubt that was intended, but maybe I’m wrong. That’s something for the TSC to decide anyway. I’m tossing it on the agenda.