T
T
Tweedledum2020-01-31 14:43:50
typescript
Tweedledum, 2020-01-31 14:43:50

Why does eslint throw Unexpected token with valid typescript code?

I put eslint for an already existing react project, the problem occurs with the following code:

client = applyErrorProcessing(client, [401, 403, 404, 500]);
    return client.catcher(400, response => {
        const validationError = JSON.parse(response.message) as ValidationError;
        if (validationError.errors) {


eslint throws this error:

19:62  error  Parsing error: Unexpected token, expected ";"

  17 |     client = applyErrorProcessing(client, [401, 403, 404, 500]);
  18 |     return client.catcher(400, response => {
> 19 |         const validationError = JSON.parse(response.message) as ValidationError;
     |                                                              ^


here are my settings from .eslintrc, although env has no effect on this error

"extends": [ "airbnb", "eslint:recommended", "react-app" ],
  "parser": "babel-eslint",
  "env": {
    "es6": true,
    "node": true,
    "browser": true,
    "commonjs": true
  },


here is package.json:

"react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-fontawesome": "^1.7.1",
    "react-jss": "^10.0.3",
    "react-redux": "^7.1.3",
    "react-router-dom": "^5.1.2",
    "react-select": "^3.0.8",
    "react-toastify": "^5.4.1",
    "redux": "^4.0.1",
    "redux-localstorage": "^0.4.1",
    "redux-thunk": "^2.3.0",
    "typescript": "^3.7.3",
   "html-webpack-plugin": "^3.2.0",
    "react-scripts": "^3.0.1",
    "eslint-config-airbnb": "^18.0.1",
    "babel-eslint": "^10.0.3"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Stolyarov, 2020-01-31
@Tweedledum

ESLint doesn't understand TypeScript out of the box. Parser and plugin needed: @typescript-eslint/parser @typescript-eslint/eslint-plugin
Read more .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question