angular-eslint icon indicating copy to clipboard operation
angular-eslint copied to clipboard

Can't update to v18.1.0. `@angular-eslint/schematics` not being detected?

Open nunoarruda opened this issue 1 year ago • 5 comments

ng update is not detecting that there's a new angular-eslint version:

npx ng update

Using package manager: npm
Collecting installed dependencies...
Found 34 dependencies.
    We analyzed your package.json and everything seems to be in order. Good work!

If I try to update @angular-eslint/schematics directly, it also fails to detect it:

npx ng update @angular-eslint/schematics

Using package manager: npm
Collecting installed dependencies...
Found 34 dependencies.
Package '@angular-eslint/schematics' is not a dependency.

I see reference(s) of @angular-eslint/schematics on angular.json and on package-lock.json but not in package.json. Could this be related? Or, am I missing something?

Here's my ng version:

npx ng version

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


Angular CLI: 18.0.6
Node: 20.15.0
Package Manager: npm 10.7.0
OS: darwin arm64

Angular: 18.0.5
... animations, cdk, common, compiler, compiler-cli, core, forms
... material, platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1800.6
@angular-devkit/build-angular   18.0.6
@angular-devkit/core            18.0.6
@angular-devkit/schematics      18.0.6
@angular/cli                    18.0.6
@schematics/angular             18.0.6
rxjs                            7.8.1
typescript                      5.4.5
zone.js                         0.14.6

nunoarruda avatar Jul 02 '24 09:07 nunoarruda

@JamesHenry could you take a look at this when you have a chance? It is still an issue with v18.2.0.

Thanks in advance 👍

nunoarruda avatar Aug 07 '24 12:08 nunoarruda

Yes @angular-eslint/schematics should be in your package.json, please add it and align it with other @angular-eslint packages in terms of version number

JamesHenry avatar Aug 13 '24 18:08 JamesHenry

from what i understand, this line https://github.com/angular-eslint/angular-eslint/blob/fc31fef214a1ef3151ff541a451597ccd2176a67/packages/schematics/src/ng-add/index.ts#L100 removes it from the package.json as soon as you run any update (using flat config), or am i miss-reading it?

robertado avatar Aug 14 '24 08:08 robertado

@robertado Apologies, you are right, and as you can see in this file, this behaviour is new and specific to flat config.

The reason for this is historically all the @angular-eslint packages would be in your package.json directly, now I was trying to get it such that only angular-eslint (the new package) would be needed and it depends on the others.

I have reopened because effectively you are reporting to me that this strategy is not workable with the Angular CLI, it apparently needs that package to be a direct dev dependency of the repo in question?

I will need to test this out locally and see if it is consistent, and if so see if there is a workaround available, such as maybe exposing the schematics of @angular-eslint/schematics via the angular-eslint package (so you would run ng update angular-eslint instead.

JamesHenry avatar Aug 14 '24 09:08 JamesHenry

@JamesHenry until now i updated the packages angular-eslint and typescript-eslint directly or via ng update angular-eslint. maybe a note in the readme is sufficient 😄

robertado avatar Aug 14 '24 10:08 robertado

Same problem with @angular-eslint/builder in angular.json. Need to add it as a direct dependency or get an error when running 'ng lint'

jefbarn avatar Nov 05 '24 23:11 jefbarn

@jefbarn That is not the same thing, we have e2e tests that cover this and ng lint works just fine. Please provide much more information about your setup

JamesHenry avatar Nov 23 '24 09:11 JamesHenry

@JamesHenry

@jefbarn That is not the same thing, we have e2e tests that cover this and ng lint works just fine. Please provide much more information about your setup

Looks like it's related to pnpm usage vs npm. Pnpm has stricter usage of transitive dependencies and the ng cli tool is trying to go directly into the node_modules directory to find it (it doesn't live there with pnpm unless you add it as a project dependency).

jefbarn avatar Nov 23 '24 18:11 jefbarn

@jefbarn Please provide a reproduction in a fresh issue, I just did:

pnpm dlx @angular/cli new --package-manager pnpm
cd the-workspace-name
pnpm ng add angular-eslint
pnpm ng lint

And everything worked fine

image

JamesHenry avatar Nov 30 '24 09:11 JamesHenry