Unibeautify
  • Install
  • Docs
  • Assistant
  • Playground
  • GitHub

›E

A

  • Align Assignments
  • Arrow Parens

B

  • Brace Style
  • Break Chained Methods

C

  • Comma First

E

  • End With Comma
  • End With Newline
  • End With Semicolon

F

  • Force Indentation

I

  • Identifier Case
  • Indent Chained Methods
  • Indent Comments
  • Indent Inner Html
  • Indent Scripts
  • Indent Size
  • Indent Style

J

  • JSLint Happy
  • JSX Brackets

K

  • Keep Array Indentation
  • Keyword Case

M

  • Max Preserve Newlines
  • Multiline Ternary

N

  • Newline Before Tags
  • Newline Between Rules
  • No Leading Zero

O

  • Object Curly Spacing

P

  • Pragma Insert
  • Pragma Require
  • Preserve Newlines

Q

  • Quotes

R

  • Remove Trailing Whitespace

S

  • Selector Separator Newline
  • Space After Anon Function
  • Space Before Conditional
  • Space In Empty Paren
  • Space In Paren

U

  • Unescape Strings
  • Unformatted

W

  • Wrap Attributes
  • Wrap Attributes Indent Size
  • Wrap Line Length
  • Wrap Prose
Edit

End With Comma

Config Key: end_with_comma

Description: If a terminating comma should be inserted into arrays, object literals, and destructured objects.

Available since version: 0.7.0 (Current: npm)

Type: boolean

Default: false

Support

Edit Beautifiers

Languages: EJS, JSX, JavaScript, Riot, Swig, Twig, TypeScript

Beautifiers: Prettier, Pretty Diff, ESLint, TSLint

Comparison Table

LanguagePrettierPretty DiffESLintTSLint
EJS❌✅❌❌
JSX✅✅✅❌
JavaScript✅✅✅❌
Riot❌✅❌❌
Swig❌✅❌❌
Twig❌✅❌❌
TypeScript✅✅❌✅

Examples

Invisible characters are shown with the following symbols:

Carriage Return = ␍; Line Feed = ␊; Tab = ⇥; Whitespace = ·.

Add EJS Example

No example found. Please submit a Pull Request!

Edit JSX Example

🚧 Original Code

var·foo·=·{␊
····bar:·"baz",␊
····qux:·"quux",␊
};␊
␊
var·bar·=·{␊
····bar:·"baz",␊
····qux:·"quux"␊
};

🔧 true

Using Prettier beautifier:

var·foo·=·{␊
··bar:·"baz",␊
··qux:·"quux",␊
};␊
␊
var·bar·=·{␊
··bar:·"baz",␊
··qux:·"quux",␊
};␊

How to configure A .unibeautify.json file would look like the following:

{
  "JSX": {
    "indent_size": 2,
    "indent_char": " ",
    "end_with_comma": true,
    "beautifiers": [
      "Prettier"
    ]
  }
}

Difference from original

Index: true
===================================================================
--- true    Original
+++ true    Beautified
@@ -1,9 +1,9 @@
 var·foo·=·{␊
-····bar:·"baz",␊
-····qux:·"quux",␊
+··bar:·"baz",␊
+··qux:·"quux",␊
 };␊
 ␊
 var·bar·=·{␊
-····bar:·"baz",␊
\ No newline at end of file
-····qux:·"quux"␊
-};
+··bar:·"baz",␊
+··qux:·"quux",␊
+};␊

🔧 false

Using Prettier beautifier:

var·foo·=·{␊
··bar:·"baz",␊
··qux:·"quux"␊
};␊
␊
var·bar·=·{␊
··bar:·"baz",␊
··qux:·"quux"␊
};␊

How to configure A .unibeautify.json file would look like the following:

{
  "JSX": {
    "indent_size": 2,
    "indent_char": " ",
    "end_with_comma": false,
    "beautifiers": [
      "Prettier"
    ]
  }
}

Difference from original

Index: false
===================================================================
--- false   Original
+++ false   Beautified
@@ -1,9 +1,9 @@
 var·foo·=·{␊
-····bar:·"baz",␊
-····qux:·"quux",␊
+··bar:·"baz",␊
+··qux:·"quux"␊
 };␊
 ␊
 var·bar·=·{␊
-····bar:·"baz",␊
\ No newline at end of file
-····qux:·"quux"␊
-};
+··bar:·"baz",␊
+··qux:·"quux"␊
+};␊

Edit JavaScript Example

🚧 Original Code

var·foo·=·{␊
····bar:·"baz",␊
····qux:·"quux",␊
};␊
␊
var·bar·=·{␊
····bar:·"baz",␊
····qux:·"quux"␊
};

🔧 true

Using Prettier beautifier:

var·foo·=·{␊
··bar:·"baz",␊
··qux:·"quux",␊
};␊
␊
var·bar·=·{␊
··bar:·"baz",␊
··qux:·"quux",␊
};␊

How to configure A .unibeautify.json file would look like the following:

{
  "JavaScript": {
    "indent_size": 2,
    "indent_char": " ",
    "end_with_comma": true,
    "beautifiers": [
      "Prettier"
    ]
  }
}

Difference from original

Index: true
===================================================================
--- true    Original
+++ true    Beautified
@@ -1,9 +1,9 @@
 var·foo·=·{␊
-····bar:·"baz",␊
-····qux:·"quux",␊
+··bar:·"baz",␊
+··qux:·"quux",␊
 };␊
 ␊
 var·bar·=·{␊
-····bar:·"baz",␊
\ No newline at end of file
-····qux:·"quux"␊
-};
+··bar:·"baz",␊
+··qux:·"quux",␊
+};␊

🔧 false

Using Prettier beautifier:

var·foo·=·{␊
··bar:·"baz",␊
··qux:·"quux"␊
};␊
␊
var·bar·=·{␊
··bar:·"baz",␊
··qux:·"quux"␊
};␊

How to configure A .unibeautify.json file would look like the following:

{
  "JavaScript": {
    "indent_size": 2,
    "indent_char": " ",
    "end_with_comma": false,
    "beautifiers": [
      "Prettier"
    ]
  }
}

Difference from original

Index: false
===================================================================
--- false   Original
+++ false   Beautified
@@ -1,9 +1,9 @@
 var·foo·=·{␊
-····bar:·"baz",␊
-····qux:·"quux",␊
+··bar:·"baz",␊
+··qux:·"quux"␊
 };␊
 ␊
 var·bar·=·{␊
-····bar:·"baz",␊
\ No newline at end of file
-····qux:·"quux"␊
-};
+··bar:·"baz",␊
+··qux:·"quux"␊
+};␊

Add Riot Example

No example found. Please submit a Pull Request!

Add Swig Example

No example found. Please submit a Pull Request!

Add Twig Example

No example found. Please submit a Pull Request!

Edit TypeScript Example

🚧 Original Code

var·foo·=·{␊
····bar:·"baz",␊
····qux:·"quux",␊
};␊
␊
var·bar·=·{␊
····bar:·"baz",␊
····qux:·"quux"␊
};

🔧 true

Using Prettier beautifier:

var·foo·=·{␊
··bar:·"baz",␊
··qux:·"quux",␊
};␊
␊
var·bar·=·{␊
··bar:·"baz",␊
··qux:·"quux",␊
};␊

How to configure A .unibeautify.json file would look like the following:

{
  "TypeScript": {
    "indent_size": 2,
    "indent_char": " ",
    "end_with_comma": true,
    "beautifiers": [
      "Prettier"
    ]
  }
}

Difference from original

Index: true
===================================================================
--- true    Original
+++ true    Beautified
@@ -1,9 +1,9 @@
 var·foo·=·{␊
-····bar:·"baz",␊
-····qux:·"quux",␊
+··bar:·"baz",␊
+··qux:·"quux",␊
 };␊
 ␊
 var·bar·=·{␊
-····bar:·"baz",␊
\ No newline at end of file
-····qux:·"quux"␊
-};
+··bar:·"baz",␊
+··qux:·"quux",␊
+};␊

🔧 false

Using Prettier beautifier:

var·foo·=·{␊
··bar:·"baz",␊
··qux:·"quux"␊
};␊
␊
var·bar·=·{␊
··bar:·"baz",␊
··qux:·"quux"␊
};␊

How to configure A .unibeautify.json file would look like the following:

{
  "TypeScript": {
    "indent_size": 2,
    "indent_char": " ",
    "end_with_comma": false,
    "beautifiers": [
      "Prettier"
    ]
  }
}

Difference from original

Index: false
===================================================================
--- false   Original
+++ false   Beautified
@@ -1,9 +1,9 @@
 var·foo·=·{␊
-····bar:·"baz",␊
-····qux:·"quux",␊
+··bar:·"baz",␊
+··qux:·"quux"␊
 };␊
 ␊
 var·bar·=·{␊
-····bar:·"baz",␊
\ No newline at end of file
-····qux:·"quux"␊
-};
+··bar:·"baz",␊
+··qux:·"quux"␊
+};␊

← Comma FirstEnd With Newline →
  • Support
  • Examples
Unibeautify
Docs
Getting StartedCLIConfigurationOptions
Community
User ShowcaseStack Overflow@Unibeautify on TwitterFollow Unibeautify on Twitter
More
GitHubStar Unibeautify on GitHubCode coverage of UnibeautifyCode coverage of Unibeautify
© 2020 Glavin Wiechert
Credits