From 971a87fcd88f2ef4e5d2509c8081b4f1b39f3c7e Mon Sep 17 00:00:00 2001 From: Glavin Wiechert Date: Thu, 10 Sep 2015 16:08:58 -0300 Subject: [PATCH] See #524, #534. Add end_with_comma option to JavaScript using Pretty Diff --- docs/options.md | 72 +++++++++++++++++++++++++++++++ src/beautifiers/prettydiff.coffee | 1 + src/languages/javascript.coffee | 5 +++ 3 files changed, 78 insertions(+) diff --git a/docs/options.md b/docs/options.md index b5e9320..60d26b9 100644 --- a/docs/options.md +++ b/docs/options.md @@ -1440,6 +1440,30 @@ End output with newline (Supported by JS Beautify) } ``` +#### [JavaScript - End with comma](#javascript---end-with-comma) + +**Namespace**: `js` + +**Key**: `end_with_comma` + +**Type**: `boolean` + +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) + +**Description**: + +If a terminating comma should be inserted into arrays, object literals, and destructured objects. (Supported by JS Beautify, Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "end_with_comma": false + } +} +``` + #### [Objective-C - Config Path](#objective-c---config-path) **Namespace**: `objectivec` @@ -5386,6 +5410,30 @@ End output with newline (Supported by JS Beautify) } ``` +#### [JavaScript - End with comma](#javascript---end-with-comma) + +**Namespace**: `js` + +**Key**: `end_with_comma` + +**Type**: `boolean` + +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) + +**Description**: + +If a terminating comma should be inserted into arrays, object literals, and destructured objects. (Supported by JS Beautify, Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "end_with_comma": false + } +} +``` + ### Pretty Diff @@ -5869,6 +5917,30 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre } ``` +#### [JavaScript - End with comma](#javascript---end-with-comma) + +**Namespace**: `js` + +**Key**: `end_with_comma` + +**Type**: `boolean` + +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) + +**Description**: + +If a terminating comma should be inserted into arrays, object literals, and destructured objects. (Supported by JS Beautify, Pretty Diff) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "js": { + "end_with_comma": false + } +} +``` + ### Gherkin formatter diff --git a/src/beautifiers/prettydiff.coffee b/src/beautifiers/prettydiff.coffee index dfbdd70..b0b44e0 100644 --- a/src/beautifiers/prettydiff.coffee +++ b/src/beautifiers/prettydiff.coffee @@ -28,6 +28,7 @@ module.exports = class PrettyDiff extends Beautifier wrap: "wrap_line_length" space: "space_after_anon_function" noleadzero: "no_lead_zero" + endcomma: "end_with_comma" # Apply language-specific options CSV: true ERB: true diff --git a/src/languages/javascript.coffee b/src/languages/javascript.coffee index 4634765..2de59bb 100644 --- a/src/languages/javascript.coffee +++ b/src/languages/javascript.coffee @@ -106,5 +106,10 @@ module.exports = { type: 'boolean' default: false description: "End output with newline" + end_with_comma: + type: 'boolean' + default: false + description: "If a terminating comma should be inserted into \ + arrays, object literals, and destructured objects." }