question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adding linter to multi-project workspace results in incomplete/broken configuration

See original GitHub issue

🐞 Bug report

Description

When adding @angular-eslint/schematics to a workspace that was initially created with --create-application=false, the .eslintrc.json files are not added to the workspace root, or to the project directories (if projects exist) and the architect/lint sections are not added to project definitions in angular.json regardless of whether the projects are created before or after adding @angular-eslint/schematics.

Minimal Reproduction

ng new workspace --create-application=false
cd workspace
ng add @angular-eslint/schematics
ng generate library lib1

Exception or Error

When attempting to run the linter, the following error is produced even after the above steps are performed


Cannot find "lint" target for the specified project.

You should add a package that implements linting capabilities.

For example:
  ng add @angular-eslint/schematics

Environment


Angular CLI: 12.1.4
Node: 14.16.0
Package Manager: npm 7.21.0
OS: win32 x64

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

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1201.4
@angular-devkit/build-angular   12.1.4
@angular-devkit/core            12.1.4
@angular-devkit/schematics      12.1.4
@angular/cli                    12.1.4
@schematics/angular             12.1.4
ng-packagr                      12.2.1
rxjs                            6.6.7
typescript                      4.3.5

Additional Information

It seems that adding the linter to a single-project workspace, which later includes additional projects, results in success and covers all projects as expected.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:7
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Francesco-Manicardicommented, Feb 10, 2022

Here’s the intended way to install eslint in a multi project workspace setup:

in root directory, run ng add @angular-eslint/schematics

For each child project, run: ng g @angular-eslint/schematics:add-eslint-to-project <your-project-name-goes-here>

3reactions
bogacgcommented, Aug 29, 2021

You need to execute once more ng add @angular-eslint/schematics for it to work its magic. First execution only adds packages, after you create your lib/app by executing that command for the second time it understands what it has to do.

However the situation is still not perfect. That second execution generates an eslintrc.json under lib/app with "extends": "../../.eslintrc.json", being its first option which is kind of faulty since ng add @angular-eslint/schematics did not generate that root file in neither execution so you get error. Removing that extends option makes things work as far as I can see.

It’s already reported #462

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add ESLint to Angular Workspace for multiple Projects #$D$_ ...
Step 1. Run the following commands first from your workspace directory ng add @angular-eslint/schematics. Step 2. ng ...
Read more >
Troubleshooting CI/CD - GitLab Docs
GitLab provides several tools to help make troubleshooting your pipelines easier. This guide also lists common issues and possible solutions.
Read more >
IDE Project Management and Building Guide - IAR Systems
Project management describes how you can create workspaces with multiple projects, build configurations, groups, source files, and options that help you ...
Read more >
Set up forms in Workspace
Select the fields that appear in form pane to help agents do their work.
Read more >
Should I commit the .vscode folder to source control?
A simple way to keep your settings without commit it in your project git repository is creating a workspace and add folder into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found