Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 10 solution style tsconfig.json incompatibility #110

Closed
AlbertBrand opened this issue Jul 17, 2020 · 2 comments
Closed

Angular 10 solution style tsconfig.json incompatibility #110

AlbertBrand opened this issue Jul 17, 2020 · 2 comments

Comments

@AlbertBrand
Copy link

Steps to reproduce:

  1. Clean install of Angular 10 project: ng new ng-eslint-test-project
  2. Add angular-eslint: ng add @angular-eslint/schematics
  3. Add .eslintrc.js file:
module.exports = {
  extends: ['plugin:@angular-eslint/recommended'],
};
  1. Update angular.json:
        "lint": {
          "builder": "@angular-eslint/builder:lint",
          "options": {
            "eslintConfig": ".eslintrc.js",
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": ["**/node_modules/**"]
          }
        },

Now running ng lint produces an error for each .ts file:

ng-eslint-test-project/src/app/app.component.ts
  0:0  error  Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser.
The file does not match your project config: src/app/app.component.ts.
The file must be included in at least one of the projects provided

✖ 1 problem (1 error, 0 warnings)

Version info

ng --version gives:

Angular CLI: 10.0.3
Node: 13.13.0
OS: darwin x64

Angular: 10.0.4
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.1000.3
@angular-devkit/build-angular     0.1000.3
@angular-devkit/build-optimizer   0.1000.3
@angular-devkit/build-webpack     0.1000.3
@angular-devkit/core              10.0.3
@angular-devkit/schematics        10.0.3
@angular/cli                      10.0.3
@ngtools/webpack                  10.0.3
@schematics/angular               10.0.3
@schematics/update                0.1000.3
rxjs                              6.5.5
typescript                        3.9.7
webpack                           4.43.0

Workaround:

If you search for "Parsing error: "parserOptions.project" has been set for @typescript-eslint/parser." you end up in the documentation. The recommendation there is to create a separate tsconfig.eslint.json.

Create one in the root:

{
  "extends": "./tsconfig.base.json",
  "include": ["src/**/*.ts", "e2e/**/*.ts"]
}

Override parsing of *.ts files with this file by editing .eslintrc.js:

module.exports = {
  extends: ['plugin:@angular-eslint/recommended'],
  overrides: [
    {
      files: ['*.ts'],
      parser: '@typescript-eslint/parser',
      parserOptions: {
        project: ['tsconfig.eslint.json'],
        ecmaVersion: 2020,
        sourceType: 'module',
      },
    },
  ]
};
@JamesHenry
Copy link
Member

Thank you for submitting the issue, please see #86 (comment) for a brief personal update. I will endeavour to review this in the near future, if one of my co-contributors does not get to it first.

@JamesHenry
Copy link
Member

Thanks again for the report @AlbertBrand!

Please could you try out the latest version I just published v0.1.0-beta.1, this issue should no longer be present and it explicitly supports Angular 10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants