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 · May be fixed by ali8889/emerald-wallet#4, Dizzydaizys/yarn#9 or DmytroSkrypnyk/test_bootstrap#6

Comments

@not-an-aardvark
Copy link
Member

@not-an-aardvark not-an-aardvark commented Oct 29, 2017

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.

@alberto

This comment has been minimized.

Copy link
Member

@alberto alberto commented Oct 29, 2017

Does it also happen with root: true?

@gyandeeps

This comment has been minimized.

Copy link
Member

@gyandeeps 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

This comment has been minimized.

Copy link
Member

@platinumazure platinumazure commented Oct 29, 2017

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

This comment has been minimized.

Copy link
Member

@platinumazure platinumazure commented Oct 29, 2017

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

This comment has been minimized.

Copy link
Member Author

@not-an-aardvark not-an-aardvark commented Oct 29, 2017

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.

platinumazure added a commit that referenced this issue Jan 15, 2018
Users must use --no-eslintrc to prevent `.eslintrc.*` files from being used
@platinumazure

This comment has been minimized.

Copy link
Member

@platinumazure platinumazure commented Jan 16, 2018

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.