Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d6edf0c
expand user in node.js path
jasonbrazeal Sep 28, 2018
90768ae
Merge branch 'jsonbrazeal-expand-user'
victorporof Sep 30, 2018
9c36075
Make vue formatting supported by default
victorporof Sep 30, 2018
69d6139
Fix some typos
victorporof Sep 30, 2018
2ee087b
Update all packages, fix linting errors
victorporof Sep 30, 2018
2bab4a9
Update node_modules and build
victorporof Sep 30, 2018
1afa2b0
2.2.0
victorporof Sep 30, 2018
330eb65
Make jsx formatting supported by default
victorporof Sep 30, 2018
73eea81
Add a way of making a realease without any code changes
victorporof Sep 30, 2018
a0c0da1
2.2.1
victorporof Sep 30, 2018
92725bf
Fix glob typo in default eslint settings
victorporof Sep 30, 2018
982ca88
2.2.2
victorporof Sep 30, 2018
39e154b
Log process versions
victorporof Oct 2, 2018
828a50e
Don't just transpile, also polyfill new APIs for older node versions
victorporof Oct 2, 2018
fa9a2a1
Update node_modules and build
victorporof Oct 2, 2018
841261b
2.2.3
victorporof Oct 2, 2018
3701eeb
Update package.json
roblav96 Oct 2, 2018
8314602
Merge pull request #629 from roblav96/patch-1
victorporof Oct 2, 2018
49482ab
Update node_modules and build
victorporof Oct 2, 2018
1ca464a
2.2.4
victorporof Oct 2, 2018
2de54c4
Add core-js as a dependency to the root package.json
victorporof Oct 2, 2018
efa3076
Update node_modules and build
victorporof Oct 2, 2018
893e5bf
2.2.5
victorporof Oct 2, 2018
db59fb5
Update jsbeautify to latest version
victorporof Oct 26, 2018
18b8791
Update node_modules and build
victorporof Oct 26, 2018
a53b334
2.2.6
victorporof Oct 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
15 changes: 11 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
{
"presets": ["es2015"],
"presets": [
[
"@babel/env",
{
"useBuiltIns": "usage"
}
]
],
"plugins": [
"transform-runtime",
"transform-object-rest-spread",
"transform-async-to-generator"
"@babel/transform-runtime",
"@babel/syntax-object-rest-spread",
"@babel/transform-async-to-generator"
]
}
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node 0
13 changes: 7 additions & 6 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"parser": "babel-eslint",

"extends": [
"airbnb-base"
],

"rules": {
"max-len": ["error", {
"code": 120,
"ignoreUrls": true
}],
"max-len": [
"error",
{
"code": 150,
"ignoreUrls": true
}
],
"no-restricted-syntax": "off",
"no-console": "off"
}
Expand Down
37 changes: 22 additions & 15 deletions .jsbeautifyrc.defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

"all":
{
// These rules apply to all HTML, CSS, JS and JSON files to be prettified
// These rules apply to any supported code that is going to be be prettified,
// and have the lowest level of precedence (meaning any of the settings in
// the 'html', 'css', 'js', 'json' and 'custom' categories override these).

Expand Down Expand Up @@ -45,8 +45,9 @@

"html":
{
// Rules added here apply only to HTML files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to HTML-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -65,8 +66,9 @@

"css":
{
// Rules added here apply only to CSS files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to CSS-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -82,8 +84,9 @@

"js":
{
// Rules added here apply only to JS files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to JS-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -97,7 +100,7 @@
"comma_first": false,

// Pass E4X xml literals through untouched
"e4x": false,
"e4x": true,

// If true, then jslint-stricter mode is enforced
"jslint_happy": false,
Expand Down Expand Up @@ -129,8 +132,9 @@

"json":
{
// Rules added here apply only to JSON files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to JSON-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -146,12 +150,15 @@

"custom":
{
// Rules added here apply only to some files matching specific glob strings.
// Rules added here apply only to files matching specific glob strings,
// but respecting any whitelists or blacklists as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over any of the settings in the categories above.

// For the following entries, keys are globs and values are objects which
// can contain any kind of .jsbeautifyrc setting. They take precedence over
// all of the above settings.
// can contain any kind of .jsbeautifyrc setting.

"package?(-lock).json":
"@(package?(-lock)|yarn-lock).json":
{
"indent_size": 2,
"brace_style": "collapse"
Expand All @@ -163,4 +170,4 @@
"brace_style": "expand"
}
}
}
}
26 changes: 13 additions & 13 deletions HTMLPrettify.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -31,35 +31,35 @@
"save_to_temp_file_before_prettifying": true,

// Settings determining which files are allowed to be prettified.
// All the keys below need to be included in your user settings for them to work.
// !!! All the keys below need to be included in your user settings for them to work. !!!
"global_file_rules":
{
// Be sure to include the `html` key in your user settings to be able
// to prettify html files.
// Be sure to include all of the `html`, `css`, `js` and `json` keys in your user settings
// if you want to be able to prettify the default files as well.
"html":
{
"allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg"],
"allowed_file_syntaxes": ["html", "xml"],
"allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg", "vue"],
"allowed_file_syntaxes": ["html", "xml", "vue"],
"disallowed_file_patterns": []
},
// Be sure to include the `css` key in your user settings to be able
// to prettify css files.
// Be sure to include all of the `html`, `css`, `js` and `json` keys in your user settings
// if you want to be able to prettify the default files as well.
"css":
{
"allowed_file_extensions": ["css", "scss", "sass", "less"],
"allowed_file_syntaxes": ["css", "sass", "less"],
"disallowed_file_patterns": []
},
// Be sure to include the `js` key in your user settings to be able
// to prettify js files.
// Be sure to include all of the `html`, `css`, `js` and `json` keys in your user settings
// if you want to be able to prettify the default files as well.
"js":
{
"allowed_file_extensions": ["js"],
"allowed_file_syntaxes": ["javascript", "ecma"],
"allowed_file_extensions": ["js", "jsx"],
"allowed_file_syntaxes": ["javascript", "ecma", "react", "babel"],
"disallowed_file_patterns": []
},
// Be sure to include the `json` key in your user settings to be able
// to prettify json files.
// Be sure to include all of the `html`, `css`, `js` and `json` keys in your user settings
// if you want to be able to prettify the default files as well.
"json":
{
"allowed_file_extensions": [
Expand Down
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# HTML, CSS, JavaScript and JSON code formatter for Sublime Text 2 and 3 via node.js
# HTML, CSS, JavaScript, JSON, React and Vue code formatter for Sublime Text 2 and 3 via node.js
#### [Sublime Text 3](http://www.sublimetext.com/3)
#### [JS-beautify](https://github.com/einars/js-beautify)
#### [Node.js download](http://nodejs.org/#download)

## About
This is a Sublime Text 2 and 3 plugin allowing you to format your HTML, CSS, JavaScript and JSON code. It uses a set of nice beautifier scripts made by Einar Lielmanis. The formatters are written in JavaScript, so you'll need something (node.js) to interpret JavaScript code outside the browser.
This is a Sublime Text 2 and 3 plugin allowing you to format your HTML, CSS, JavaScript, JSON, React and Vue code. It uses a set of nice beautifier scripts made by Einar Lielmanis. The formatters are written in JavaScript, so you'll need something (node.js) to interpret JavaScript code outside the browser.

This will work with either HTML, CSS, JavaScript and JSON files.
This will work with either HTML, CSS, JavaScript, JSON, React and Vue files.

## Installation
First of all, be sure you have [node.js](http://nodejs.org/#download) installed in order to run the beautifier. After you've installed node.js, you will need to setup this plugin.
Expand Down Expand Up @@ -47,7 +47,7 @@ Right click in the current buffer and select `HTML/CSS/JS Prettify` -> `Prettify

-- or --

Open a HTML, CSS or JavaScript file, pop out the console in Sublime Text from View -> Show Console, and type `view.run_command("htmlprettify")`.
Open a HTML, CSS, JavaScript, JSON, React or Vue file, pop out the console in Sublime Text from View -> Show Console, and type `view.run_command("htmlprettify")`.

Writing commands in the console is ugly. Set up your own key combo for this, by going to Preferences -> Key Bindings - User, and adding a command in that array: `{ "keys": ["super+shift+h"], "command": "htmlprettify" }`. You can use any other command you want, thought most of them are already taken.

Expand All @@ -66,6 +66,12 @@ On Windows, the absolute path to node.exe *must* use forward slashes. Must inclu
### Be very careful on Linux!
Depending on your distribution and default package sources, `apt-get install node` (for example) *will not* install node.js, contrary to all human common sense and popular belief. You want `nodejs` instead. Best thing is to make it yourself from http://nodejs.org/#download.

## Beautify Vue
To properly beautify Vue files, make sure the file syntax is recongnized by Sublime as either HTML, XML or Vue.

## Beautify JSX
To properly beautify JSX files, make sure the file syntax is recongnized by Sublime as JavaScript and that `e4x` is `true` in your `.jsbeautifyrc`.

## Beautify on Save
To beautify your code when saving the document, set the `format_on_save` setting to `true` in `HTMLPrettify.sublime-settings`:

Expand Down Expand Up @@ -196,7 +202,7 @@ When one is found, it stops searching, and it uses those options along with the

"all":
{
// These rules apply to all HTML, CSS, JS and JSON files to be prettified
// These rules apply to any supported code that is going to be be prettified,
// and have the lowest level of precedence (meaning any of the settings in
// the 'html', 'css', 'js', 'json' and 'custom' categories override these).

Expand Down Expand Up @@ -232,8 +238,9 @@ When one is found, it stops searching, and it uses those options along with the

"html":
{
// Rules added here apply only to HTML files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to HTML-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -252,8 +259,9 @@ When one is found, it stops searching, and it uses those options along with the

"css":
{
// Rules added here apply only to CSS files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to CSS-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -269,8 +277,9 @@ When one is found, it stops searching, and it uses those options along with the

"js":
{
// Rules added here apply only to JS files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to JS-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand Down Expand Up @@ -316,8 +325,9 @@ When one is found, it stops searching, and it uses those options along with the

"json":
{
// Rules added here apply only to JSON files. They take precedence over all
// of the settings in the 'all' category above.
// Rules added here apply only to JSON-like files, as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over all of the settings in the 'all' category above.

// You can add other .jsbeautifyrc rules in this section too.

Expand All @@ -333,10 +343,13 @@ When one is found, it stops searching, and it uses those options along with the

"custom":
{
// Rules added here apply only to some files matching specific glob strings.
// Rules added here apply only to files matching specific glob strings,
// but respecting any whitelists or blacklists as determined by the
// rules specified for `global_file_rules` in the plugin settings. They
// take precedence over any of the settings in the categories above.

// For the following entries, keys are globs and values are objects which
// can contain any kind of .jsbeautifyrc setting. They take precedence over
// all of the above settings.
// can contain any kind of .jsbeautifyrc setting.

"package?(-lock).json":
{
Expand Down
Loading