Search code examples
reactjstypescripteslinteslint-config-airbnbtypescript-eslint

Parsing error: The keyword 'enum' is reserved


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


Solution

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

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