I'm Pam.
also known as
Señora Developer at One Medical
(we're hiring! 😉🙆🏻♀️)
eliminate comments about style in code reviews 🚮
Prettier is an automated code formatting tool that formats the code to produce consistent spaces, commas, semicolons, parens, braces, and line breaks for many languages! 🤯
The eslint --fix feature flag enables automatic fixes for lines of code that don't meet lint rules, so one might ask:
One way to increase developer happiness 😍 is to ✨automagically✨ fix "broken" code.
Automatically format files that have been changed as a part of a commit!
One major downside of formatting the whole file is the whitespace...
DIFFSRUPTION.
These changes are irrelevant and increase the cognitive complexity of reviewing code. 😱
So what do prettier, precise-commits, husky, AND eslint look like?
The precise-commits README is a good starting point.
There are some additional steps required to format code with both eslint and prettier.
Prettier docs have a nifty guide for
In summary, you'll need:
{
"extends": [
"plugin:prettier/recommended"
]
}
To tie it all in together with husky, we introduced another package, lint-staged.
lint-staged allows us to run additional tasks or file specific tasks during the pre-commit hook.
"lint-staged": {
"*.{md,json,scss}": [
"npx precise-commits",
"git add"
],
"*.js": [
"npx precise-commits --whitelist={app,spec}",
"eslint --fix",
"git add"
],
"*.scss": [
"sass-lint -c .sass-lint.yml -v -q"
]
}
Link to these slides