This plugin will format JavaScript in Caret Editor.
A Caret Editor plug-in which allows for Pretty Print for JavaScript.
If you find any issues with the plug-in please open an issue at the GitHub page.
Note:
You will need to configure Caret to see the plugin as it will not automatically. The following will help you configure Caret
api.json
You'll need to add the following to your api.json file, under settings menu. This plugin can pass the same options that JS-Beautify does in the 'options' tag. I left the default 'sampleMessage' in there for the example. Note: the options in Pretty-JavaScript, these can be any of the options from JS Beautifier https://github.com/beautify-web/js-beautify as this plug-in uses it and is just a wrapper for it to work in Caret.
{
"sampleMessage": {
"id": "extension id goes here",
"message": {
"data": "message can be any JSON object passable to chrome.runtime.sendMessageExternal"
}
},
"Pretty-JavaScript": {
"id": "nfkohdggkammeogcdpmiebnlbcgpdcii",
"message": {
"options": {
"indent_size": 1,
"indent_char": "\t",
"max_preserve_newlines": 2,
"brace_style": "collapse",
"jslint_happy": true,
"wrap_line_length": 0
}
},
"sendEditorContext": true
}
}
key.json
You'll want to bind the command to the keyboard, you can select any shortcut combo that you want.
"Ctrl-Shift-H": {
"command": "api:execute",
"argument": "Pretty-JavaScript"
}
menus.json
This is optional, but allows the command to be accessible in menu system.
{
"label": "JavaScript Beautify",
"command": "api:execute",
"argument": "Pretty-JavaScript"
}
The following have contributed works
Without the following, this plug-in would not exist. Thanks to their works.
Caret :: https://github.com/thomaswilburn/Caret
JS-Beautify :: https://github.com/beautify-web/js-beautify
Latest reviews
- (2020-09-24) Rico Trevisan: Excellent! (it might be worthwhile to add a picture to the plugin with the instructions or an arrow pointing down to how to install it. I lost waaaay too much time not rtfm...)
- (2018-07-01) Kevin Griffin: This is a nice extension to Caret.
- (2018-05-05) LotsOfBitts: I can't get it to work, no matter how hard I try
- (2018-01-26) Anthony Bakopoulos: how do you make a game? and why does it not look the same as on youtube!?
- (2017-09-27) Tom Proffitt: It's good for html
Statistics
Installs
533
history
Category
Rating
4.2 (5 votes)
Last update / version
2019-03-08 / 1.0.1
Listing languages