observing/pre-commit

Only check staged files

Opened this issue · 9 comments

Only check staged files when trying to commit

Not sure if this should be in scope of this library but I've created https://github.com/okonet/lint-staged for this. Check it out and let me know what you think.

Great, this is exactly what I was looking for; I didn't realize you had another repo for this. Thanks for your quick and diligent response on this!

Just FYI I'm not the maintainer nor developer of this package... just stumbled upon this issue.

Thank you I overlooked your username originally.

I'm going to re-open and wait and see what the owner has to say.

rehia commented

I agree that this should not be part of this library, at least as far as I understand it.
But I would definitely get a property called onFailure (or something close) or preferably finally, so we can give a npm script name which would be run respectively when an error occurs or always, at the end of the pre-commit.
This would help us start with a script which stash everything but staged files, and unstash those files once scripts have run, whatever the result.

Actually that would be awesome! Stashing and unstashing is something I'd like to integrate into 🚫💩 lint-staged but it's not trivial at the moment.

I'm not sure though it can be done as part of the pre-commmit hook.

I've created a script that does exactly this. It uses pre-commit to start a node script that programmatically goes over all the staged files.

https://gist.github.com/bertyhell/c8ae817626e053375bad0d62efc1da7d

Improvements are welcome.