JS-Beautify Beautifier
About
JS-Beautify beautifier for Unibeautify
| Package | Docs | Latest |
|---|---|---|
| @unibeautify/beautifier-js-beautify | v0.4.0 | |
| js-beautify | v1.13.0 | |
| unibeautify | v0.17.1 |
Install
Install with npm:
npm install --save-dev js-beautify unibeautify @unibeautify/beautifier-js-beautify
Or with yarn:
yarn add --dev js-beautify unibeautify @unibeautify/beautifier-js-beautify
Usage
Add JS-Beautify to beautifiers language option.
A .unibeautifyrc.json file would look like the following:
{
"LANGUAGE_NAME": {
"beautifiers": [
"JS-Beautify"
]
}
}
Note: The
LANGUAGE_NAMEshould be replaced with your desired supported language name, such asCSS,EJS,HTML, etc.
Options
| Option | CSS | EJS | HTML | Handlebars | JSON | JSON5 | JSX | JavaScript | Liquid | Mustache | XML |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Brace Style | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Break Chained Methods | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Comma First | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| End With Newline | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Indent Chained Methods | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Indent Inner Html | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Indent Scripts | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Indent Size | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Indent Style | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| JSLint Happy | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Keep Array Indentation | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Max Preserve Newlines | ❌ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Newline Before Tags | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Newline Between Rules | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Preserve Newlines | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Selector Separator Newline | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Space After Anon Function | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Space Before Conditional | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Space In Empty Paren | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Space In Paren | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Unescape Strings | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ |
| Unformatted | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Wrap Attributes | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Wrap Attributes Indent Size | ❌ | ❌ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ |
| Wrap Line Length | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ |
FAQ
How to use JS-Beautify in Atom, VSCode, and other editors?
See the editor integration documentation for installation instructions for your editor of choice.
How to enable JS-Beautify to format on save?
See the editor integration documentation for format on save instructions for your editor of choice.
How to run JS-Beautify on all files?
You can run JS-Beautify on all of your files for every commit with Unibeautify CI.
Is there a JS-Beautify sandbox or playground?
You can quickly try JS-Beautify online with Unibeautify Playground.