Prettier is built with many options for customization. You can configure Prettier via the following options:
- A prettier.config.js or .prettierrc.js script in a JavaScript object
- A package.json file using a prettier key
- A .prettierrc file in YAML or JSON with optional extensions: .json, .yaml, or .yml
- A .prettierrc.toml file in TOML
It is a good idea to customize Prettier even though you can choose not to. For example, Prettier enforces double quotes and prints semicolons at the ends of statements by default. If we don't want these defaults, we can create a prettier.config.js file in our project root directory. Let's use Prettier in the API we have created (we made a copy at /chapter-14/apps-to-fix/koa-api/ in our GitHub repository) with this configuration in the following steps:
- Create a prettier.config.js file in our project root directory with the following code:
// prettier.config.js
module.exports = {
semi: false,
singleQuote...