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
When running eslint from another directory and using --ignore-path, paths are not relative to .eslintignore location #6759
Comments
eslint
from another directory and using --ignore-path
, paths are not relative to .eslintignore
location
It seems reasonable to me to use a provided |
Changing that would be a breaking change. |
Or would it be a bugfix? I can't think of a single reason why someone would want the behavior of the |
We prefer an open discussion in the issue before putting in in the TSC agenda, so we can get feedback from everyone. One possible use case is someone keeping the ignore file outside the project. |
Hmm, does If no, we should consider proper behavior. In this case, I think too aggressive if we address this as a bug. For example, there might be people which use {
"lint-src": "eslint . -c conf/src.eslintrc.json --ignore-path conf/src.eslintignore",
"lint-test": "eslint . -c conf/test.eslintrc.json --ignore-path conf/test.eslintignore"
} |
@IanVS please add a comment for the TSC that summarizes what you're seeking guidance on (see http://eslint.org/docs/maintainer-guide/issues.html#when-to-send-to-tsc for the format). |
@nzakas thanks. There have been a lot of changes to our process lately and I admit I haven't kept up as much as I should have. In gitter you had said,
So I thought I needed to get this on the agenda to approve its acceptance as a bug. |
Consider this file structure:
And imagine the contents of
Here are a few commands that could be run, along with the results as they currently stand:
As you can see, linting the same file with the same ignore file has different outcomes depending on where the command is run. Even though the
This is why I think this is a bug that should be fixed. The patterns specified in an eslint ignore file should also be relative to the location of the file, not relative to whatever location eslint is invoked from. |
@alberto, @mysticatea The fix I'm proposing here would not prevent either of those use cases. The contents of the ignore files being used would just simply need to contain proper patterns/globs which match the desired files to ignore based on their relative position to the ignore file itself. |
@IanVS you are always free to accept bugs that you have verified, regardless of their location. |
There was some discussion whether this is actually a bug or a feature. I feel pretty strongly it's a bug, but willing to hear counterarguments. |
I think this might be a bug. At my work, we run I do think it makes more sense (principle of least surprise) for |
@IanVS I think what you are proposing is very reasonable, and I am not saying it would prevent the use cases we mentioned, just that it will change the current behaviour. It will affect people relying on the current one (like the example @mysticatea showed), whose setup will stop working and they'll have to change the ignore file paths. That makes me a bit reluctant to introduce this change in a minor release. |
@alberto, can you explain? I don't see how this effects @mysticatea's example. |
@IanVS ah, gotcha. If you're unsure if this is a |
Sorry, my tablet freaked out and accidentally hit the wrong button. What I was saying: if there's a question about whether or not this is a bug and whether or not we would need a major release to address, then it should go in the TSC agenda. We'd just need a comment summarizing the issue and explaining what question(s) the TSC should answer. |
@IanVS in my example, probably the developer needs to add I got it about Hmm, I will not oppose it, but I'm still afraid to do this change without a major version... |
@mysticatea Ah yes I see, thanks. They would need to make a small change to their ignore files, but they will still be able to use that strategy. I was trying to think of a case where if we make this change then they are unable to work the same way at all, no matter how they change the ignore file. I can't think of anything like that so far. |
I'm okay with this being treated as a breaking change too. I just want to see it done at some point 😄 Maybe we could also consider adding an option that would enable the old behavior? (Or put the proposed behavior behind an option, but... 😢) |
Oh man, please no options! 😺 Seriously though, if this is a breaking change, I'd rather just wait for a major version. |
@IanVS Apologies, I meant as a separate enhancement later on. No need to add an option now. I'm also okay with treating this as a breaking change. |
👍 |
I know I opened the issue, but fwiw I also feel like it's a bug and I'm okay with it being a breaking change. A lot of SublimeText users are eager for that change, and I know the entire dev team at my previous job will be happy, too. |
Accepted as a breaking change. That means we can't merge it before 4.0. |
I can help with the ignore-paths.js. And any progress about #6783 ? |
@eslint/eslint-team This has been sitting for a long time. Has anyone started work on this? Do we still want this in for 4.x? If nobody has started working on it, I'm interested in working on this, but I want to close out some of my open PRs first (so if anyone else wants to start this, definitely go ahead). |
Ah, I lost track of this. I'd like to take a shot at it, @platinumazure, but I am going to be traveling until next week. So if you've got time this weekend then go for it. |
Working on this. |
What 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:
.eslintrc
.eslintignore
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
Expected
C:\dev\eslint-bug\src\foo.js
to be ignoredWhat actually happened? Please include the actual, raw output from ESLint.
Errors were reported for
C:\dev\eslint-bug\src\foo.js
: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 #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 (SublimeLinter/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.The text was updated successfully, but these errors were encountered: