Parsing Error The Keyword import is Reserved (SublimeLinter-contrib-eslint)

后端 未结 10 2144
南笙
南笙 2021-01-31 01:14

I have a problem with eslint, it gives me [Parsing Error The keyword import is reserve] this is only occur in sublime, in atom editor work well. I have eslint

.eslintr

10条回答
  •  一个人的身影
    2021-01-31 02:01

    Spent 30 mins - trying all solutions but dint work, so sharing this one.

    The issue is seen with new react app, and in Visual Code, even at this time - Apr 2020.

    1. Create a file .eslintrc.js in the root folder (beside package.json, or beside /src/ directory)
    2. Paste below contents in .eslintrc.js
    3. Restart your editor, like VS Code.
    4. Now I can see real errors, instead of those fake import/export errors.

    .eslintrc.js file contents:

    module.exports = {
      env: {
        commonjs: true,
        node: true,
        browser: true,
        es6: true,
        jest: true,
      },
      extends: ["eslint:recommended", "plugin:react/recommended"],
      globals: {},
      parser: "babel-eslint",
      parserOptions: {
        ecmaFeatures: {
          jsx: true,
        },
        ecmaVersion: 2018,
        sourceType: "module",
      },
      plugins: ["react", "import", "react-hooks"],
      ignorePatterns: ["node_modules/"],
      rules: {},
      settings: {
        react: {
          version: "latest", // "detect" automatically picks the version you have installed.
        },
      },
    };
    

    Hope that helps.

提交回复
热议问题