@nrwl/linter: add support/option to builder to run lint only on touched files in affected tree
See original GitHub issueDescription + Motivation
Currently when affected
is executed it runs all targets on whole affected tree, which makes 100% sense for:
- build
- test
- e2e
- type-check ( not part of standard targets but we’re using it at work to run tsc)
those afformentioned targets are real safe-guards in terms of not breaking API/application
Now for lint
on the other hand, we know it’s not necessary ( for our monorepo project 5k + modules ).
What we can say with confidence, is, that for our use case, it would make sense, to run linter only on touched files per project in particular affected tree, thus rapidly speeding up linting process on CI.
NOTE: you might be thinking, there is this
cache
option, provided by native eslint —> well in short, that doesn’t work properly, especially on CI
Edge cases:
let’s say we have this simple dep graph
// lib A uses lib B
[ lib A ] ---> [ lib B ]
- if one uses type aware lint rules from
@typescript-eslint/no-unsafe-
family and they are set toseverity: error
, and owner oflibB
changes api to returnany
( which is a type information breaking change, which could be possibly catched by TypeScript anyways ), then consumer of libB (libA
) would contain invalid code from linter perspective, thus introduce error to other developers after it was merged
Suggested Implementation
I’d add new option flag to current builder, to support this behaviour as an opt-in feature, which would not introduce breaking changes.
"lint": {
"builder": "@nrwl/linter:lint",
"options": {
"linter": "eslint",
"config": "path/to/lib/.eslintrc",
"tsConfig": [
"path/to/lib/tsconfig.lib.json",
"path/to/lib/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"],
+ "touchedOnly": true
}
}
with that touchedOnly
could just extract touched files internaly and provide those to already supported --files
flag
Alternate Implementations
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:9 (3 by maintainers)
@cafesanu I’ll soon release lint builder with this functionality 😃
Nope, my implementation covering this proposal - we use it at work already 😃