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 an automatic prettier pre-commit runner #26

Closed

Conversation

GabeAtWork
Copy link
Contributor

See #25

Automatically runs the format and linting before git commits. If the linting fails with errors, the commit is prevented (but can be circumvented with the --no-verify option).

I took the liberty to add the trailingComma prettier rule: it ensures trailing commas are put at the end of every line of array, object and even function definition. This makes it easier to edit arrays and objects to add/remove elements. That is why the PR impacts so many files.

For more information: https://github.com/typicode/husky and https://github.com/okonet/lint-staged

@the-simian
Copy link
Member

I use husky in other projects, Its great!

I'm not super into the trailing comma, because my editor can automatically fix those (and so can husky). Its my preference to leave this off, but the core idea behind the PR of making a commit hook is great.

Actually a better approach, I've found is to not run prettier, but run eslint with --fix. I'm using eslint as the main entry point here, so I will add this feaure, but I need to do it a slightly different way.

The big idea with using eslint is so that editors don't really need to know about prettier, they can just know about eslint (which they likely already use). Still going to use prettier for most of the style rules though.

I am going to integrate this functionality. I want to stick with the one source of truth for style: eslint. This way there's not a bunch of competing lint/style rules in the root of the project.

So I'm not going to pull this PR in, but I'm totally going to make sure you get this feature asap, I'm just achieving the same goal in a slightly different way, that I think will be useful to more people than just us folks that love prettier. (you could easily swap out for standard if you hate semicolons easily)

Thank you very much for the PR! I've greatly appreciated your interest so far. I'll @ you when I get this in, might be this evening.

@the-simian the-simian closed this Jun 21, 2018
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.

None yet

2 participants