DEV Community 👩‍💻👨‍💻

Masato Ohba
Masato Ohba

Posted on

Lint only over changed files

The bigger your project gets, the longer time lint takes.

So the following task is quite useful since we basically want to run lint only over changed files.

# package.json
{
  "scripts": {
    "tslint": "git diff --name-only develop... | grep -E '\\.tsx?$' | xargs yarn tslint"
  }
}
Enter fullscreen mode Exit fullscreen mode

I'm referring tslint here, but the same is true of eslint, stylelint, and etc.

Top comments (3)

Collapse
 
gijovarghese profile image
Gijo Varghese

I use lint-staged. Works pretty well. I've also written an in-depth guide on NodeJS – Auto Lint & Format on Git Commit with Airbnb Styleguide

Collapse
 
earonesty profile image
earonesty

This works for any language and vcs (git, hg, etc).
Useful for projects where there is more than one language used.
Default config works with node, ruby, python, bash.
github.com/AtakamaLLC/lint-diffs

Collapse
 
elpdpt profile image
elpdpt

thank you

Visualizing Promises and Async/Await 🤯

async await

☝️ Check out this all-time classic DEV post