Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 824
Einsamer Avatar asked Sep 11 '20 08:09

Einsamer


2 Answers

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

like image 194
jstokes Avatar answered Sep 19 '22 13:09

jstokes


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

like image 24
Danny Avatar answered Sep 18 '22 13:09

Danny