Skip to content

Instantly share code, notes, and snippets.

@oroce
Created April 25, 2014 08:42
Show Gist options
  • Save oroce/11282380 to your computer and use it in GitHub Desktop.
Save oroce/11282380 to your computer and use it in GitHub Desktop.
run eslint only on changed (*.js files) files using pre-commit
{
"scripts": {
"eslint": "LIST=`git diff-index --name-only HEAD | grep .*\\.js | grep -v json`; if [ \"$LIST\" ]; then eslint $LIST; fi"
},
"devDependencies": {
"pre-commit": "0.0.7",
"eslint": "~0.5.1"
},
"pre-commit": [
"eslint"
]
}
@Bananen1234
Copy link

Problem here with using eslint --fix, is that the script is passing successfully, but the fixed file is now unstaged, and git is commiting the erronous change still unfixed. Can I reuse the list of staged files and git add them??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment