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"
]
};
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided. This might be a simple typo.
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.
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? .... .... 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.
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.
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.
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",
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With