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 ESLint recommended config does not include TypeScript recommended rules #1174

Closed
2 tasks done
belyan opened this issue Nov 3, 2022 · 5 comments
Closed
2 tasks done
Labels
package: eslint-plugin Angular-specific TypeScript rules triage This issue needs to be looked at and categorized by a maintainer

Comments

@belyan
Copy link

belyan commented Nov 3, 2022

Description and reproduction of the issue

I am using ESLint config file that recommended and created using Angular ESLint schematics command:
ng add @angular-eslint/schematics.

My eslintrc.json file looks like:

{
  "root": true,
  "ignorePatterns": ["projects/**/*"],
  "overrides": [
    {
      "files": ["*.ts"],
      "parserOptions": {
        "project": ["tsconfig.json"],
        "createDefaultProgram": true
      },
      "extends": ["plugin:@angular-eslint/recommended"]
    }
  ]
}

Because the package @angular-eslint/eslint-plugin depends on the package @typescript-eslint/eslint-plugin I expect that Angular ESLint plugin inherits all the recommended rules from TypeScript ESLint plugin.

I mean these rules:
https://github.com/typescript-eslint/typescript-eslint/blob/v5.41.0/packages/eslint-plugin/src/configs/recommended.ts

But in fact all the recommended TypeScript ESLint rules does not working.

Versions

package version
@angular-eslint/eslint-plugin 13.5.0
@typescript-eslint/parser 5.41.0
ESLint 7.32.0
node 16.14.2
# Please run `npx ng version` in your project and paste the full output here:

Angular CLI: 13.3.9
Node: 16.14.2
Package Manager: npm 8.19.2
OS: darwin x64

Angular: 13.3.11
... animations, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.9
@angular-devkit/build-angular   13.3.9
@angular-devkit/core            13.3.9
@angular-devkit/schematics      13.3.9
@angular/cli                    13.3.9
@schematics/angular             13.3.9
rxjs                            7.5.7
typescript                      4.6.4
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest supported version of the packages and checked my ng version output per the instructions given here.
@belyan belyan added package: eslint-plugin Angular-specific TypeScript rules triage This issue needs to be looked at and categorized by a maintainer labels Nov 3, 2022
@abaran30
Copy link
Contributor

Hey @belyan. Have you seen the Premade configs doc? The recommended section suggests configuring @typescript-eslint/eslint-plugin and @angular-eslint/eslint-plugin separately. @angular-eslint/recommended is configured to only configure rules defined by the plugin itself, and you can see that here.

If there is something in the docs that led you to believe that recommended also enforces the recommended config for @typescript-eslint/eslint-plugin, please share where.

@belyan
Copy link
Author

belyan commented Nov 11, 2022

In section Recommended of the docs, the plugin @typescript-eslint/eslint-plugin is mentioned several times. For example:

That being said, it is not the only way to use @typescript-eslint/eslint-plugin and @angular-eslint/eslint-plugin, nor is it the way that will necessarily work 100% for your project/company.

Docs also emphasize that Angular recommended rules are based on ES and TypeScript recommended rules.

The recommended config contains config for ESLint core rules, as well as two different plugins:
@typescript-eslint/eslint-plugin
@angular-eslint/eslint-plugin

But all examples of Angular recommended config doesn't include @typescript-eslint/eslint-plugin, that gives the complete impression that it is already included.

{
  "extends": ["plugin:@angular-eslint/recommended"],
  "rules": {}
}

Also pay attention, that TypeScript recommended config includes ES recommended rules:
https://github.com/typescript-eslint/typescript-eslint/blob/v5.41.0/packages/eslint-plugin/src/configs/recommended.ts#L6

But Angular recommended config breaks this chain of dependencies: ES --> TypeScript -X-> Angular, because it doesn't includes TypeScript recommended rules here:
https://github.com/angular-eslint/angular-eslint/blob/v13.5.0/packages/eslint-plugin/src/configs/recommended.json#L2

@belyan belyan changed the title Angular ESLint recommended rules does not include TypeScript ESLint recommended rules Angular recommended config does not include TypeScript recommended rules Nov 11, 2022
@belyan belyan changed the title Angular recommended config does not include TypeScript recommended rules Angular ESLint recommended config does not include TypeScript recommended rules Nov 11, 2022
@abaran30
Copy link
Contributor

The recommended config contains config for ESLint core rules, as well as two different plugins:
@typescript-eslint/eslint-plugin
@angular-eslint/eslint-plugin

I can see how this may give the impression that the angular-eslint recommended config extends the TypeScript recommended rules.

@JamesHenry is it intended for the angular-eslint recommended config to extend the TS recommended rules? If so, an update to the config will be required. Otherwise, perhaps an update to the docs to clarify how these configurations work.

@JamesHenry
Copy link
Member

As of v15, all new workspaces will extend from the eslint:recommended and plugin:@typescript-eslint:recommended configs

@belyan
Copy link
Author

belyan commented Nov 21, 2022

Good work. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: eslint-plugin Angular-specific TypeScript rules triage This issue needs to be looked at and categorized by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants