Skip to content

Automatic ng add of @angular-eslint/schematics still throws the first time based on missing lint target #22937

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

Closed
1 of 15 tasks
JamesHenry opened this issue Apr 3, 2022 · 2 comments · Fixed by #22938
Closed
1 of 15 tasks
Labels
area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@JamesHenry
Copy link
Contributor

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Unknown

Description

When following the libraries tutorial, running ng lint will throw the first time you run it, but pass the second time.

🔬 Minimal Reproduction

Follow the steps outlined here taken from the creating libraries tutorial on angular.io:
angular-eslint/angular-eslint#917

🔥 Exception or Error




An unhandled exception occurred: Project target does not exist.
See "/private/var/folders/zs/vbyzg7s52n9flpbjxjc_xplc0000gn/T/ng-XzDOA6/angular-errors.log" for further details.

[error] Error: Project target does not exist.
    at findProjectTarget (/Users/james/Repos/tmp/new-workspace/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:53:15)
    at Object.getBuilderName (/Users/james/Repos/tmp/new-workspace/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:66:46)
    at WorkspaceNodeModulesArchitectHost.getBuilderNameForTarget (/Users/james/Repos/tmp/new-workspace/node_modules/@angular-devkit/architect/node/node-modules-architect-host.js:105:35)
    at LintCommand.runSingleTarget (/Users/james/Repos/tmp/new-workspace/node_modules/@angular/cli/models/architect-command.js:246:55)
    at LintCommand.runArchitectTarget (/Users/james/Repos/tmp/new-workspace/node_modules/@angular/cli/models/architect-command.js:299:35)
    at LintCommand.run (/Users/james/Repos/tmp/new-workspace/node_modules/@angular/cli/models/architect-command.js:240:27)
    at LintCommand.validateAndRun (/Users/james/Repos/tmp/new-workspace/node_modules/@angular/cli/models/command.js:136:33)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runCommand (/Users/james/Repos/tmp/new-workspace/node_modules/@angular/cli/models/command-runner.js:228:24)
    at async default_1 (/Users/james/Repos/tmp/new-workspace/node_modules/@angular/cli/lib/cli/index.js:70:31)

🌍 Your Environment



Angular CLI: 13.3.1
Node: 16.13.2
Package Manager: npm 8.3.0
OS: darwin arm64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1303.1
@angular-devkit/build-angular   13.3.1
@angular-devkit/core            13.3.1
@angular-devkit/schematics      13.3.1
@schematics/angular             13.3.1
ng-packagr                      13.3.0
rxjs                            7.5.5
typescript                      4.6.3

Anything else relevant?

Full output from ng lint my-lib onwards, showing the error and subsequent successful run:

~/Repos/tmp/new-workspace   ⬢  16.13.2                                                                                                                                                                                            main
❯ ng lint my-lib                                                                                                                                                                                                                    

Cannot find "lint" target for the specified project.

You should add a package that implements linting capabilities.

For example:
  ng add @angular-eslint/schematics

Would you like to add ESLint now? Yes
ℹ Using package manager: npm
✔ Found compatible package version: @angular-eslint/[email protected].
✔ Package information loaded.

The package @angular-eslint/[email protected] will be installed and executed.
Would you like to proceed? Yes
✔ Package successfully installed.

    All @angular-eslint dependencies have been successfully installed 🎉

    Please see https://github.com/angular-eslint/angular-eslint for how to add ESLint configuration to your project.

    We detected that you have a single project in your workspace and no existing linter wired up, so we are configuring ESLint for you automatically.

    Please see https://github.com/angular-eslint/angular-eslint for more information.

CREATE .eslintrc.json (984 bytes)
CREATE projects/my-lib/.eslintrc.json (842 bytes)
UPDATE package.json (1482 bytes)
UPDATE angular.json (1457 bytes)
✔ Packages installed successfully.
An unhandled exception occurred: Project target does not exist.
See "/private/var/folders/zs/vbyzg7s52n9flpbjxjc_xplc0000gn/T/ng-XzDOA6/angular-errors.log" for further details.


~/Repos/tmp/new-workspace   ⬢  16.13.2                                                                                                                                                                                            main
❯ ng lint my-lib                                                                                                                                                                                                              

Linting "my-lib"...

/Users/james/Repos/tmp/new-workspace/projects/my-lib/src/lib/my-lib.component.ts
  17:3  error  Lifecycle methods should not be empty  @angular-eslint/no-empty-lifecycle-method

✖ 1 problem (1 error, 0 warnings)

Lint errors found in the listed files.
clydin added a commit to clydin/angular-cli that referenced this issue Apr 4, 2022
When no lint target is present for a project, the command will ask if linting should be added to the project.
However, after adding the package, the command incorrectly kept executing and then failing due to the lint command not being fully setup yet.
Instead, the command will now exit after adding the linting package. This also allows inspection and/or adjustment of the linting configuration prior to actually linting.

Fixes: angular#22937
@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: @angular/cli labels Apr 4, 2022
@ngbot ngbot bot added this to the Backlog milestone Apr 4, 2022
clydin added a commit that referenced this issue Apr 4, 2022
When no lint target is present for a project, the command will ask if linting should be added to the project.
However, after adding the package, the command incorrectly kept executing and then failing due to the lint command not being fully setup yet.
Instead, the command will now exit after adding the linting package. This also allows inspection and/or adjustment of the linting configuration prior to actually linting.

Fixes: #22937
@alan-agius4
Copy link
Collaborator

Closed via #22938

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants