From 3d490658e18fbd171840cb8b8db90bb6c3393735 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 5 May 2017 13:34:27 -0500 Subject: [PATCH 1/8] fix `undefined` when options has no description When an option doesn't have a description `undefined` prefixes the (Supported by ...) declaration in the settings --- script/build-options.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/build-options.js b/script/build-options.js index 43141a4..5736fc1 100644 --- a/script/build-options.js +++ b/script/build-options.js @@ -133,9 +133,9 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) { return _.reduce(languageOptions, (function(result, optionDef, optionName) { optionDef.beautifiers = _.uniq(optionDef.beautifiers) if (optionDef.beautifiers.length > 0) { - optionDef.description = optionDef.description + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; + optionDef.description = (optionDef.description || "") + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; } else { - optionDef.description = optionDef.description + " (Not supported by any beautifiers)"; + optionDef.description = (optionDef.description || "") + " (Not supported by any beautifiers)"; } if (result[optionName] != null) { logger.warn("Duplicate option detected: ", optionName, optionDef); From a344acd48fc68be5ffcf79f94eaf84af6735ddae Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 5 May 2017 14:14:31 -0500 Subject: [PATCH 2/8] Add PHPCBF Version setting --- src/languages/php.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/languages/php.coffee b/src/languages/php.coffee index 42274f8..09fb4aa 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -55,6 +55,11 @@ module.exports = { type: 'string' default: "" description: "Path to the `phpcbf` CLI executable", + phpcbf_version: + title: "PHPCBF Version" + type: 'integer' + default: 2 + enum: [1, 2, 3] standard: title: "PHPCBF Standard" type: 'string' From fc10c7ee93cb9f0d7fde1b1733394f8c43e9a5ac Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 5 May 2017 14:15:23 -0500 Subject: [PATCH 3/8] fix PHP settings --- src/beautifiers/php-cs-fixer.coffee | 8 +++++++- src/beautifiers/phpcbf.coffee | 12 +++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/beautifiers/php-cs-fixer.coffee b/src/beautifiers/php-cs-fixer.coffee index fd42081..9fa408d 100644 --- a/src/beautifiers/php-cs-fixer.coffee +++ b/src/beautifiers/php-cs-fixer.coffee @@ -13,7 +13,13 @@ module.exports = class PHPCSFixer extends Beautifier isPreInstalled: false options: - PHP: true + PHP: + rules: true + cs_fixer_path: true + cs_fixer_version: true + allow_risky: true + level: true + fixers: true beautify: (text, language, options, context) -> @debug('php-cs-fixer', options) diff --git a/src/beautifiers/phpcbf.coffee b/src/beautifiers/phpcbf.coffee index 4d0a472..d811ec8 100644 --- a/src/beautifiers/phpcbf.coffee +++ b/src/beautifiers/phpcbf.coffee @@ -11,12 +11,10 @@ module.exports = class PHPCBF extends Beautifier isPreInstalled: false options: { - _: - standard: ["standard", (standard) -> - if (standard) then \ - standard else "PEAR" - ] - PHP: true + PHP: + phpcbf_path: true + phpcbf_version: true + standard: true } beautify: (text, language, options) -> @@ -50,7 +48,7 @@ module.exports = class PHPCBF extends Beautifier @run(exec, [ phpcbfPath unless isExec - "--no-patch" + "--no-patch" unless options.phpcbf_version is 3 "--standard=#{options.standard}" if options.standard tempFile = @tempFile("temp", text) ], { From 04e3a826be8dfd08d97e2f9be00d5a0d825246eb Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 5 May 2017 14:24:17 -0500 Subject: [PATCH 4/8] npm run docs --- docs/options.md | 71 +++++++++++++++++++++++++++++++++++------------- src/options.json | 26 +++++++++++++++--- 2 files changed, 74 insertions(+), 23 deletions(-) diff --git a/docs/options.md b/docs/options.md index c4e0a38..f11a3b5 100644 --- a/docs/options.md +++ b/docs/options.md @@ -9575,9 +9575,10 @@ Specify a configuration file which will override the default name of .perltidyrc | `cs_fixer_version` | :white_check_mark: | :x: | :x: | | `fixers` | :white_check_mark: | :x: | :x: | | `level` | :white_check_mark: | :x: | :x: | -| `phpcbf_path` | :white_check_mark: | :x: | :x: | +| `phpcbf_path` | :x: | :white_check_mark: | :x: | +| `phpcbf_version` | :x: | :white_check_mark: | :x: | | `rules` | :white_check_mark: | :x: | :x: | -| `standard` | :white_check_mark: | :white_check_mark: | :x: | +| `standard` | :x: | :white_check_mark: | :x: | **Description**: @@ -9774,11 +9775,11 @@ By default, all PSR-2 fixers and some additional ones are run. (PHP-CS-Fixer 1 o **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) +Path to the `phpcbf` CLI executable (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -9790,6 +9791,34 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) } ``` +##### [PHPCBF Version](#phpcbf-version) + +**Namespace**: `php` + +**Key**: `phpcbf_version` + +**Default**: `2` + +**Type**: `integer` + +**Enum**: `1` `2` `3` + +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) + +**Description**: + +undefined (Supported by PHPCBF) + +**Example `.jsbeautifyrc` Configuration** + +```json +{ + "php": { + "phpcbf_version": 2 + } +} +``` + ##### [Rules](#rules) **Namespace**: `php` @@ -9822,11 +9851,11 @@ Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (PHP-CS-Fixer 2 only) (Sup **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -17478,6 +17507,9 @@ allow risky rules to be applied (PHP-CS-Fixer 2 only) (Supported by PHP-CS-Fixer } ``` + +### PHPCBF + ##### [PHPCBF Path](#phpcbf-path) **Namespace**: `php` @@ -17486,11 +17518,11 @@ allow risky rules to be applied (PHP-CS-Fixer 2 only) (Supported by PHP-CS-Fixer **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) +Path to the `phpcbf` CLI executable (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** @@ -17502,33 +17534,34 @@ Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer) } ``` -##### [PHPCBF Standard](#phpcbf-standard) +##### [PHPCBF Version](#phpcbf-version) **Namespace**: `php` -**Key**: `standard` +**Key**: `phpcbf_version` -**Type**: `string` +**Default**: `2` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Type**: `integer` + +**Enum**: `1` `2` `3` + +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) +undefined (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** ```json { "php": { - "standard": "" + "phpcbf_version": 2 } } ``` - -### PHPCBF - ##### [PHPCBF Standard](#phpcbf-standard) **Namespace**: `php` @@ -17537,11 +17570,11 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru **Type**: `string` -**Supported Beautifiers**: [`PHP-CS-Fixer`](#php-cs-fixer) [`PHPCBF`](#phpcbf) +**Supported Beautifiers**: [`PHPCBF`](#phpcbf) **Description**: -Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF) +Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF) **Example `.jsbeautifyrc` Configuration** diff --git a/src/options.json b/src/options.json index e7894a9..c29c58c 100644 --- a/src/options.json +++ b/src/options.json @@ -5874,9 +5874,9 @@ "title": "PHPCBF Path", "type": "string", "default": "", - "description": "Path to the `phpcbf` CLI executable (Supported by PHP-CS-Fixer)", + "description": "Path to the `phpcbf` CLI executable (Supported by PHPCBF)", "beautifiers": [ - "PHP-CS-Fixer" + "PHPCBF" ], "key": "phpcbf_path", "language": { @@ -5884,13 +5884,31 @@ "namespace": "php" } }, + "phpcbf_version": { + "title": "PHPCBF Version", + "type": "integer", + "default": 2, + "enum": [ + 1, + 2, + 3 + ], + "beautifiers": [ + "PHPCBF" + ], + "key": "phpcbf_version", + "language": { + "name": "PHP", + "namespace": "php" + }, + "description": "undefined (Supported by PHPCBF)" + }, "standard": { "title": "PHPCBF Standard", "type": "string", "default": "", - "description": "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHP-CS-Fixer, PHPCBF)", + "description": "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF)", "beautifiers": [ - "PHP-CS-Fixer", "PHPCBF" ], "key": "standard", From ce73ce220810286284290bd08342ebb73d7e0e52 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 6 May 2017 13:27:42 -0500 Subject: [PATCH 5/8] set PEAR as default standard --- src/languages/php.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/languages/php.coffee b/src/languages/php.coffee index 09fb4aa..e22873f 100644 --- a/src/languages/php.coffee +++ b/src/languages/php.coffee @@ -63,7 +63,7 @@ module.exports = { standard: title: "PHPCBF Standard" type: 'string' - default: "", + default: "PEAR", description: "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root." } From add8333192b3af2f8b35576c9d3417ad38c700e8 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 6 May 2017 13:28:00 -0500 Subject: [PATCH 6/8] npm run docs --- docs/options.md | 8 ++++++-- src/options.json | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/options.md b/docs/options.md index f11a3b5..fe527b9 100644 --- a/docs/options.md +++ b/docs/options.md @@ -9849,6 +9849,8 @@ Add rule(s). i.e. line_ending,-full_opening_tag,@PSR2 (PHP-CS-Fixer 2 only) (Sup **Key**: `standard` +**Default**: `PEAR` + **Type**: `string` **Supported Beautifiers**: [`PHPCBF`](#phpcbf) @@ -9862,7 +9864,7 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru ```json { "php": { - "standard": "" + "standard": "PEAR" } } ``` @@ -17568,6 +17570,8 @@ undefined (Supported by PHPCBF) **Key**: `standard` +**Default**: `PEAR` + **Type**: `string` **Supported Beautifiers**: [`PHPCBF`](#phpcbf) @@ -17581,7 +17585,7 @@ Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS ru ```json { "php": { - "standard": "" + "standard": "PEAR" } } ``` diff --git a/src/options.json b/src/options.json index c29c58c..4873da4 100644 --- a/src/options.json +++ b/src/options.json @@ -5906,7 +5906,7 @@ "standard": { "title": "PHPCBF Standard", "type": "string", - "default": "", + "default": "PEAR", "description": "Standard name Squiz, PSR2, PSR1, PHPCS, PEAR, Zend, MySource... or path to CS rules. Will use local `phpcs.xml`, `phpcs.xml.dist`, `phpcs.ruleset.xml` or `ruleset.xml` if found in the project root. (Supported by PHPCBF)", "beautifiers": [ "PHPCBF" From 20299459c9c224dd716faaba316c836e834e34d8 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 6 May 2017 13:38:45 -0500 Subject: [PATCH 7/8] fix all descriptions --- script/build-options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/build-options.js b/script/build-options.js index 5736fc1..4d1fabf 100644 --- a/script/build-options.js +++ b/script/build-options.js @@ -322,7 +322,7 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) { optionDef = ref16[o]; optionDef.beautifiers = _.uniq(optionDef.beautifiers) if (optionDef.beautifiers.length > 0) { - optionDef.description = optionDef.description + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; + optionDef.description = (optionDef.description || "") + " (Supported by " + (optionDef.beautifiers.join(', ')) + ")"; } else { unsupportedOptions.push(g + ".properties." + o); } From 9ea17f755a3e9ebf13db9105e1a7cf18ca00b0e6 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Sat, 6 May 2017 13:38:52 -0500 Subject: [PATCH 8/8] npm run docs --- docs/options.md | 12 ++++++------ src/options.json | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/options.md b/docs/options.md index c4e0a38..5232b30 100644 --- a/docs/options.md +++ b/docs/options.md @@ -7074,7 +7074,7 @@ Automatically beautify LaTeX files on save **Description**: -undefined (Supported by Latex Beautify) + (Supported by Latex Beautify) **Example `.jsbeautifyrc` Configuration** @@ -8945,7 +8945,7 @@ Automatically beautify Nginx files on save **Description**: -undefined (Supported by Nginx Beautify) + (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** @@ -9706,7 +9706,7 @@ Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Description**: -undefined (Supported by PHP-CS-Fixer) + (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** @@ -16757,7 +16757,7 @@ Remove trailing whitespace (Supported by Latex Beautify) **Description**: -undefined (Supported by Latex Beautify) + (Supported by Latex Beautify) **Example `.jsbeautifyrc` Configuration** @@ -17311,7 +17311,7 @@ Indentation uses tabs, overrides `Indent Size` and `Indent Char` (Supported by N **Description**: -undefined (Supported by Nginx Beautify) + (Supported by Nginx Beautify) **Example `.jsbeautifyrc` Configuration** @@ -17366,7 +17366,7 @@ Absolute path to the `php-cs-fixer` CLI executable (Supported by PHP-CS-Fixer) **Description**: -undefined (Supported by PHP-CS-Fixer) + (Supported by PHP-CS-Fixer) **Example `.jsbeautifyrc` Configuration** diff --git a/src/options.json b/src/options.json index e7894a9..8694365 100644 --- a/src/options.json +++ b/src/options.json @@ -4301,7 +4301,7 @@ "name": "LaTeX", "namespace": "latex" }, - "description": "undefined (Supported by Latex Beautify)" + "description": " (Supported by Latex Beautify)" }, "disabled": { "title": "Disable Beautifying Language", @@ -5420,7 +5420,7 @@ "name": "Nginx", "namespace": "nginx" }, - "description": "undefined (Supported by Nginx Beautify)" + "description": " (Supported by Nginx Beautify)" }, "disabled": { "title": "Disable Beautifying Language", @@ -5808,7 +5808,7 @@ "name": "PHP", "namespace": "php" }, - "description": "undefined (Supported by PHP-CS-Fixer)" + "description": " (Supported by PHP-CS-Fixer)" }, "fixers": { "type": "string",