🚀Announcing Flightcontrol - Optimized Deployment for Fullstack Blitz.js and Next.js 🚀
Back to Documentation Menu

Custom Prettier Config

Topics

Jump to a Topic

Prettier is an opinionated code formatter. It enforces a consistent code style across your entire codebase.

It re-prints the parsed AST (abstract syntax tree) with its own rules that take the maximum line length into account, wrapping code when necessary, etc.

Configuration File

Prettier uses cosmiconfig for configuration file support. This means you can configure Prettier via (in order of precedence):

  • A "prettier" key in your package.json file.
  • A .prettierrc file written in JSON or YAML.
  • A .prettierrc.json, .prettierrc.yml, .prettierrc.yaml, or .prettierrc.json5 file.
  • A .prettierrc.js, .prettierrc.cjs, prettier.config.js, or prettier.config.cjs file that exports an object using module.exports.
  • A .prettierrc.toml file.

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.

Prettier intentionally doesn’t support any kind of global configuration. This is to make sure that when a project is copied to another computer, Prettier’s behavior stays the same. Otherwise, Prettier wouldn’t be able to guarantee that everybody in a team gets the same consistent results.

The full set of configuration options, including overrides and sharing options can be found in the prettier docs

Default Blitz config

By default, new Blitz apps configure prettier using the "prettier" key in the package.json file


Idea for improving this page? Edit it on GitHub.