Last active
July 11, 2016 10:30
-
-
Save Alex1990/6cf23afd253b146a62862c58b9dd9792 to your computer and use it in GitHub Desktop.
Run eslint before `git commit` with npm scripts and `pre-commit` package.
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": { | |
"lint-legacy": "files=$(git diff --cached --name-only | grep -v '.jsx$' | grep '.js$' | tr '\\n' ' '); if [[ -n \"$files\" ]]; then eslint --config ./.eslintrc.legacy.json --quiet $files || (git reset HEAD; exit 1); else exit 0; fi", | |
"lint-base": "files=$(git diff --cached --name-only | grep '.jsx$' | tr '\\n' ' '); if [[ -n \"$files\" ]]; then eslint --config ./.eslintrc.base.json --quiet $files || (git reset HEAD; exit 1); else exit 0; fi", | |
"lint": "npm run lint-legacy && npm run lint-base", | |
"lint-all": "(eslint --config ./.eslintrc.base.json --ext .jsx --quiet ./) && (eslint --config ./.eslintrc.legacy.json --ext .js --quiet ./)", | |
"build": "gulp build" | |
}, | |
"pre-commit": [ | |
"lint" | |
], | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment