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 library generator generates wrong eslint config #20939

Closed
1 of 4 tasks
mattlewis92 opened this issue Dec 28, 2023 · 4 comments
Closed
1 of 4 tasks

angular library generator generates wrong eslint config #20939

mattlewis92 opened this issue Dec 28, 2023 · 4 comments
Assignees
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: angular Issues related to Angular support in Nx scope: linter Issues related to Eslint support in Nx type: bug

Comments

@mattlewis92
Copy link
Contributor

mattlewis92 commented Dec 28, 2023

Current Behavior

Using the @nx/angular:library generator creates an .eslintrc.json that looks like this (note we have not yet migrated our repo to flat eslint config, .eslintrc.js is still using the legacy format):

{
  "extends": ["../../.eslintrc.js"],
  "ignorePatterns": ["!**/*"],
  "overrides": [
    {
      "files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
      "rules": {}
    },
    {
      "files": ["*.ts", "*.tsx"],
      "rules": {}
    },
    {
      "files": ["*.js", "*.jsx"],
      "rules": {}
    },
    {
      "files": ["*.json"],
      "parser": "jsonc-eslint-parser",
      "rules": {
        "@nx/dependency-checks": "error"
      }
    }
  ]
}

Expected Behavior

The eslint config that gets generated looks more like this:

{
  "extends": ["../../.eslintrc.js"],
  "ignorePatterns": ["!**/*"],
  "overrides": [
    {
      "files": ["*.ts"],
      "extends": [
        "plugin:@nx/angular",
        "plugin:@angular-eslint/template/process-inline-templates"
      ],
      "rules": {
        "@angular-eslint/directive-selector": [
          "error",
          {
            "type": "attribute",
            "prefix": "cu",
            "style": "camelCase"
          }
        ],
        "@angular-eslint/component-selector": [
          "error",
          {
            "type": "element",
            "prefix": "cu",
            "style": "kebab-case"
          }
        ]
      }
    },
    {
      "files": ["*.html"],
      "extends": ["plugin:@nx/angular-template"],
      "rules": {}
    }
  ]
}

GitHub Repo

https://github.com/mattlewis92/nx-eslint-repro

Steps to Reproduce

  1. Change repo root eslint config format from .eslintrc.json to .eslintrc.js
  2. Run nx generate @nx/angular:library foo
  3. Verify that libs/foo/.eslintrc.json is wrong

Nx Report

>  NX   Report complete - copy this into the issue template

   Node   : 20.10.0
   OS     : darwin-arm64
   pnpm   : 8.12.1
   
   nx (global)        : 16.10.0
   nx                 : 17.2.7
   @nx/js             : 17.2.7
   @nx/jest           : 17.2.7
   @nx/eslint         : 17.2.7
   @nx/workspace      : 17.2.7
   @nx/angular        : 17.2.7
   @nx/cypress        : 17.2.7
   @nx/devkit         : 17.2.7
   @nx/eslint-plugin  : 17.2.7
   @nx/node           : 17.2.7
   @nx/plugin         : 17.2.7
   @nx/react          : 17.2.7
   @nx/rollup         : 17.2.7
   @nx/storybook      : 17.2.7
   @nrwl/tao          : 16.10.0
   @nx/web            : 17.2.7
   nx-cloud           : 16.5.2
   typescript         : 5.1.3
   ---------------------------------------
   Community plugins:
   @compodoc/compodoc                             : 1.1.18
   @fortawesome/angular-fontawesome               : 0.11.1
   @jscutlery/semver                              : 4.1.0
   @ngneat/spectator                              : 15.0.1
   @ngrx/effects                                  : 16.0.1
   @ngrx/entity                                   : 16.0.1
   @ngrx/eslint-plugin                            : 16.0.1
   @ngrx/router-store                             : 16.0.1
   @ngrx/schematics                               : 16.0.1
   @ngrx/store                                    : 16.0.1
   @ngrx/store-devtools                           : 16.0.1
   @rx-angular/cdk                                : 16.0.0
   @rx-angular/state                              : 16.0.0
   @rx-angular/template                           : 16.1.1
   @storybook/angular                             : 7.5.3
   @testing-library/angular                       : 13.4.0
   @time-loop/angular-platform-browser-perf-patch : 16.2.1
   @time-loop/ngx-bootstrap                       : 3.2.0
   angular-calendar                               : 0.30.1
   ng-mocks                                       : 14.11.0
   ngx-deploy-npm                                 : 7.1.0
   ---------------------------------------
   Local workspace plugins:
         @cu/nx-plugin-workspace-generators
         @cu/nx-plugin-esbuild
   ---------------------------------------
   The following packages should match the installed version of nx
     - @nrwl/[email protected]
   
   To fix this, run `nx migrate [email protected]`

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

If it is not possible to easily detect if the root eslint config is flat or not, a simple option we could pass to the library generator like is-using-flat-eslint-config=false would be great.

@AgentEnder AgentEnder added the scope: angular Issues related to Angular support in Nx label Jan 9, 2024
@FrozenPandaz FrozenPandaz added the scope: linter Issues related to Eslint support in Nx label May 13, 2024
@Coly010 Coly010 added the blocked: retry with latest Retry with latest release or head. label Aug 20, 2024
@Coly010
Copy link
Contributor

Coly010 commented Aug 20, 2024

@mattlewis92 I apologize that this has taken a while to get back to. Can you confirm if this is still an issue with the latest version of Nx?

@mattlewis92
Copy link
Contributor Author

@mattlewis92 I apologize that this has taken a while to get back to. Can you confirm if this is still an issue with the latest version of Nx?

Hey @Coly010, I just upgraded the repo to the latest nx and am still able to reproduce the issue

@Coly010
Copy link
Contributor

Coly010 commented Aug 20, 2024

@mattlewis92 I talked to the team about this and the support for flat config is still in progress.

I'm going to close this issue and refer you to this issue instead which is tracking the work: #27451

@Coly010 Coly010 closed this as completed Aug 20, 2024
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
blocked: retry with latest Retry with latest release or head. outdated scope: angular Issues related to Angular support in Nx scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

4 participants