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.

@nrwl/linter: add support/option to builder to run lint only on touched files in affected tree

See original GitHub issue

Description + 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 to severity: error, and owner of libB changes api to return any ( 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:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Hotellcommented, Oct 1, 2020

@cafesanu I’ll soon release lint builder with this functionality 😃

2reactions
Hotellcommented, Oct 2, 2020

Nice! is this part of the new eslint builder in 10.3.0?

Nope, my implementation covering this proposal - we use it at work already 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

eslint: howto lint only touched files - javascript - Stack Overflow
I accomplished it by using a watcher; this is the solution in the details: dependencies for the Webpack configuration:
Read more >
Running ESLint only on staged files - CircleCI Discuss
Hi, is there any way I can run eslint only the files that appear in my PR? At present this is my job...
Read more >
[mozlint] Run linters on entire tree when configuration files ...
This is especially pertinent to vcs commands like --outgoing and --workdir. If a config file is modified, then we should lint the entire...
Read more >
2021年05月_weixin_39942191的博客_CSDN博客
install.package(miscTools)library(miscTools)#insertRow Insert Row into a MatrixDescriptionInsert a new row into a matrix.UsageinsertRow( m, r, v = NA, ...
Read more >
Using ESLint in Nx Workspaces
Rules requiring type information. ESLint is powerful linter by itself, able to work on the syntax of your source files and assert things...
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