THIS POST IS PENDING MORE EXPLORATION….
My .prettier file
| |
Prettier vs. Linters
How does it compare to ESLint/TSLint/stylelint, etc.?
(https://prettier.io/docs/en/comparison)
Linters have two categories of rules:
Formatting rules: eg: max-len, no-mixed-spaces-and-tabs, keyword-spacing, comma-style…
Prettier alleviates the need for this whole category of rules! Prettier is going to reprint the entire program from scratch in a consistent way, so it’s not possible for the programmer to make a mistake there anymore :)
Code-quality rules: eg no-unused-vars, no-extra-bind, no-implicit-globals, prefer-promise-reject-errors…
Prettier does nothing to help with those kind of rules. They are also the most important ones provided by linters as they are likely to catch real bugs with your code!
In other words, use Prettier for formatting and linters for catching bugs!
Prittier Configuration
(https://prettier.io/docs/en/configuration)
You can configure Prettier via (in order of precedence):
- A
"prettier"key in yourpackage.jsonfile.- A
.prettierrcfile written in JSON or YAML.- A
.prettierrc.json,.prettierrc.yml,.prettierrc.yaml, or.prettierrc.json5file.- A
.prettierrc.js, orprettier.config.jsfile that exports an object usingexport defaultormodule.exports(depends on thetypevalue in yourpackage.json).- A
.prettierrc.mjs, orprettier.config.mjsfile that exports an object usingexport default.- A
.prettierrc.cjs, orprettier.config.cjsfile that exports an object usingmodule.exports.- A
.prettierrc.tomlfile.The configuration file will be resolved starting from the location of the file being formatted, and searching up the file tree until a config file is (or isn’t) found.