From 35f8c924ee32d569a6ee20da6b270f0cf3f4b7ce Mon Sep 17 00:00:00 2001 From: Steven Zeck Date: Mon, 19 Feb 2018 00:09:53 -0600 Subject: [PATCH] Add Prettier as a beautifier, first commit --- README.md | 15 +- docs/options.md | 312 ++++++++++++++++---------------- package.json | 4 +- src/beautifiers/index.coffee | 1 + src/beautifiers/prettier.coffee | 38 ++++ src/options.json | 14 ++ 6 files changed, 220 insertions(+), 164 deletions(-) create mode 100644 src/beautifiers/prettier.coffee diff --git a/README.md b/README.md index 7720f42..9c3d948 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | Perltidy | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to http://perltidy.sourceforge.net/ and follow the instructions. | | PHP-CS-Fixer | :warning: 2 executables | :warning: Only 1 of 2 executables | :whale: With [Docker](https://www.docker.com/):
1. Install [PHP-CS-Fixer (`php-cs-fixer`)](https://github.com/FriendsOfPHP/PHP-CS-Fixer) with `docker pull unibeautify/php-cs-fixer`

:bookmark_tabs: Manually:
1. Install [PHP (`php`)](http://php.net/) by following http://php.net/manual/en/install.php
2. Install [PHP-CS-Fixer (`php-cs-fixer`)](https://github.com/FriendsOfPHP/PHP-CS-Fixer) by following https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation
| | PHPCBF | :warning: 2 executables | :warning: Only 1 of 2 executables | :whale: With [Docker](https://www.docker.com/):
1. Install [PHPCBF (`phpcbf`)](https://github.com/squizlabs/PHP_CodeSniffer) with `docker pull unibeautify/phpcbf`

:bookmark_tabs: Manually:
1. Install [PHP (`php`)](http://php.net/) by following http://php.net/manual/en/install.php
2. Install [PHPCBF (`phpcbf`)](https://github.com/squizlabs/PHP_CodeSniffer) by following https://github.com/squizlabs/PHP_CodeSniffer#installation
| +| Prettier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Pretty Diff | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Pug Beautify | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | puppet-lint | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [puppet-lint (`puppet-lint`)](http://puppet-lint.com/) with `docker pull unibeautify/puppet-lint`

:bookmark_tabs: Manually:
1. Install [puppet-lint (`puppet-lint`)](http://puppet-lint.com/) by following http://puppet-lint.com/
| @@ -152,7 +153,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | C++ | `C++` |`.h`, `.hh`, `.cc`, `.cpp`, `.cxx`, `.C`, `.cu`, `.c++`, `.hpp`, `.hxx`, `.h++`, `.cuh` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)**, [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | Crystal | `Crystal` |`.cr` | **[`Crystal`](http://crystal-lang.org)** | | C# | `C#` |`.cs` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** | -| CSS | `CSS` |`.css` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) | +| CSS | `CSS` |`.css` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Prettier`](https://github.com/prettier/prettier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) | | CSV | `CSV` |`.csv` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | D | `D` |`.d` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)**, [`dfmt`](https://github.com/Hackerpilot/dfmt) | | EJS | `EJS`, `JavaScript Template`, `HTML (Angular)` |`.ejs` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | @@ -169,13 +170,13 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | HTML | `HTML` |`.html` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Jade | `Jade`, `Pug` |`.jade`, `.pug` | **[`Pug Beautify`](https://github.com/vingorius/pug-beautify)** | | Java | `Java` |`.java` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** | -| JavaScript | `JavaScript` |`.js` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`ESLint Fixer`](https://github.com/eslint/eslint), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | -| JSON | `JSON` |`.json` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | +| JavaScript | `JavaScript` |`.js` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`ESLint Fixer`](https://github.com/eslint/eslint), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Prettier`](https://github.com/prettier/prettier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | +| JSON | `JSON` |`.json` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Prettier`](https://github.com/prettier/prettier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | JSX | `JSX`, `JavaScript (JSX)`, `Babel ES6 JavaScript`, `JavaScript with JSX` |`.jsx`, `.js` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`JS Beautify`](https://github.com/beautify-web/js-beautify) | | LaTeX | `BibTeX`, `LaTeX`, `TeX` |`.bib`, `.tex`, `.sty`, `.cls`, `.dtx`, `.ins`, `.bbx`, `.cbx` | **[`Latex Beautify`](https://github.com/cmhughes/latexindent.pl)** | -| LESS | `LESS` |`.less` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`CSScomb`](https://github.com/csscomb/csscomb.js) | +| LESS | `LESS` |`.less` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Prettier`](https://github.com/prettier/prettier) | | Lua | `Lua` |`.lua`, `.ttslua` | **[`Lua beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.coffee)** | -| Markdown | `GitHub Markdown` |`.markdown`, `.md` | **[`Tidy Markdown`](https://github.com/slang800/tidy-markdown)**, [`Remark`](https://github.com/wooorm/remark) | +| Markdown | `GitHub Markdown` |`.markdown`, `.md` | **[`Tidy Markdown`](https://github.com/slang800/tidy-markdown)**, [`Prettier`](https://github.com/prettier/prettier), [`Remark`](https://github.com/wooorm/remark) | | Marko | `Marko` |`.marko` | **[`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint)** | | Mustache | `HTML (Mustache)` |`.mustache` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Nginx | `nginx` |`.conf` | **[`Nginx Beautify`](https://github.com/denysvitali/nginxbeautify)** | @@ -192,7 +193,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Ruby | `Ruby`, `Ruby on Rails` |`.rb` | **[`Rubocop`](https://github.com/bbatsov/rubocop)**, [`Ruby Beautify`](https://github.com/erniebrodeur/ruby-beautify) | | Rust | `Rust` |`.rs`, `.rlib` | **[`rustfmt`](https://github.com/rust-lang-nursery/rustfmt)** | | Sass | `Sass` |`.sass` | **[`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax)** | -| SCSS | `SCSS` |`.scss` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`CSScomb`](https://github.com/csscomb/csscomb.js), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) | +| SCSS | `SCSS` |`.scss` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Prettier`](https://github.com/prettier/prettier), [`SassConvert`](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax) | | Spacebars | `Spacebars` | | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | SQL | `SQL (Rails)`, `SQL` |`.sql` | **[`sqlformat`](https://github.com/andialbrecht/sqlparse)** | | SVG | `SVG` |`.svg` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | @@ -205,7 +206,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | UX Markup | `UX` |`.ux` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | Vala | `Vala` |`.vala`, `.vapi` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** | | Visualforce | `Visualforce` |`.page` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | -| Vue | `Vue Component` |`.vue` | **[`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee)** | +| Vue | `Vue Component` |`.vue` | **[`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee)**, [`Prettier`](https://github.com/prettier/prettier) | | XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe`, `.config` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`JS Beautify`](https://github.com/beautify-web/js-beautify) | | XTemplate | `XTemplate` |`.xtemplate` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | YAML | `YAML` |`.yml`, `.yaml` | **[`align-yaml`](https://github.com/jonschlinkert/align-yaml)** | diff --git a/docs/options.md b/docs/options.md index 6047ede..470de85 100644 --- a/docs/options.md +++ b/docs/options.md @@ -1913,27 +1913,27 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify) #### [CSS](#css) -**Supported Beautifiers**: [`CSScomb`](#csscomb) [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) [`SassConvert`](#sassconvert) +**Supported Beautifiers**: [`CSScomb`](#csscomb) [`JS Beautify`](#js-beautify) [`Prettier`](#prettier) [`Pretty Diff`](#pretty-diff) [`SassConvert`](#sassconvert) -| Option | CSScomb | JS Beautify | Pretty Diff | SassConvert | -| --- | --- | --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `align_assignments` | :x: | :x: | :white_check_mark: | :x: | -| `configPath` | :white_check_mark: | :x: | :x: | :x: | -| `convert_quotes` | :x: | :x: | :white_check_mark: | :x: | -| `end_with_newline` | :x: | :white_check_mark: | :x: | :x: | -| `force_indentation` | :x: | :x: | :white_check_mark: | :x: | -| `indent_char` | :x: | :white_check_mark: | :white_check_mark: | :x: | -| `indent_comments` | :x: | :x: | :white_check_mark: | :x: | -| `indent_size` | :x: | :white_check_mark: | :white_check_mark: | :x: | -| `newline_between_rules` | :x: | :white_check_mark: | :white_check_mark: | :x: | -| `no_lead_zero` | :x: | :x: | :white_check_mark: | :x: | -| `predefinedConfig` | :white_check_mark: | :x: | :x: | :x: | -| `preserve_newlines` | :x: | :white_check_mark: | :white_check_mark: | :x: | -| `selector_separator_newline` | :x: | :white_check_mark: | :x: | :x: | -| `wrap_line_length` | :x: | :white_check_mark: | :white_check_mark: | :x: | +| Option | CSScomb | JS Beautify | Prettier | Pretty Diff | SassConvert | +| --- | --- | --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `align_assignments` | :x: | :x: | :x: | :white_check_mark: | :x: | +| `configPath` | :white_check_mark: | :x: | :x: | :x: | :x: | +| `convert_quotes` | :x: | :x: | :x: | :white_check_mark: | :x: | +| `end_with_newline` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `force_indentation` | :x: | :x: | :x: | :white_check_mark: | :x: | +| `indent_char` | :x: | :white_check_mark: | :x: | :white_check_mark: | :x: | +| `indent_comments` | :x: | :x: | :x: | :white_check_mark: | :x: | +| `indent_size` | :x: | :white_check_mark: | :x: | :white_check_mark: | :x: | +| `newline_between_rules` | :x: | :white_check_mark: | :x: | :white_check_mark: | :x: | +| `no_lead_zero` | :x: | :x: | :x: | :white_check_mark: | :x: | +| `predefinedConfig` | :white_check_mark: | :x: | :x: | :x: | :x: | +| `preserve_newlines` | :x: | :white_check_mark: | :x: | :white_check_mark: | :x: | +| `selector_separator_newline` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `wrap_line_length` | :x: | :white_check_mark: | :x: | :white_check_mark: | :x: | **Description**: @@ -1964,7 +1964,7 @@ Disable CSS Beautification **Type**: `string` -**Enum**: `CSScomb` `JS Beautify` `Pretty Diff` `SassConvert` +**Enum**: `CSScomb` `JS Beautify` `Prettier` `Pretty Diff` `SassConvert` **Description**: @@ -5510,33 +5510,33 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify) #### [JavaScript](#javascript) -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`ESLint Fixer`](#eslint-fixer) [`Pretty Diff`](#pretty-diff) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`JSCS Fixer`](#jscs-fixer) [`ESLint Fixer`](#eslint-fixer) [`Prettier`](#prettier) [`Pretty Diff`](#pretty-diff) -| Option | ESLint Fixer | JS Beautify | JSCS Fixer | Pretty Diff | -| --- | --- | --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `brace_style` | :x: | :white_check_mark: | :x: | :x: | -| `break_chained_methods` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `end_of_line` | :x: | :white_check_mark: | :x: | :x: | -| `end_with_comma` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `end_with_newline` | :x: | :white_check_mark: | :x: | :x: | -| `eval_code` | :x: | :white_check_mark: | :x: | :x: | -| `indent_char` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `indent_level` | :x: | :white_check_mark: | :x: | :x: | -| `indent_size` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `indent_with_tabs` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `jslint_happy` | :x: | :white_check_mark: | :x: | :x: | -| `keep_array_indentation` | :x: | :white_check_mark: | :x: | :x: | -| `keep_function_indentation` | :x: | :white_check_mark: | :x: | :x: | -| `max_preserve_newlines` | :x: | :white_check_mark: | :x: | :x: | -| `preserve_newlines` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `space_after_anon_function` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `space_before_conditional` | :x: | :white_check_mark: | :x: | :x: | -| `space_in_paren` | :x: | :white_check_mark: | :x: | :white_check_mark: | -| `unescape_strings` | :x: | :white_check_mark: | :x: | :x: | -| `wrap_line_length` | :x: | :white_check_mark: | :x: | :white_check_mark: | +| Option | ESLint Fixer | JS Beautify | JSCS Fixer | Prettier | Pretty Diff | +| --- | --- | --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `brace_style` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `break_chained_methods` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `end_of_line` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `end_with_comma` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `end_with_newline` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `eval_code` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `indent_char` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `indent_level` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `indent_size` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `indent_with_tabs` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `jslint_happy` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `keep_array_indentation` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `keep_function_indentation` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `max_preserve_newlines` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `preserve_newlines` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `space_after_anon_function` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `space_before_conditional` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `space_in_paren` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | +| `unescape_strings` | :x: | :white_check_mark: | :x: | :x: | :x: | +| `wrap_line_length` | :x: | :white_check_mark: | :x: | :x: | :white_check_mark: | **Description**: @@ -5567,7 +5567,7 @@ Disable JavaScript Beautification **Type**: `string` -**Enum**: `JS Beautify` `JSCS Fixer` `ESLint Fixer` `Pretty Diff` +**Enum**: `JS Beautify` `JSCS Fixer` `ESLint Fixer` `Prettier` `Pretty Diff` **Description**: @@ -6097,33 +6097,33 @@ Wrap lines at next opportunity after N characters (Supported by JS Beautify, Pre #### [JSON](#json) -**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Pretty Diff`](#pretty-diff) +**Supported Beautifiers**: [`JS Beautify`](#js-beautify) [`Prettier`](#prettier) [`Pretty Diff`](#pretty-diff) -| Option | JS Beautify | Pretty Diff | -| --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | -| `brace_style` | :white_check_mark: | :x: | -| `break_chained_methods` | :white_check_mark: | :white_check_mark: | -| `end_of_line` | :white_check_mark: | :x: | -| `end_with_comma` | :white_check_mark: | :white_check_mark: | -| `end_with_newline` | :white_check_mark: | :x: | -| `eval_code` | :white_check_mark: | :x: | -| `indent_char` | :white_check_mark: | :white_check_mark: | -| `indent_level` | :white_check_mark: | :x: | -| `indent_size` | :white_check_mark: | :white_check_mark: | -| `indent_with_tabs` | :white_check_mark: | :white_check_mark: | -| `jslint_happy` | :white_check_mark: | :x: | -| `keep_array_indentation` | :white_check_mark: | :x: | -| `keep_function_indentation` | :white_check_mark: | :x: | -| `max_preserve_newlines` | :white_check_mark: | :x: | -| `preserve_newlines` | :white_check_mark: | :white_check_mark: | -| `space_after_anon_function` | :white_check_mark: | :white_check_mark: | -| `space_before_conditional` | :white_check_mark: | :x: | -| `space_in_paren` | :white_check_mark: | :white_check_mark: | -| `unescape_strings` | :white_check_mark: | :x: | -| `wrap_line_length` | :white_check_mark: | :white_check_mark: | +| Option | JS Beautify | Prettier | Pretty Diff | +| --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `brace_style` | :white_check_mark: | :x: | :x: | +| `break_chained_methods` | :white_check_mark: | :x: | :white_check_mark: | +| `end_of_line` | :white_check_mark: | :x: | :x: | +| `end_with_comma` | :white_check_mark: | :x: | :white_check_mark: | +| `end_with_newline` | :white_check_mark: | :x: | :x: | +| `eval_code` | :white_check_mark: | :x: | :x: | +| `indent_char` | :white_check_mark: | :x: | :white_check_mark: | +| `indent_level` | :white_check_mark: | :x: | :x: | +| `indent_size` | :white_check_mark: | :x: | :white_check_mark: | +| `indent_with_tabs` | :white_check_mark: | :x: | :white_check_mark: | +| `jslint_happy` | :white_check_mark: | :x: | :x: | +| `keep_array_indentation` | :white_check_mark: | :x: | :x: | +| `keep_function_indentation` | :white_check_mark: | :x: | :x: | +| `max_preserve_newlines` | :white_check_mark: | :x: | :x: | +| `preserve_newlines` | :white_check_mark: | :x: | :white_check_mark: | +| `space_after_anon_function` | :white_check_mark: | :x: | :white_check_mark: | +| `space_before_conditional` | :white_check_mark: | :x: | :x: | +| `space_in_paren` | :white_check_mark: | :x: | :white_check_mark: | +| `unescape_strings` | :white_check_mark: | :x: | :x: | +| `wrap_line_length` | :white_check_mark: | :x: | :white_check_mark: | **Description**: @@ -6154,7 +6154,7 @@ Disable JSON Beautification **Type**: `string` -**Enum**: `JS Beautify` `Pretty Diff` +**Enum**: `JS Beautify` `Prettier` `Pretty Diff` **Description**: @@ -7553,25 +7553,25 @@ Remove trailing whitespace (Supported by Latex Beautify) #### [LESS](#less) -**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) +**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Prettier`](#prettier) [`Pretty Diff`](#pretty-diff) -| Option | CSScomb | Pretty Diff | -| --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | -| `align_assignments` | :x: | :white_check_mark: | -| `configPath` | :white_check_mark: | :x: | -| `convert_quotes` | :x: | :white_check_mark: | -| `force_indentation` | :x: | :white_check_mark: | -| `indent_char` | :x: | :white_check_mark: | -| `indent_comments` | :x: | :white_check_mark: | -| `indent_size` | :x: | :white_check_mark: | -| `newline_between_rules` | :x: | :white_check_mark: | -| `no_lead_zero` | :x: | :white_check_mark: | -| `predefinedConfig` | :white_check_mark: | :x: | -| `preserve_newlines` | :x: | :white_check_mark: | -| `wrap_line_length` | :x: | :white_check_mark: | +| Option | CSScomb | Prettier | Pretty Diff | +| --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `align_assignments` | :x: | :x: | :white_check_mark: | +| `configPath` | :white_check_mark: | :x: | :x: | +| `convert_quotes` | :x: | :x: | :white_check_mark: | +| `force_indentation` | :x: | :x: | :white_check_mark: | +| `indent_char` | :x: | :x: | :white_check_mark: | +| `indent_comments` | :x: | :x: | :white_check_mark: | +| `indent_size` | :x: | :x: | :white_check_mark: | +| `newline_between_rules` | :x: | :x: | :white_check_mark: | +| `no_lead_zero` | :x: | :x: | :white_check_mark: | +| `predefinedConfig` | :white_check_mark: | :x: | :x: | +| `preserve_newlines` | :x: | :x: | :white_check_mark: | +| `wrap_line_length` | :x: | :x: | :white_check_mark: | **Description**: @@ -7602,7 +7602,7 @@ Disable LESS Beautification **Type**: `string` -**Enum**: `CSScomb` `Pretty Diff` +**Enum**: `CSScomb` `Prettier` `Pretty Diff` **Description**: @@ -8036,16 +8036,16 @@ Override EOL from line-ending-selector (Supported by Lua beautifier) #### [Markdown](#markdown) -**Supported Beautifiers**: [`Remark`](#remark) [`Tidy Markdown`](#tidy-markdown) +**Supported Beautifiers**: [`Prettier`](#prettier) [`Remark`](#remark) [`Tidy Markdown`](#tidy-markdown) -| Option | Remark | Tidy Markdown | -| --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | -| `commonmark` | :white_check_mark: | :x: | -| `gfm` | :white_check_mark: | :x: | -| `yaml` | :white_check_mark: | :x: | +| Option | Prettier | Remark | Tidy Markdown | +| --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `commonmark` | :x: | :white_check_mark: | :x: | +| `gfm` | :x: | :white_check_mark: | :x: | +| `yaml` | :x: | :white_check_mark: | :x: | **Description**: @@ -8076,7 +8076,7 @@ Disable Markdown Beautification **Type**: `string` -**Enum**: `Remark` `Tidy Markdown` +**Enum**: `Prettier` `Remark` `Tidy Markdown` **Description**: @@ -11154,25 +11154,25 @@ Automatically beautify Sass files on save #### [SCSS](#scss) -**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Pretty Diff`](#pretty-diff) [`SassConvert`](#sassconvert) +**Supported Beautifiers**: [`CSScomb`](#csscomb) [`Prettier`](#prettier) [`Pretty Diff`](#pretty-diff) [`SassConvert`](#sassconvert) -| Option | CSScomb | Pretty Diff | SassConvert | -| --- | --- | --- | --- | -| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | -| `align_assignments` | :x: | :white_check_mark: | :x: | -| `configPath` | :white_check_mark: | :x: | :x: | -| `convert_quotes` | :x: | :white_check_mark: | :x: | -| `force_indentation` | :x: | :white_check_mark: | :x: | -| `indent_char` | :x: | :white_check_mark: | :x: | -| `indent_comments` | :x: | :white_check_mark: | :x: | -| `indent_size` | :x: | :white_check_mark: | :x: | -| `newline_between_rules` | :x: | :white_check_mark: | :x: | -| `no_lead_zero` | :x: | :white_check_mark: | :x: | -| `predefinedConfig` | :white_check_mark: | :x: | :x: | -| `preserve_newlines` | :x: | :white_check_mark: | :x: | -| `wrap_line_length` | :x: | :white_check_mark: | :x: | +| Option | CSScomb | Prettier | Pretty Diff | SassConvert | +| --- | --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `align_assignments` | :x: | :x: | :white_check_mark: | :x: | +| `configPath` | :white_check_mark: | :x: | :x: | :x: | +| `convert_quotes` | :x: | :x: | :white_check_mark: | :x: | +| `force_indentation` | :x: | :x: | :white_check_mark: | :x: | +| `indent_char` | :x: | :x: | :white_check_mark: | :x: | +| `indent_comments` | :x: | :x: | :white_check_mark: | :x: | +| `indent_size` | :x: | :x: | :white_check_mark: | :x: | +| `newline_between_rules` | :x: | :x: | :white_check_mark: | :x: | +| `no_lead_zero` | :x: | :x: | :white_check_mark: | :x: | +| `predefinedConfig` | :white_check_mark: | :x: | :x: | :x: | +| `preserve_newlines` | :x: | :x: | :white_check_mark: | :x: | +| `wrap_line_length` | :x: | :x: | :white_check_mark: | :x: | **Description**: @@ -11203,7 +11203,7 @@ Disable SCSS Beautification **Type**: `string` -**Enum**: `CSScomb` `Pretty Diff` `SassConvert` +**Enum**: `CSScomb` `Prettier` `Pretty Diff` `SassConvert` **Description**: @@ -14030,39 +14030,39 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff) #### [Vue](#vue) -**Supported Beautifiers**: [`Vue Beautifier`](#vue-beautifier) +**Supported Beautifiers**: [`Prettier`](#prettier) [`Vue Beautifier`](#vue-beautifier) -| Option | Vue Beautifier | -| --- | --- | -| `disabled` | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | -| `brace_style` | :white_check_mark: | -| `break_chained_methods` | :white_check_mark: | -| `end_of_line` | :white_check_mark: | -| `end_with_comma` | :white_check_mark: | -| `end_with_newline` | :white_check_mark: | -| `eval_code` | :white_check_mark: | -| `extra_liners` | :white_check_mark: | -| `indent_char` | :white_check_mark: | -| `indent_inner_html` | :white_check_mark: | -| `indent_level` | :white_check_mark: | -| `indent_scripts` | :white_check_mark: | -| `indent_size` | :white_check_mark: | -| `indent_with_tabs` | :white_check_mark: | -| `jslint_happy` | :white_check_mark: | -| `keep_array_indentation` | :white_check_mark: | -| `keep_function_indentation` | :white_check_mark: | -| `max_preserve_newlines` | :white_check_mark: | -| `preserve_newlines` | :white_check_mark: | -| `space_after_anon_function` | :white_check_mark: | -| `space_before_conditional` | :white_check_mark: | -| `space_in_paren` | :white_check_mark: | -| `unescape_strings` | :white_check_mark: | -| `unformatted` | :white_check_mark: | -| `wrap_attributes` | :white_check_mark: | -| `wrap_attributes_indent_size` | :white_check_mark: | -| `wrap_line_length` | :white_check_mark: | +| Option | Prettier | Vue Beautifier | +| --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | +| `brace_style` | :x: | :white_check_mark: | +| `break_chained_methods` | :x: | :white_check_mark: | +| `end_of_line` | :x: | :white_check_mark: | +| `end_with_comma` | :x: | :white_check_mark: | +| `end_with_newline` | :x: | :white_check_mark: | +| `eval_code` | :x: | :white_check_mark: | +| `extra_liners` | :x: | :white_check_mark: | +| `indent_char` | :x: | :white_check_mark: | +| `indent_inner_html` | :x: | :white_check_mark: | +| `indent_level` | :x: | :white_check_mark: | +| `indent_scripts` | :x: | :white_check_mark: | +| `indent_size` | :x: | :white_check_mark: | +| `indent_with_tabs` | :x: | :white_check_mark: | +| `jslint_happy` | :x: | :white_check_mark: | +| `keep_array_indentation` | :x: | :white_check_mark: | +| `keep_function_indentation` | :x: | :white_check_mark: | +| `max_preserve_newlines` | :x: | :white_check_mark: | +| `preserve_newlines` | :x: | :white_check_mark: | +| `space_after_anon_function` | :x: | :white_check_mark: | +| `space_before_conditional` | :x: | :white_check_mark: | +| `space_in_paren` | :x: | :white_check_mark: | +| `unescape_strings` | :x: | :white_check_mark: | +| `unformatted` | :x: | :white_check_mark: | +| `wrap_attributes` | :x: | :white_check_mark: | +| `wrap_attributes_indent_size` | :x: | :white_check_mark: | +| `wrap_line_length` | :x: | :white_check_mark: | **Description**: @@ -14093,7 +14093,7 @@ Disable Vue Beautification **Type**: `string` -**Enum**: `Vue Beautifier` +**Enum**: `Prettier` `Vue Beautifier` **Description**: diff --git a/package.json b/package.json index bdb74b1..d0d4d46 100644 --- a/package.json +++ b/package.json @@ -183,6 +183,7 @@ "node-dir": "0.1.17", "node-uuid": "1.4.8", "open": "0.0.5", + "prettier": "^1.10.2", "prettydiff2": "^2.2.7", "pug-beautify": "^0.1.1", "remark": "6.0.1", @@ -414,7 +415,8 @@ "goimports", "terraform", "terraformfmt", - "tsx" + "tsx", + "prettier" ], "devDependencies": { "coffeelint": "1.16.0" diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index cc3f237..3d57821 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -61,6 +61,7 @@ module.exports = class Beautifiers extends EventEmitter 'perltidy' 'php-cs-fixer' 'phpcbf' + 'prettier' 'prettydiff' 'pybeautifier' 'pug-beautify' diff --git a/src/beautifiers/prettier.coffee b/src/beautifiers/prettier.coffee new file mode 100644 index 0000000..e7fea61 --- /dev/null +++ b/src/beautifiers/prettier.coffee @@ -0,0 +1,38 @@ +"use strict" + +Beautifier = require('./beautifier') +prettier = require("prettier") + +module.exports = class Prettier extends Beautifier + name: "Prettier" + link: "https://github.com/prettier/prettier" + options: { + JavaScript: false + CSS: false + LESS: false + SCSS: false + Vue: false + JSON: false + Markdown: false + } + + beautify: (text, language, options) -> + return new @Promise((resolve, reject) -> + _ = require('lodash') + + prettierLanguage = _.find(prettier.getSupportInfo().languages, 'name': language) + if prettierLanguage + parser = prettierLanguage.parsers[0] + else + reject(new Error("Unknown language for Prettier")) + + try + result = prettier.format(text, { + tabWidth: options.indent_size, + useTabs: options.indent_with_tabs + parser + }); + resolve result + catch err + reject(err) + ) \ No newline at end of file diff --git a/src/options.json b/src/options.json index d545bd3..b5c0ec2 100644 --- a/src/options.json +++ b/src/options.json @@ -893,6 +893,7 @@ "beautifiers": [ "CSScomb", "JS Beautify", + "Prettier", "Pretty Diff", "SassConvert" ], @@ -1132,6 +1133,7 @@ "enum": [ "CSScomb", "JS Beautify", + "Prettier", "Pretty Diff", "SassConvert" ] @@ -3139,6 +3141,7 @@ "JS Beautify", "JSCS Fixer", "ESLint Fixer", + "Prettier", "Pretty Diff" ], "grammars": [ @@ -3467,6 +3470,7 @@ "JS Beautify", "JSCS Fixer", "ESLint Fixer", + "Prettier", "Pretty Diff" ] }, @@ -3486,6 +3490,7 @@ "collapsed": true, "beautifiers": [ "JS Beautify", + "Prettier", "Pretty Diff" ], "grammars": [ @@ -3812,6 +3817,7 @@ "description": "Default Beautifier to be used for JSON", "enum": [ "JS Beautify", + "Prettier", "Pretty Diff" ] }, @@ -4350,6 +4356,7 @@ "collapsed": true, "beautifiers": [ "CSScomb", + "Prettier", "Pretty Diff" ], "grammars": [ @@ -4554,6 +4561,7 @@ "description": "Default Beautifier to be used for LESS", "enum": [ "CSScomb", + "Prettier", "Pretty Diff" ] }, @@ -4633,6 +4641,7 @@ "description": "Options for language Markdown", "collapsed": true, "beautifiers": [ + "Prettier", "Remark", "Tidy Markdown" ], @@ -4700,6 +4709,7 @@ "default": "Tidy Markdown", "description": "Default Beautifier to be used for Markdown", "enum": [ + "Prettier", "Remark", "Tidy Markdown" ] @@ -6566,6 +6576,7 @@ "collapsed": true, "beautifiers": [ "CSScomb", + "Prettier", "Pretty Diff", "SassConvert" ], @@ -6771,6 +6782,7 @@ "description": "Default Beautifier to be used for SCSS", "enum": [ "CSScomb", + "Prettier", "Pretty Diff", "SassConvert" ] @@ -8068,6 +8080,7 @@ "description": "Options for language Vue", "collapsed": true, "beautifiers": [ + "Prettier", "Vue Beautifier" ], "grammars": [ @@ -8559,6 +8572,7 @@ "default": "Vue Beautifier", "description": "Default Beautifier to be used for Vue", "enum": [ + "Prettier", "Vue Beautifier" ] },