Prettier Beautifier
About
Prettier beautifier for Unibeautify
| Package | Docs | Latest |
|---|---|---|
| @unibeautify/beautifier-prettier | v0.9.0 | |
| unibeautify | v0.17.1 | |
| prettier | v1.19.1 |
Install
Install with npm:
npm install --save-dev unibeautify prettier @unibeautify/beautifier-prettier
Or with yarn:
yarn add --dev unibeautify prettier @unibeautify/beautifier-prettier
Usage
Add Prettier to beautifiers language option.
A .unibeautifyrc.json file would look like the following:
{
"LANGUAGE_NAME": {
"beautifiers": [
"Prettier"
]
}
}
Note: The
LANGUAGE_NAMEshould be replaced with your desired supported language name, such asCSS,GraphQL,JSON, etc.
Advanced
The following beautifier option(s) are supported:
prefer_beautifier_config
See beautifier options docs for more information.
Example advanced configuration:
{
"LANGUAGE_NAME": {
"beautifiers": [
"Prettier"
],
"Prettier": {
"prefer_beautifier_config": true
}
}
}
Options
| Option | CSS | GraphQL | JSON | JSON5 | JSX | JavaScript | Less | Markdown | SCSS | TypeScript | Vue |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Arrow Parens | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| End With Comma | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| End With Semicolon | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Indent Size | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
| Indent Style | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ |
| JSX Brackets | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Object Curly Spacing | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Pragma Insert | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Pragma Require | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Quotes | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ✅ | ❌ |
| Wrap Line Length | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
| Wrap Prose | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ |
FAQ
How to use Prettier in Atom, VSCode, and other editors?
See the editor integration documentation for installation instructions for your editor of choice.
How to use Prettier configuration file?
You can override Unibeautify configuration and use Prettier's own configuration file instead with prefer_beautifier_config beautifier option.
{
"LANGUAGE_NAME": {
"beautifiers": [
"Prettier"
],
"Prettier": {
"prefer_beautifier_config": "path/to/Prettier/config/file"
}
}
}
See beautifier options docs for more information.
How to enable Prettier to format on save?
See the editor integration documentation for format on save instructions for your editor of choice.
How to run Prettier on all files?
You can run Prettier on all of your files for every commit with Unibeautify CI.
Is there a Prettier sandbox or playground?
You can quickly try Prettier online with Unibeautify Playground.