eslint: eslint throws exception when no configuration file found.

When no configuration file is present, eslint prints an exception backtrace to the console and returns an exit status of 1. This throws a spanner in the works of automated syntax checkers like flycheck as seen here.

$ echo 'var x = "y";' | eslint --stdin                                                                                                                                                                
No ESLint configuration found.
Error: No ESLint configuration found.
    at getLocalConfig (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/config.js:162:35)
    at Config.getConfig (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/config.js:256:22)
    at processText (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/cli-engine.js:222:33)
    at CLIEngine.executeOnText (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/cli-engine.js:749:26)
    at Object.execute (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/lib/cli.js:174:42)
    at /Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/bin/eslint.js:57:36
    at ConcatStream.<anonymous> (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/node_modules/concat-stream/index.js:36:43)
    at emitNone (events.js:72:20)
    at ConcatStream.emit (events.js:166:7)
    at finishMaybe (/Users/cowboyd/.nvm/versions/node/v4.2.3/lib/node_modules/eslint/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14)

One possible solution would be to make this a warning not an error, or also to have an option to suppress the error / warning. e.g. eslint --no-configuration-ok

Environment

> eslint "--version"
>v3.5.0
> node -v                                                                                                                                                   
> v4.2.3
> npm -v

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 33 (18 by maintainers)

Most upvoted comments

Actually, having --check-config or '–show-config-location` option in ESLint that prints location of configuration file of showing notice that there is no configuration is best solution to this problem. In the case that there is configuration, we can still be using ESLint as default JS checker in Emacs and keep ESLint as first JS checker. If there is no configuration we know that using ESLint can not be used. In that case we can fallback to JSHint or something else.

@platinumazure, is implementing this an option for ESLint team?