Skip to content

Latest commit

 

History

History
70 lines (50 loc) · 1.92 KB

prettier.md

File metadata and controls

70 lines (50 loc) · 1.92 KB
description title layout
Explore Prettier, the powerful code formatter. Learn how to install, configure, and effectively use Prettier to enhance your coding workflow.
Trunk | How to run Prettier
title description tableOfContents outline pagination
visible
true
visible
visible
true
visible
true
visible
true

Prettier

Prettier is a formatter for CSS, SCSS, JavaScript, JSON, Markdown, TypeScript, GraphQL and YAML.

You can enable the Prettier formatter with:

trunk check enable prettier

prettier example output

Auto Enabling

Prettier will be auto-enabled if any TypeScript, Yaml, Css, Postcss, Sass, Html, Markdown, Json, JavaScript, Graphql or Prettier_supported_configs files are present.

Settings

Prettier supports the following config files:

  • .prettierrc
  • .prettierrc.json
  • .prettierrc.yml
  • .prettierrc.yaml
  • .prettierrc.json5
  • .prettierrc.js
  • .prettierrc.cjs
  • .prettierrc.mjs
  • prettier.config.js
  • prettier.config.cjs
  • prettier.config.mjs
  • .prettierrc.toml
  • .prettierignore

You can move these files to .trunk/configs and trunk check will still find them. See Moving Linters for more info.

Usage Notes

By default, Trunk uses Prettier to autoformat many languages/config formats, including markdown. To line wrap within markdown, you need to set the following in your Prettier config .prettierrc.yaml, etc.

proseWrap: always

You may also want to configure printWidth to your liking.

Links