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
if config appears in project folder, configs in home directory can't be seen totally #7729
Comments
Per the documentation, this behavior is intentional and working as designed. Generally, it's better to just put your entire configuration in your project, because that way if you work with other people, you'll all have the same configuration in source control within the project directory. If you want to avoid creating the same config for multiple projects, you can create a plugin or a shareable config and publish that to npm. |
intentional? then what does "config cascading and hierarchy" mean sir? |
It means that configurations in ancestor directories (relative to the location of the file to be linted) do get factored in as part of a cascade, except that a configuration in a user's home directory is special-cased to only be used if literally no other configuration is found. I'm not 100% sure what is supposed to happen if your project is in a descendant of your home directory, so that the home directory is also part of the ancestor directories. As I said earlier, it usually makes more sense to have all of your config files in your project directory. If you rely on a configuration in your home directory and you start sharing a project on GitHub or similar, then part of the linting configuration you've been using won't get to any of your fellow collaborators and your codebase will become inconsistent. |
Thank you for your patience.
what do you think? |
@roneyrao Thanks for including a documentation snippet. The part you have emphasized is generally correct, except when one of the two .eslintrc files is in a home directory because that is intentionally given lowest priority. You may be right that the documentation could be made clearer. Personally, though, I find it weird that the home directory .eslintrc is deprioritized when the home directory is actually an ancestor of your project directory. I wonder if it should be treated as a normal ancestor directory file, when the home directory is an ancestor of the project directory. Maybe only if the home directory is not an ancestor of the project directory should it be included as a fallback if literally no other configuration file is found. @eslint/eslint-team Can anyone speak to what rationale we might have behind the current config cascade/resolution logic, where a home directory config file is ignored entirely even if the home directory is an ancestor of the project directory? |
Yes, my project is a descendant of home. now, the two rules for 'home' and 'ancestor' collide. which one to choose, and even the 'home' rule itself, is better to placed in the docs, in case new comers get confused. Anyway, thanks for team's hard work! |
@roneyrao No worries, thanks for your patience. I'm hoping my previous comment will pull in some team members who can explain the current logic. If we decide not to change the current logic, then we can make a documentation change. Either way, this is no longer just a question, so I've relabeled the issue. |
If I'm not mistaken, last one to change/rewrite config cascading logic (including home directory special case), was @btmills |
It looks like this behavior has been around since the original commit that implemented the hierarchy. The specific case of a project within the home directory when the home directory contains a config file wasn't covered in the spec, which was an oversight on my part. Then in the implementation, @nzakas decided to exclude the home directory from traversal toward the root. It doesn't look like that distinction is documented anywhere. So which is the correct behavior in the case above? Should it include or exclude a home directory config as part of the root traversal for projects within the home directory? |
The exclusion takes effect. The problem is that the docs doesn't mention that, so I considered it as a bug and filed this issue. |
I think the current behavior is correct. the home directory is a special case because it can unintentionally affect a lot of projects (iirc this was an early complaint). I think changing that now would be confusing and possibly damaging to the current user base. I'm all for updating the docs to make this special case clearer. |
I ran into this today as I attempted to run tests via Heroku CI which deploys your app's source to the home-directory of the user running the test. This causes any configuration cascade to fail without warning. A project config is usually located at Would it be possible to allow |
That would break a lot of things if it's by default; I explicitly rely on |
@ljharb I believe the accepted resolution here is to update the docs to make it clear that the home directory is a special case. I agree with others that this is too big a breaking change to introduce now. |
Closing because this was fixed in eca01ed. |
Tell us about your environment
Linux version 3.6.32-431.11.2.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Tue Mar 25 19:59:55 UTC 2014
ESLint Version:
v3.11.1
Node Version:
v7.2.0
npm Version:
3.10.9
What parser (default, Babel-ESLint, etc.) are you using?
espree
Please show your full configuration:
What did you do? Please include the actual source code causing the issue.
What did you expect to happen?
config cascading and hierarchy take effect.
run: eslint --print-config app.js
long config list shows, with the same content with when no empty config appears in project folder;
run: eslint app.js
error 'a' is assigned a value but never used no-unused-vars
What actually happened? Please include the actual, raw output from ESLint.
run: eslint --print-config app.js
{
"globals": {},
"env": {},
"rules": {},
"parserOptions": {}
}
run: eslint app.js
error Parsing error: The keyword 'const' is reserved
The text was updated successfully, but these errors were encountered: