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
--config flag doesn't prevent searching for ~/.eslintrc #4881
Comments
@kentcdodds Thanks for the issue! If you're reporting a bug, please be sure to include:
Requesting a new rule? Please see Proposing a New Rule for instructions. |
I think this is a bug. The home directory config is only supposed to be used when there's no other config. I think we get confused because the command line config isn't accounted for in our current check, but I think it would make more sense that the home directory config is only used when there is no other config at all. FWIW, you can use the |
Ah, should have investigating existing debugging options before hacking away 👍 |
@nzakas Based on a lot of previous discussions specially I am fine if we want to change this behavior but just to dig deep into what this change means. Are you saying we will keep looking for files up the chain (as we already do) but will stop right before the home directory? (Let me know if I didnt explain myself well here). I just want to think this all the way through keeping in mind what we do vs what we are trying to do. I hope I understood the proposed solution correctly 😄 |
@gyandeeps that's a good point for clarification. Right now, there are two ways
If I understand this correctly, this is dealing with case (2), where the project was not under the home directory, and there were no Did I get that right? |
Perfect summary of what I experienced |
Thanks a lot @btmills for a very good explanation. |
👍 |
Why does is make any difference whether the project is inside $HOME or not? If I understand correctly the purpose of |
Because if you're in The purpose of |
Yeah, |
Breaking: don't load ~/.eslintrc when using --config flag (fixes #4881)
See twitter for context:
This issue is just meant to discuss the scenario of what happens when you run
eslint --config someESLintConfig.js foo.js
. Currently, ESLint will mergesomeESLintConfig.js
with a configuration found in the user's home directory (for example~/.eslintrc
). This can lead to some difficult to track issues.An important note to all of this is if there IS an
.eslintrc
in the directory where you're running eslint, then ESLint will not merge the user's home directory.Specifically for me my root
.eslintrc
was created pre-1.0.0 days so I kept getting a bunch of removed errors and I couldn't identify why that was happening (no amount ofgrep
in that directory would save me). I finally discovered the problem by putting in a bunch of console.logs and throwing errors throughout ESLint in mynode_modules
until I discovered what was happening.I'm personally leaning toward ESLint treating an explicit
--config
flag the same it does when there's an.eslintrc
in the directory you're running ESLint. I think the main use case for the--config
flag is to specify a specific configuration you want to use and merging the root config under the hood can lead (read: has lead) to confusion for some (read: me) :-)If this were to happen, it would be a breaking change and would require a major version bump.
As an aside, I think something that would have helped me a great deal is some way to tell ESLint where the rules it's using came from. I realize this could be quite complicated due to the way ESLint merges rules, but I wonder if it may be as simple as monkey-patching the filename to each
rule
when it's merged. And then providing some kind of flag to have ESLint print out the source of each configuration option. This would be very handy in many more scenarios. If you like this idea, let me know and I'll file another issue for discussion on it.The text was updated successfully, but these errors were encountered: