Created
August 31, 2015 19:35
-
-
Save kadamwhite/1bfb6c4ea502400f1557 to your computer and use it in GitHub Desktop.
Use `git diff` and `grep` to selectively lint changed files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"jscs:branch": "jscs $(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base head master) | grep '.js$') || true", | |
"jshint:branch": "jshint $(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base head master) | grep '.js$') || true", | |
"jscs:diff": "jscs $(git diff --name-only --diff-filter=ACMRTUXB | grep '.js$') || true", | |
"jshint:diff": "jshint $(git diff --name-only --diff-filter=ACMRTUXB | grep '.js$') || true", | |
"jscs:prev": "jscs $(git diff head~1 --name-only --diff-filter=ACMRTUXB | grep '.js$') || true", | |
"jshint:prev": "jshint $(git diff head~1 --name-only --diff-filter=ACMRTUXB | grep '.js$') || true" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Amazing, this was super helpful when trying to lint my contributions to a huge project that sorely needs a lint standard. One thing I might add is the git HEAD ref is usually (always?) case sensitive: if you're getting
fatal: Not a valid object name head
that's probably the reason.After that, this approach works great with python's
pep8/pycodestyle
andautopep8
.Thanks for sharing this!