Home > Enterprise >  How to get eslint in vscode to use the correct compilerOptions.target from tsconfig.json
How to get eslint in vscode to use the correct compilerOptions.target from tsconfig.json

Time:10-31

eslint in vscode is reporting the error:

Type 'this' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."

I would have thought that eslint would look at my tsconfig.json and see that I have set the TypeScript compilerOptions.target to es2015.

For good measure, I also added the following to my package.json

  "eslintConfig": {
    "env": {
      "node": true,
      "es2015": true
    }
  }

Despite the correct configuration, eslint is still reporting the error ts(2802).

How can I get the built-in eslint in vscode to know that my target is es2015 and not report that error?

CodePudding user response:

You dont have to add eslintconfig in package json.

Make sure you have in tsConfig.json -> compilerOptions.target: "target": "es2017" and in package.json => devDependencies :

"eslint": "^8.17.0"
"@angular-eslint/builder": "13.5.0",
"@angular-eslint/eslint-plugin": "13.5.0",
"@angular-eslint/eslint-plugin-template": "13.5.0",
"@angular-eslint/schematics": "13.5.0",
"@angular-eslint/template-parser": "13.5.0",
"@typescript-eslint/eslint-plugin": "5.27.1",
"@typescript-eslint/parser": "5.27.1"

then be sure you have .eslintrc.json file in the root of the project, next to package.json and tsconfig.json files

It work for me.

  • Related