:nail_care: Run eslint only in the changed parts of the code
Last updated 2 years ago by grvcoelho .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @grvcoelho/lint-diff 
SYNC missed versions from official npm registry.


Build Status

:nail_care: Run eslint only in the changed parts of the code


ESLint is a great tool to enforce code style in your code, but it has some limitations: it can only lint entire files. When working with legacy code, we often have to make changes to very large files (which would be too troublesome to fix all lint errors)and thus it would be good to lint only the lines changed and not the entire file.

lint-diff receives a commit range and uses ESLint to lint the changed files and filter only the errors introduced in the commit range (and nothing more).

State of the art

  • lint-staged is a similar tool that lints only the staged changes. It's very helpful for adding a precommit hook, but it cannot be used to enforce the styleguide on a Continuous Integration service like Travis, because the changes are already commited.


  1. Install it:
npm install @grvcoelho/lint-diff
  1. Install eslint and add your eslint configuration file.

  2. Use it:

# This will lint the last commit
lint-diff lint HEAD^..HEAD


  1. Lint the last 3 commits:
lint-diff lint HEAD~3..HEAD
  1. Lint local changes that are not yet commited (similar to what lint-staged do):
lint-diff lint HEAD
  1. Lint all commits from a build in Travis:
# This environment variable will be available in any Travis build
lint-diff lint $TRAVIS_COMMIT_RANGE

Current Tags

  • 0.5.4                                ...           latest (2 years ago)

3 Versions

  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
Maintainers (1)
Today 0
This Week 3
This Month 4
Last Day 3
Last Week 1
Last Month 0
Dependencies (4)
Dependents (0)

Copyright 2014 - 2016 © taobao.org |