How to update the configuration for eslint after upgrade angular 9 to 10
Asked Answered
S

3

17

After upgrading angular from 9 to 10 and run npm run lint, I got this experiment > ng lint --fix

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(tsConfig).

My angular.json is:

    ..."lint": {
      "builder": "@angular-eslint/builder:lint",
      "options": {
        "eslintConfig": ".eslintrc.js",
        "tsConfig": [
          "tsconfig.app.json",
          "tsconfig.spec.json",
          "e2e/tsconfig.json"
        ],
        "exclude": ["**/node_modules/**"]
      }
    },...

Here is my package.json - devDependencies:

..."@angular-devkit/build-angular": "~0.1001.1",
"@angular-eslint/builder": "0.3.0-beta.1",
"@angular-eslint/eslint-plugin": "0.0.1-alpha.32",
"@angular-eslint/eslint-plugin-template": "0.0.1-alpha.32",
"@angular-eslint/template-parser": "0.0.1-alpha.32",
"@angular/cli": "~10.1.0",
"@angular/compiler-cli": "~10.1.1",
"@angular/language-service": "~10.1.1",
"@types/file-saver": "^2.0.1",
"@types/google-libphonenumber": "^7.4.19",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@typescript-eslint/eslint-plugin": "2.31.0",
"@typescript-eslint/parser": "2.31.0",
"codelyzer": "^5.2.2",
"eslint": "^7.6.0",
"eslint-config-airbnb-typescript": "^8.0.2",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
"eslint-plugin-prettier": "^3.1.4",...

when I replace 'tsConfig' with 'lintFilePatterns', the cli says:

error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: tsconfig.app.json.
The extension for the file (.json) is non-standard. You should add "parserOptions.extraFileExtensions" to your config

What should I update?

Squarerigger answered 11/9, 2020 at 8:49 Comment(8)
Could you provide the whole of your angular.json and your package.json? Might be a version mismatch.Trackandfield
Yes, I've updated it. :DSquarerigger
Try upgrading your @angular-devkit/build-angular to 0.13.0Trackandfield
Sadly, it doesn't work. :(Squarerigger
Could you provide the whole angular.json?Trackandfield
Cannot, but the angular version I'm using is "^10.1.1" and typescript version "~4.0.2"Squarerigger
If existing, try removing the "es5BrowserSupport": true from your angular.jsonTrackandfield
No, I don't set it upSquarerigger
I
15

I have the same issue with Angular 8. The issue is that the builder in angular-eslint does not support the tsConfig option: https://github.com/angular-eslint/angular-eslint/blob/master/packages/builder/src/schema.d.ts

My solution was to remove tsConfig just for linting and copy the "include" files up to "lintFilePatterns". I created .eslintignore at my project root where I list any "exclude" files I had (namely node_modules).

My angular.json:

  ..."lint": {
      "builder": "@angular-eslint/builder:lint",
      "options": {
        "eslintConfig": ".eslintrc.js",
        "lintFilePatterns": [
          "**/*.spec.ts",
          "**/*.d.ts"
        ]
      }
    },...

and then .eslintignore

node_modules/*

That got ng lint working for me

Ieper answered 13/11, 2020 at 15:6 Comment(0)
A
10

you should launch following command:

ng g @angular-eslint/schematics:convert-tslint-to-eslint {{YOUR_PROJECT_NAME_GOES_HERE}}

it will do many things but here where is lying your error: enter image description here

doc: https://github.com/angular-eslint/angular-eslint

Arabelle answered 24/11, 2020 at 14:58 Comment(0)
S
0

Stick with the document https://github.com/angular-eslint/angular-eslint, the problem comes from the version of angular.

Currently, the angular-eslint supports the old typescript (<=3.10), so we need to use the angular version <10.0.6 (the 10.1.x is using the typescript 4.0).

I think I need to wait for the compatibility, will update when I can resolve this conflict. If you're getting the same issue as I have, you can try to downgrade the angular to v10.0.6, if you can resolve it, I'm so happy if you can put the solution here. :D

Squarerigger answered 15/9, 2020 at 10:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.