eslint --init fails on parse error
See original GitHub issueTell us about your environment
- ESLint Version: 3.10.2
- Node Version: 4.6.2
- npm Version: 4.0.2
What parser (default, Babel-ESLint, etc.) are you using? Not sure, I guess Babel-ESLint since I selected yes to ES6 features.
Please show your full configuration:
❯ eslint --init
? How would you like to configure ESLint? Inspect your JavaScript file(s)
? Which file(s), path(s), or glob(s) should be examined? imports/**/*.js
? What format do you want your config file to be in? JSON
? Are you using ECMAScript 6 features? Yes
? Are you using ES6 modules? Yes
? Where will your code run? Browser, Node
? Do you use CommonJS? No
? Do you use JSX? No
What did you do? Please include the actual source code causing the issue.
This is the offending piece of code:
image.onerror = onerrCb || () => {
console.error('unable to load uploaded image', url);
};
(Notice that () =>
is highlighted in VSCode as [js] Expression expected.
).
What did you expect to happen?
I expected eslint --init
to output a configuration file anyways, ignoring parsing errors.
What actually happened? Please include the actual, raw output from ESLint.
❯ eslint --init
? How would you like to configure ESLint? Inspect your JavaScript file(s)
? Which file(s), path(s), or glob(s) should be examined? imports/**/*.js
? What format do you want your config file to be in? JSON
? Are you using ECMAScript 6 features? Yes
? Are you using ES6 modules? Yes
? Where will your code run? Browser, Node
? Do you use CommonJS? No
? Do you use JSX? No
Determining Config: 13% [====--------------------------] 1.3s elapsed, eta 8.4s
(<project-directory>/imports/startup/client/scripts/services/common.svc.js:18:45) Parsing error: Unexpected token )
Error: (<project-directory>/imports/startup/client/scripts/services/common.svc.js:18:45) Parsing error: Unexpected token )
at getSourceCodeOfFile (/usr/local/lib/node_modules/eslint/lib/util/source-code-util.js:39:15)
at /usr/local/lib/node_modules/eslint/lib/util/source-code-util.js:95:28
at Array.forEach (native)
at getSourceCodeOfFiles (/usr/local/lib/node_modules/eslint/lib/util/source-code-util.js:94:15)
at configureRules (/usr/local/lib/node_modules/eslint/lib/config/config-initializer.js:129:23)
at processAnswers (/usr/local/lib/node_modules/eslint/lib/config/config-initializer.js:248:18)
at null.completed (/usr/local/lib/node_modules/eslint/lib/config/config-initializer.js:406:30)
at PromptUI.onCompletion (/usr/local/lib/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js:57:10)
at AnonymousObserver.Rx.AnonymousObserver.AnonymousObserver.completed (/usr/local/lib/node_modules/eslint/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1550:12)
at AnonymousObserver.Rx.internals.AbstractObserver.AbstractObserver.onCompleted (/usr/local/lib/node_modules/eslint/node_modules/inquirer/node_modules/rx-lite/rx.lite.js:1489:14)
(No config file output.)
Issue Analytics
- State:
- Created 7 years ago
- Comments:10 (5 by maintainers)
Top GitHub Comments
Yes. Arrow function expressions are similar to assignment expressions in terms of operator precedence, etc.
@not-an-aardvark I think I understand a little bit more now. VS Code marks errors parsed by itself (the JS plugin I guess?) with the
[js]
prefix and ESLint with[eslint]
so I think the error was not being reported by ESLint in VS Code, which makes sense.