8

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
  • 4,445
  • 3
  • 31
  • 44
Joji
  • 4,703
  • 7
  • 41
  • 86
  • 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

11

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

"parser": "@typescript-eslint/parser"
Joji
  • 4,703
  • 7
  • 41
  • 86
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,915
  • 18
  • 31