Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds lint and test pre-commit hooks #2077

Merged
merged 3 commits into from
Oct 27, 2017

Conversation

oneill-c
Copy link

It occurred to me while reading the contribution guide that the project might benefit from automatic push hooks to lint and test.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.835% when pulling a481154 on mcpolandc:add-pre-push-hooks into a252668 on JedWatson:master.

@JedWatson
Copy link
Owner

@mcpolandc thanks! good idea.

Thoughts on using husky and lint-staged with a pre-commit hook though? (instead of pre-push, errors would be caught before commit)

@oneill-c
Copy link
Author

Hi @JedWatson! Yeah, running the linter on only the staged files when committing makes a lot of sense. I will make changes to this effect 😄

Just extending on this... I wonder if we should maybe add the test cover check at the commit stage as well. Maybe husky, lint-staged or some other package can provide this functionality (exit with 1 if test coverage has dropped, thus failing commit). What are your thoughts on this?

@oneill-c oneill-c changed the title Adds lint and test pre-push hooks Adds lint and test pre-commit hooks Oct 25, 2017
@oneill-c
Copy link
Author

Changed this to run lint (only staged js files) and test scripts on commit rather than push.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.868% when pulling 207ca7c on mcpolandc:add-pre-push-hooks into ca09183 on JedWatson:master.

package.json Outdated
]
],
"lint-staged": {
"*.js": ["eslint", "git add"]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of git add here? unless eslint is being run with the --fix flag (which it's not and I'm happy to leave it that way) this wouldn't be necessary; and it has the side-effect of preventing you from committing only staged chunks of a file without making it an obvious thing...

Surely just eslint on its own would be sufficient (and safer!) here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I knew that I didn't want to have it fix linter errors automatically but I didn't really understand what git add was doing. Reading further down the readme of lint-staged helped with that 😛. I totally agree with what you're saying here so making the change.

@JedWatson
Copy link
Owner

Thanks @mcpolandc! Left a note there for feedback but otherwise this looks great!

@JedWatson JedWatson self-assigned this Oct 26, 2017
@coveralls
Copy link

Coverage Status

Coverage remained the same at 92.9% when pulling cdedc32 on mcpolandc:add-pre-push-hooks into f057218 on JedWatson:master.

@JedWatson
Copy link
Owner

Great, thanks!

@JedWatson JedWatson merged commit 9c42cc5 into JedWatson:master Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants