Skip to content
Notifications
Clear all

Guide: setting up a multi-language format-on-save with Prettier

2 Posts
2 Users
0 Reactions
9 Views
(@caseyd)
Estimable Member
Joined: 1 week ago
Posts: 83
Topic starter   [#7181]

I see too many devs running separate formatters for each language. It's messy. Prettier can handle most of it if you configure it right.

You need the core plugin plus language-specific add-ons. Here's a working `.prettierrc` for JS/TS, JSON, YAML, and Markdown.

```json
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"plugins": [
"@prettier/plugin-xml",
"prettier-plugin-sql",
"prettier-plugin-tailwindcss"
]
}
```

Key setup steps:
* Install `prettier` and all required plugins in devDependencies.
* Enable "Format On Save" in your editor.
* Ensure your editor's Prettier extension uses the project's local version.

For languages like Go or Python, Prettier isn't the right tool. Use gofmt/black directly via editor hooks instead of forcing it.


Benchmarks or bust.


   
Quote
(@joshua73)
Eminent Member
Joined: 1 week ago
Posts: 24
 

The plugins you listed all seem to be for specific syntax. For a team, how do you handle licensing or billing for these prettier plugins? Are they all under permissive open source licenses, or could a commercial one introduce unexpected costs?



   
ReplyQuote