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.

Arrow functions: "Parsing error: unexpected token ="

See original GitHub issue

Tell us about your environment

  • ESLint Version: 4.19.1
  • Node Version: 7.9.0
  • npm Version: 5.5.1

What parser (default, Babel-ESLint, etc.) are you using? "babel-eslint": "^8.2.2",

Please show your full configuration:

Configuration
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jest": "^21.15.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",

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

anyFunc = (e) => {
    // does not matter what is inside
  }
./node_modules/.bin/eslint myfile.jsx

What did you expect to happen? Errors should be output and shown in VS Code.

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

34:16 error  Parsing error: Unexpected token =

✖ 1 problem (1 error, 0 warnings)

VS Code integration breaks: the first = is underlined with this message:[eslint] Parsing error: unexpected token =. Linting is broken for entire file, no other errors are shown even though they exist, and autofix on save does not work.

Everything works as expected for files without arrow functions both via CL and in VSCode.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:16 (2 by maintainers)

github_iconTop GitHub Comments

83reactions
euharrisoncommented, May 1, 2018

You should add babel-eslint as parser.

extends: airbnb
parser: babel-eslint
plugins:
  - react
  - jest
(...)
13reactions
flagpoonagecommented, Nov 13, 2018

babel-eslint is not needed for this from at least version 5.9.0 (probably earlier) I was able to use arrow functions by setting the ecmaVersion to 2018

{
  "parserOptions": {
    "ecmaVersion": 2018
  },

  "env": {
    "node": true,
    "es6": true
  },
  
  "extends": "eslint:recommended"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Eslint - `Parsing error: unexpected token =` error for assigned ...
I'm using an arrow function and it's ...
Read more >
ESLint: "Parsing error: Unexpected token" in Visual Studio Code
Unexpected token errors are caused by incompatibilities in your parser options and the code you're writing. In this case, I'm using a number...
Read more >
parsing error: unexpected token javascript
Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing capabilities with the ...
Read more >
Parsing error: unexpected token ':' - The freeCodeCamp Forum
An arrow function expression is a syntactically compact alternative to a regular function expression, although without its own bindings to the ...
Read more >
Arrow function expressions - JavaScript - MDN Web Docs
An arrow function expression is a compact alternative to a ... const func = (a, b, c) => 1; // SyntaxError: Unexpected token...
Read more >

github_iconTop Related Medium Post

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 Hashnode Post

No results found