Skip to content
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

ESLint looks for .eslintrc.* files even when -c flag is used #9535

Closed
not-an-aardvark opened this issue Oct 29, 2017 · 8 comments · Fixed by Urigo/tortilla#62, mono-js/mono-notifications#5, mono-js/mono-push#5 or terrajs/lib-starter#5 · May be fixed by ali8889/emerald-wallet#4
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features documentation Relates to ESLint's documentation

Comments

@not-an-aardvark
Copy link
Member

Tell us about your environment

  • ESLint Version: master
  • Node Version: 8.8.0
  • npm Version: 5.4.2

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

Configuration
# foo.yml

rules:
  semi: 2
# .eslintrc.yml

rules:
  no-console: 2

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

console.log('foo');
eslint -c foo.yml foo.js

What did you expect to happen?

I expected no errors to be reported, because I used the -c flag to specify a config, so I did not expect ESLint to also look for other config files in the filesystem.

What actually happened? Please include the actual, raw output from ESLint.

1:1   error  Unexpected console statement         no-console

In addition to the config file specified with -c, ESLint also looked for .eslintrc files in the current directory, so the no-console rule was enabled.

@not-an-aardvark not-an-aardvark added breaking This change is backwards-incompatible bug ESLint is working incorrectly core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 29, 2017
@alberto
Copy link
Member

alberto commented Oct 29, 2017

Does it also happen with root: true?

@gyandeeps
Copy link
Member

gyandeeps commented Oct 29, 2017

I dont think its a bug, it was designed this way. You have to use --no-eslintrc option to disable that feature. So -c and --no-eslintrc are individual options.
Thats why your nested .eslintrc files (like in test folder) will respected even when you supply a config file using -c flag.

root: true is used inside .eslintrc files to stop the traversal lookup of .eslintrc files up in the hierarchy chain.

@platinumazure
Copy link
Member

I agree with @gyandeeps, this is as designed. We could update the docs to clarify that it might make sense to also use --no-eslintrc if no other config files should be used.

I do use this feature in combination with ESLint config files, so please let's not change this if possible...

@platinumazure
Copy link
Member

I'd be okay with changing this in a major release if it's possible to combine with a --eslintrc or --use-eslintrc to explicitly opt back into normal config resolution. But I want to continue supporting the use case (eslintrc resolution plus overrides in -c).

@not-an-aardvark
Copy link
Member Author

Ok, it seems like this is working as designed, so I'll update it to be a documentation issue. I think we should document more clearly that -c still causes ESLint to look for other config files.

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion documentation Relates to ESLint's documentation and removed breaking This change is backwards-incompatible bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Oct 29, 2017
platinumazure added a commit that referenced this issue Jan 15, 2018
Users must use --no-eslintrc to prevent `.eslintrc.*` files from being used
@platinumazure
Copy link
Member

@WalterBoles I've created #9847 to address this, which should be merged later this week and will be updated on eslint.org when we cut a new minor release on Friday or Saturday.

@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.