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
- Windows 10
- @angular/cli 12.1.4
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:
- Created 2 years ago
- Reactions:7
- Comments:5 (1 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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>
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 sinceng add @angular-eslint/schematics
did not generate that root file in neither execution so you get error. Removing thatextends
option makes things work as far as I can see.It’s already reported #462