eslint “parsing error: Unexpected token {” in JSX

后端 未结 3 544
滥情空心
滥情空心 2021-02-13 00:54
const title = \'My Minimal React Webpack Babel Setups\';

const App = () => (
{title}
)
3条回答
  •  星月不相逢
    2021-02-13 01:24

    I've got the same error on Next.js.

    These steps solved my issue:

    1) Install babel-eslint:

    npm install --save-dev babel-eslint
    

    2) Add babel-eslint as a parser to eslint config

    "parser": "babel-eslint"
    

    My eslint config looks like this (.eslintrc):

    {
      "env": {
        "browser": true,
        "es6": true,
        "commonjs": true,
        "node": true
      },
      "extends": ["eslint:recommended", "plugin:react/recommended"],
      "parser": "babel-eslint",
      "parserOptions": {
        "ecmaVersion": 9,
        "ecmaFeatures": {
          "jsx": true
        },
        "sourceType": "module"
      },
      "plugins": ["react"],
      "rules": {
        "react/react-in-jsx-scope": 0,
        "no-console": 1
      }
    }
    

提交回复
热议问题