Nx: `nx lint && ng lint` reports one file in multiple libs

Created on 22 Oct 2018  路  7Comments  路  Source: nrwl/nx

After executing npm run lint I get this output:

PS C:\_\TechniServ\esel\esel.clients> npm run lint

> [email protected] lint C:\_\TechniServ\esel\esel.clients
> nx lint && ng lint

Linting "el-portal"...

ERROR: C:/_/TechniServ/esel/esel.clients/libs/common/core/src/lib/http/http-cache.service.ts[97, 12]: Type annotation in JSDoc is redundant in TypeScript code.

Lint errors found in the listed files.
Linting "el-admin"...


All files pass linting.
Linting "common-auth"...


All files pass linting.
Linting "common-core"...

ERROR: C:/_/TechniServ/esel/esel.clients/libs/common/core/src/lib/http/http-cache.service.ts[97, 12]: Type annotation in JSDoc is redundant in TypeScript code.

Lint errors found in the listed files.
Linting "common-logger"...


All files pass linting.
Linting "common-router"...


All files pass linting.
Linting "el-login"...


All files pass linting.
Linting "el-home"...

ERROR: C:/_/TechniServ/esel/esel.clients/libs/common/core/src/lib/http/http-cache.service.ts[97, 12]: Type annotation in JSDoc is redundant in TypeScript code.

One lint issues is reported multiple times, why is that? Thank you.

retry with latest misc bug

Most helpful comment

I observed similiar problem in my project. Looks like the same files gets checked multiple times during linting.
Suppose that we have following simple project structure: AppFoo --- LibBar. Now when we do ng lint or affected:lint --all, the files from the LibBar are checked twice -> once by linting the LibBar library itself, and for the second time by linting of AppFoo because it imports the LibBar.
This is sub-optimal and can create significant overhead in big multi apps/multi lib projects.

All 7 comments

I observed similiar problem in my project. Looks like the same files gets checked multiple times during linting.
Suppose that we have following simple project structure: AppFoo --- LibBar. Now when we do ng lint or affected:lint --all, the files from the LibBar are checked twice -> once by linting the LibBar library itself, and for the second time by linting of AppFoo because it imports the LibBar.
This is sub-optimal and can create significant overhead in big multi apps/multi lib projects.

Got same problem. One file get linted 6 times in my case and that is really slowing down CI

Found a solution to this for angular projects. In angular.json, for every lib/project in lint options, you need to add "files" property including only the files of that library/project - then it never goes outside of lib/project boundary. Example config of lib in angular.json:

 "some-lib": {
      "root": "libs/some-lib",
      "sourceRoot": "libs/some-lib/src",
      "projectType": "library",
      "prefix": "some",
      "architect": {
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "files": ["libs/some-lib/src/**/*.ts"],
            "tsConfig": ["libs/some-lib/tsconfig.lib.json", "libs/some-lib/tsconfig.spec.json"],
            "exclude": ["**/node_modules/**"]
          }
        },

so the crucial line above, which does the fix, is this one: "files": ["libs/some-lib/src/**/*.ts"],

This has been fixed. We now correctly set up excludes not to relint the same file multiple times.

Could you update your repo to latest to see if the issue persists?

@vsavkin tried with 8.9.0 - the problem is still there.

@krawetko Every project is generated with exclusions of outside files:

https://github.com/nrwl/nx-examples/blob/master/angular.json#L96

Can you confirm you have this configuration? If so, can you please provide a repro (public repo) to help us investigate the issue?

Closing this issue as I haven't received a response for 3 months. If you continue to experience this issue, please open a new issue with a repo exhibiting the issue so we can easily debug.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MichaelWarneke picture MichaelWarneke  路  3Comments

Koslun picture Koslun  路  3Comments

SWGeekPD picture SWGeekPD  路  3Comments

markphip picture markphip  路  3Comments

IonFoXx picture IonFoXx  路  3Comments