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
Extore is a team of professionals who are passionate about creating extensions for web browsers. This devotion also gives us opportunity to appreciate work of other people. We get inspired by useful, open source extensions made by developers all over the world. Our strong belief is that one should share helpful add-ons with others. That’s why we’d like to present you our ever-growing list of favourite extensions that have inspired us. Moreover, as you probably have already learned, sometimes struggling for the best brings an end to the good. Talking about add-ons it often turns out that an upgrade is worse then previous version. Also it can become really tricky to get back to the beloved version of your favourite extension. That’s why we’re going to make not only the latest, but all versions of our favourite (and we hope yours too) add-ons available for download. No more compromises, just stick to the version you really like!