5

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

Henke
  • 2,831
  • 2
  • 16
  • 26
Joji
  • 3,901
  • 5
  • 19
  • 58
  • is the word enum in your code base? Seems like you are using in way that does not define an enum. – DCTID Aug 13 '20 at 03:29

2 Answers2

7

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

"parser": "@typescript-eslint/parser"
Joji
  • 3,901
  • 5
  • 19
  • 58
1

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

https://typescript-eslint.io/docs/linting/

Brad Zacher
  • 2,259
  • 17
  • 28