Enforcing Style

Enforce consistent style patterns with the command npm run prettify

package.json:

"prettier": {
"arrowParens": "always",
"bracketSpacing": true,
"bracketSameLine": false,
"printWidth": 80,
"quoteProps": "as-needed",
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all",
"useTabs": true
},
"scripts": {
// ...
"prettify": "npx prettier --write .",
// ...
}

Implementation

HaTs projects are pre-configured to enforce style using prettier.

While enforcing code style may seem immaterial, these consistency refactors carry huge value adds:

  • Your git history on file-by-file basis is cleaner.
  • Your team members or contributors can quickly write features locally using whatever idiosyncratic patterns they like, and the final synced changes are automagically standardized.

Further Reading

Edit this page on GitHub

Happy TypeScript
©2022 👨🏾‍💻 Kamar Mack