Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

eslint Parsing error: Unexpected token =

Why is eslint throwing this error? The Javascript runs without issue inside of React Native. The code was taken from the react-navigation example at : https://reactnavigation.org/docs/intro/

Javascript:

static navigationOptions = { header: null };

eslint error:

error  Parsing error: Unexpected token =

.eslintrc.js file:

module.exports = {
    "extends": "standard",
    "plugins": [
      "react",
      "react-native"
    ]
};
like image 886
Jeremy Avatar asked Jun 18 '17 21:06

Jeremy


People also ask

What does parsing error unexpected token mean?

The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided. This might be a simple typo.

What is parsing error?

A parse error is an error message you sometimes get on Android devices when an app fails to install. The message itself is not very specific, and there are a lot of problems that can cause it.

What are ESLint's unexpected token errors?

Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing capabilities with the ongoing changes with JavaScripts ES6~7.

What's the problem with ESLint parsing?

Why? .... .... What's the problem? Show activity on this post. Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing capabilities with the ongoing changes with JavaScripts ES6~7.

What does error 7/16 mean in ESLint?

Show activity on this post. 7:16 error Parsing error: Unexpected token .. Why? .... .... What's the problem? Show activity on this post. Unexpected token errors in ESLint parsing occur due to incompatibility between your development environment and ESLint's current parsing capabilities with the ongoing changes with JavaScripts ES6~7.

Why does ESLint mark this syntax as an error?

ESLint 8.2.0 is not aware of this syntax and therefore marks it as an error: The problem is that after this error is thrown, no further linting is performed, ESLint doesn't analyze any further line of code and bearing in mind that usually loading of JSON modules defined somewhere at the beginning of a file, ESLint doesn't scan the entire file.


Video Answer


2 Answers

The syntax is not yet standardised, but a stage-2 proposal for inclusion in Javascript (see "Class Fields" on https://github.com/tc39/proposals).

Try adding the following option above "extends" in your .eslintrc.js:

"parser": "babel-eslint",
like image 193
benwixen Avatar answered Oct 03 '22 19:10

benwixen


Sometimes I get this error out of blue for the code that worked previously, so I know it's not a syntax error. Restarting VSCode solves my issue.

like image 20
Mario Nezmah Avatar answered Oct 03 '22 20:10

Mario Nezmah