Skip to content

Commit 330eb65

Browse files
committed
Make jsx formatting supported by default
Signed-off-by: Victor Porof <[email protected]>
1 parent 1afa2b0 commit 330eb65

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.jsbeautifyrc.defaults.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
"comma_first": false,
101101

102102
// Pass E4X xml literals through untouched
103-
"e4x": false,
103+
"e4x": true,
104104

105105
// If true, then jslint-stricter mode is enforced
106106
"jslint_happy": false,

HTMLPrettify.sublime-settings

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
// if you want to be able to prettify the default files as well.
5555
"js":
5656
{
57-
"allowed_file_extensions": ["js"],
58-
"allowed_file_syntaxes": ["javascript", "ecma"],
57+
"allowed_file_extensions": ["js", "jsx"],
58+
"allowed_file_syntaxes": ["javascript", "ecma", "react", "babel"],
5959
"disallowed_file_patterns": []
6060
},
6161
// Be sure to include all of the `html`, `css`, `js` and `json` keys in your user settings

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# HTML, CSS, JavaScript, JSON and Vue code formatter for Sublime Text 2 and 3 via node.js
1+
# HTML, CSS, JavaScript, JSON, React and Vue code formatter for Sublime Text 2 and 3 via node.js
22
#### [Sublime Text 3](http://www.sublimetext.com/3)
33
#### [JS-beautify](https://github.com/einars/js-beautify)
44
#### [Node.js download](http://nodejs.org/#download)
55

66
## About
7-
This is a Sublime Text 2 and 3 plugin allowing you to format your HTML, CSS, JavaScript, JSON 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.
7+
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.
88

9-
This will work with either HTML, CSS, JavaScript, JSON and Vue files.
9+
This will work with either HTML, CSS, JavaScript, JSON, React and Vue files.
1010

1111
## Installation
1212
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.
@@ -47,7 +47,7 @@ Right click in the current buffer and select `HTML/CSS/JS Prettify` -> `Prettify
4747

4848
-- or --
4949

50-
Open a HTML, CSS, JavaScript, JSON or Vue file, pop out the console in Sublime Text from View -> Show Console, and type `view.run_command("htmlprettify")`.
50+
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")`.
5151

5252
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.
5353

@@ -66,6 +66,12 @@ On Windows, the absolute path to node.exe *must* use forward slashes. Must inclu
6666
### Be very careful on Linux!
6767
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.
6868

69+
## Beautify Vue
70+
To properly beautify Vue files, make sure the file syntax is recongnized by Sublime as either HTML, XML or Vue.
71+
72+
## Beautify JSX
73+
To properly beautify JSX files, make sure the file syntax is recongnized by Sublime as JavaScript and that `e4x` is `true` in your `.jsbeautifyrc`.
74+
6975
## Beautify on Save
7076
To beautify your code when saving the document, set the `format_on_save` setting to `true` in `HTMLPrettify.sublime-settings`:
7177

0 commit comments

Comments
 (0)