loading...

Lint only over changed files

ohbarye profile image Masato Ohba ・1 min read

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"
  }
}

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

Discussion

pic
Editor guide
 

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

 

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