[英]eslint Parsing error: Unexpected token =
Why is eslint throwing this error?为什么 eslint 会抛出这个错误? The Javascript runs without issue inside of React Native. Javascript 在 React Native 内部运行没有问题。 The code was taken from the react-navigation example at : https://reactnavigation.org/docs/intro/代码取自 react-navigation 示例: https : //reactnavigation.org/docs/intro/
Javascript: Javascript:
static navigationOptions = { header: null };
eslint error: eslint 错误:
error Parsing error: Unexpected token =
.eslintrc.js file: .eslintrc.js 文件:
module.exports = {
"extends": "standard",
"plugins": [
"react",
"react-native"
]
};
The syntax is not yet standardised, but a stage-2 proposal for inclusion in Javascript (see "Class Fields" on https://github.com/tc39/proposals ).语法尚未标准化,而是包含在 Javascript 中的第 2 阶段提案(请参阅https://github.com/tc39/proposals上的“类字段”)。
Try adding the following option above "extends" in your .eslintrc.js:尝试在 .eslintrc.js 中的“extends”上方添加以下选项:
"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.重新启动 VSCode 解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.