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

后端 未结 10 1938
南笙
南笙 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 01:44

    The problem was i had installed eslint globally and locally, causing inconsistencies in SublimeLinter-contrib-eslint. I uninstalled eslint globally and SublimeLinter is working.

    0 讨论(0)
  • 2021-01-31 01:45

    Add this to the root of your .eslintrc

    "parser": "babel-eslint"
    

    and make sure to run:

    npm i babel-eslint --save-dev
    
    0 讨论(0)
  • 2021-01-31 01:45

    i also got this error in a meteor project and i could solved it setting sourceType to "module" more details can be found in Eslint docs: http://eslint.org/docs/user-guide/configuring#specifying-parser-options

    0 讨论(0)
  • 2021-01-31 01:48

    The eslint option that solves the "The keyword import is reserved" error is parserOptions.sourceType. Setting it to "module" allows the import keyword to be used.

    .eslintrc

    {
        "parserOptions": {
            "sourceType": "module"
        }
    }
    

    Docs: https://eslint.org/docs/user-guide/configuring#specifying-parser-options

    0 讨论(0)
  • 2021-01-31 01:48

    This config worked for me. (I am using create-react-app but applicable to any eslint project)


    .eslintrc (create file in root if it doesnt exist)

    {
        "rules": {
          "jsx-a11y/anchor-is-valid": [ "error", {
            "components": [ "Link" ],
            "specialLink": [ "to" ]
          }]
        },
        "parserOptions": {
            "sourceType": "module",
            "ecmaVersion": 2015
        }
      }
    
    0 讨论(0)
  • 2021-01-31 01:54

    Closing VS code and re-open it does the trick for me...

    0 讨论(0)
提交回复
热议问题