question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

eslint --init fails on parse error

See original GitHub issue

Tell 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:closed
  • Created 7 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
not-an-aardvarkcommented, Nov 24, 2016

Yes. Arrow function expressions are similar to assignment expressions in terms of operator precedence, etc.

foo = bar || baz = qux; // syntax error

foo = bar || baz => qux; // syntax error

foo = bar || (baz = qux); // ok

foo = bar || (baz => qux); // ok
0reactions
alejandroiglesiascommented, Nov 29, 2016

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I fix this error message "Initialization error (Eslint ...
My attempts at recreating the issue with a fresh project failed, with the same configs, both eslint and jscs were running successfully.
Read more >
Command Line Interface - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Parsing error: Unexpected token for Eslint --init - Google Groups
Hi Marina, It looks like it's failing to install eslint-plugin-react. Can you try answering “no” for that question and see if you can...
Read more >
ESLint - npm
ESLint uses Espree for JavaScript parsing. ... After running npm init @eslint/config , you'll have a .eslintrc file in your directory.
Read more >
eslint/eslint - Gitter
I wonder if anyone else gets a JSON parse error with eslint --init ? ... I keep receiving an error: "Failed to load...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found