Created by: mxstbr
Prettier is an automatic code formatting tool (similar to gofmt
in go) which takes care of handling code style for us. Adding it to the repository should mean new contributors can come on board more easily because they don't have to care about writing in a consistent code style, they can just focus on their code and prettier will make sure it's formatted consistently with the rest of the code. (see the prettier website for more information)
This PR has four parts:
-
Set up prettier as a pre-commit hook (36ec5b70): With
lint-staged
andhusky
prettier now runs before contributors commit. This means everybody can write their code in whatever code style they want, but as soon as they commit it's reformatted to conform the the shared style of the codebase. -
Enforce prettier style in CI (95eef4cf): Altough it runs as a precommit hook and thusly all code is formatted, folks could on purpose disable the precommit hook, then commit without reformatting, and then submit a PR. By running prettier in CI with
--list-different
CI will fail if folks do this, in effect enforcing prettier's code style. -
Disable the stylistic eslint rules (eb7e37e5): Since prettier now enforces a consistent code style, there's no reason to enforce that again from
eslint
. I've disabled all stylist eslint rules (e.g.semi
), but left all the error catching ones in place. (e.g.no-unused-variables
) - Run prettier over the entire codebase to get a consistent style (e3bcce65)
FWIW, we've added prettier to styled-components
and react-boilerplate
and have had 0 complaints overall. It's been a huge success and has made our life much easier, on top of never having to say "Hey, CI failed because you forgot a semicolon. Please add that and push again.". It's amazing and I'd love to have that in bull so folks can contribute to this amazing project more easily.