Parsing error: The keyword 'enum' is reserved
Asked Answered
A

2

10

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

Appledorf answered 13/8, 2020 at 1:35 Comment(1)
is the word enum in your code base? Seems like you are using in way that does not define an enum.Presumptuous
A
13

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

"parser": "@typescript-eslint/parser"
Appledorf answered 13/8, 2020 at 4:31 Comment(0)
N
0

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

This will run through all the steps to properly setup your codebase.

https://typescript-eslint.io/getting-started/

You can just add the one line "parser": "@typescript-eslint/parser" to set the parser - but I'd still recommend reading the docs so you don't get into a weird state!

Norford answered 13/8, 2020 at 18:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.