Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[@angular-eslint/schematics][angular-eslint] ng add not able to select correct version for Angular version != 19 #2180

Open
@cgrabmann

Description

@cgrabmann

Description and reproduction of the issue

When using ng add angular-eslint or ng add @angular-eslint/schematics with Angular versions other then the latest 19, then Angular cli is unable to determine the correct compatible package to use.

To test it just create a new project with Angular 17 or 18

npx --package @angular/cli@18 ng new foo-spa
? Which stylesheet format would you like to use? Sass (SCSS)     [ https://sass-lang.com/documentation/syntax#scss                ]
? Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? no
CREATE foo-spa/angular.json (2870 bytes)
CREATE foo-spa/package.json (1079 bytes)
CREATE foo-spa/README.md (1095 bytes)
CREATE foo-spa/tsconfig.json (1045 bytes)
CREATE foo-spa/.editorconfig (331 bytes)
CREATE foo-spa/.gitignore (629 bytes)
CREATE foo-spa/tsconfig.app.json (439 bytes)
CREATE foo-spa/tsconfig.spec.json (449 bytes)
CREATE foo-spa/.vscode/extensions.json (134 bytes)
CREATE foo-spa/.vscode/launch.json (490 bytes)
CREATE foo-spa/.vscode/tasks.json (980 bytes)
CREATE foo-spa/src/main.ts (256 bytes)
CREATE foo-spa/src/index.html (305 bytes)
CREATE foo-spa/src/styles.scss (81 bytes)
CREATE foo-spa/src/app/app.component.html (20239 bytes)
CREATE foo-spa/src/app/app.component.spec.ts (948 bytes)
CREATE foo-spa/src/app/app.component.ts (317 bytes)
CREATE foo-spa/src/app/app.component.scss (0 bytes)
CREATE foo-spa/src/app/app.config.ts (318 bytes)
CREATE foo-spa/src/app/app.routes.ts (80 bytes)
CREATE foo-spa/public/favicon.ico (15086 bytes)
✔ Packages installed successfully.
    Successfully initialized git.

and run the following command.

ng add angular-eslint

✔ Determining Package Manager
  › Using package manager: npm
✔ Searching for compatible package version
  › Found compatible package version: [email protected].
✔ Loading package information from registry
✖ Command aborted

as can be seen the cli finds the compatible package version to be [email protected].

For Angular 17 and the @angular-eslint/schematics package the same can be witnessed.

The Problem is that the Angular-CLI checks the peerDependencies of the package to be installed to find a compatible package version: https://github.com/angular/angular-cli/blob/main/packages/angular/cli/src/commands/add/cli.ts#L195

For the angular-eslint package this peerDependency information was always missing since the functionality was introduced with this PR: #2134
For the @angular-eslint/schematics package this peerDependency information was incorrectly removed with the following PR: #2143
This causes the resolution to no longer work correctly since the release of https://github.com/angular-eslint/angular-eslint/releases/tag/v18.4.3

Versions

# Please run `npx ng version` in your project and paste the full output here:
ng version


     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 18.2.12
Node: 18.20.5
Package Manager: npm 10.8.2
OS: win32 x64

Angular: 18.2.13
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1802.12
@angular-devkit/build-angular   18.2.12
@angular-devkit/core            18.2.12
@angular-devkit/schematics      18.2.12
@angular/cli                    18.2.12
@schematics/angular             18.2.12
rxjs                            7.8.1
typescript                      5.5.4
zone.js                         0.14.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions