【问题标题】:ESLint returns syntax error in new syntax in ReactESLint 在 React 的新语法中返回语法错误
【发布时间】:2021-08-01 10:06:22
【问题描述】:

ESLint 在函数中捕获新语法中的错误。并在'='下划线

changefunction = () => {}

它是 .eslintrc 文件

{
"extends": "react-app",
"rules": {
    "no-console": "warn",
    "react/jsx-uses-react": "error",
    "react/jsx-uses-vars": "error"
},
"plugins": [ "babel", "react/recommended" ],
"parser": "babel-eslint",
"parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    }
  }    
}

【问题讨论】:

  • eslintrc.json { "env": { "browser": true, "es2021": true }, "extends": [ "eslint:recommended", "plugin:react/recommended", " google" ], "parserOptions": { "ecmaFeatures": { "jsx": true }, "ecmaVersion": 12, "sourceType": "module" }, "plugins": ["react" ], "rules": { }
  • 实际错误是什么?
  • error 解析错误:Unexpected token = and Unexpected 'this' no-invalid-this (in class component)

标签: reactjs babeljs jsx eslint


【解决方案1】:

改成this.changefunction = () => {}怎么样?

【讨论】:

    猜你喜欢
    • 2018-12-05
    • 2014-11-15
    • 1970-01-01
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 2021-09-28
    • 2013-06-13
    • 2013-11-26
    相关资源
    最近更新 更多