简体   繁体   中英

TypeScript with ESLint: Parsing error: The keyword 'enum' is reserved eslint

I am writing TypeScript with React. The project was generated with CRA. and I used react-app config for the .eslintrc.json . However I decided to use eslint-config-airbnb so I added it and changed my .eslintrc.json

{
  "extends": [
    "airbnb",
  ]
}

suddenly I got parsing error from ESLint about the enum type I used in the codebase

`Parsing error: The keyword 'enum' is reserved eslint`

I googled it but cannot find the answer. Tried to add some extra config like

"parserOptions": {
    "ecmaVersion": 7,
  }

but it doesn't solve the problem

I found out I just needed to add this one line in the config file of ESLint

"parser": "@typescript-eslint/parser"

Check out the getting started docs here for information on how to setup your typescript codebase for linting with ESLint

https://github.com/typescript-eslint/typescript-eslint/tree/master/docs/getting-started/linting

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM