ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Js​Format

by jdavisclark ALL Top 100

Javascript formatting for Sublime Text 2 & 3

Details

  • 2022.04.05.07.25.38
  • github.​com
  • github.​com
  • 3 years ago
  • 1 month ago
  • 13 years ago

Installs

  • Total 897K
  • Win 555K
  • Mac 244K
  • Linux 97K
Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9
Windows 12 25 42 12 14 37 35 46 32 29 12 21 38 33 38 39 44 11 14 29 33 30 36 38 12 17 26 32 36 41 34 15 14 31 41 27 36 35 19 14 21 23 31 48 33 11
Mac 18 56 39 12 9 54 42 60 49 51 14 15 42 44 58 50 33 18 15 36 62 56 56 42 12 18 40 56 62 43 60 13 10 52 49 68 42 43 18 17 49 53 56 49 58 14
Linux 3 7 12 1 4 6 16 9 9 9 3 4 7 11 8 14 6 2 5 5 10 7 16 7 3 3 6 6 8 8 12 5 3 6 14 12 6 13 6 7 13 16 14 13 9 4
050100Mar 26Mar 23Mar 20Mar 17Mar 14Mar 11Mar 8Mar 5Mar 2Feb 27Feb 24Feb 21Feb 18Feb 15Feb 12Feb 9Mar 26 Linux: 3 Mac: 18 Windows: 12Mar 25 Linux: 7 Mac: 56 Windows: 25Mar 24 Linux: 12 Mac: 39 Windows: 42Mar 23 Linux: 1 Mac: 12 Windows: 12Mar 22 Linux: 4 Mac: 9 Windows: 14Mar 21 Linux: 6 Mac: 54 Windows: 37Mar 20 Linux: 16 Mac: 42 Windows: 35Mar 19 Linux: 9 Mac: 60 Windows: 46Mar 18 Linux: 9 Mac: 49 Windows: 32Mar 17 Linux: 9 Mac: 51 Windows: 29Mar 16 Linux: 3 Mac: 14 Windows: 12Mar 15 Linux: 4 Mac: 15 Windows: 21Mar 14 Linux: 7 Mac: 42 Windows: 38Mar 13 Linux: 11 Mac: 44 Windows: 33Mar 12 Linux: 8 Mac: 58 Windows: 38Mar 11 Linux: 14 Mac: 50 Windows: 39Mar 10 Linux: 6 Mac: 33 Windows: 44Mar 9 Linux: 2 Mac: 18 Windows: 11Mar 8 Linux: 5 Mac: 15 Windows: 14Mar 7 Linux: 5 Mac: 36 Windows: 29Mar 6 Linux: 10 Mac: 62 Windows: 33Mar 5 Linux: 7 Mac: 56 Windows: 30Mar 4 Linux: 16 Mac: 56 Windows: 36Mar 3 Linux: 7 Mac: 42 Windows: 38Mar 2 Linux: 3 Mac: 12 Windows: 12Mar 1 Linux: 3 Mac: 18 Windows: 17Feb 28 Linux: 6 Mac: 40 Windows: 26Feb 27 Linux: 6 Mac: 56 Windows: 32Feb 26 Linux: 8 Mac: 62 Windows: 36Feb 25 Linux: 8 Mac: 43 Windows: 41Feb 24 Linux: 12 Mac: 60 Windows: 34Feb 23 Linux: 5 Mac: 13 Windows: 15Feb 22 Linux: 3 Mac: 10 Windows: 14Feb 21 Linux: 6 Mac: 52 Windows: 31Feb 20 Linux: 14 Mac: 49 Windows: 41Feb 19 Linux: 12 Mac: 68 Windows: 27Feb 18 Linux: 6 Mac: 42 Windows: 36Feb 17 Linux: 13 Mac: 43 Windows: 35Feb 16 Linux: 6 Mac: 18 Windows: 19Feb 15 Linux: 7 Mac: 17 Windows: 14Feb 14 Linux: 13 Mac: 49 Windows: 21Feb 13 Linux: 16 Mac: 53 Windows: 23Feb 12 Linux: 14 Mac: 56 Windows: 31Feb 11 Linux: 13 Mac: 49 Windows: 48Feb 10 Linux: 9 Mac: 58 Windows: 33Feb 9 Linux: 4 Mac: 14 Windows: 11Mar 26 Linux: 3 Mac: 18 Windows: 12Mar 25 Linux: 7 Mac: 56 Windows: 25Mar 24 Linux: 12 Mac: 39 Windows: 42Mar 23 Linux: 1 Mac: 12 Windows: 12Mar 22 Linux: 4 Mac: 9 Windows: 14Mar 21 Linux: 6 Mac: 54 Windows: 37Mar 20 Linux: 16 Mac: 42 Windows: 35Mar 19 Linux: 9 Mac: 60 Windows: 46Mar 18 Linux: 9 Mac: 49 Windows: 32Mar 17 Linux: 9 Mac: 51 Windows: 29Mar 16 Linux: 3 Mac: 14 Windows: 12Mar 15 Linux: 4 Mac: 15 Windows: 21Mar 14 Linux: 7 Mac: 42 Windows: 38Mar 13 Linux: 11 Mac: 44 Windows: 33Mar 12 Linux: 8 Mac: 58 Windows: 38Mar 11 Linux: 14 Mac: 50 Windows: 39Mar 10 Linux: 6 Mac: 33 Windows: 44Mar 9 Linux: 2 Mac: 18 Windows: 11Mar 8 Linux: 5 Mac: 15 Windows: 14Mar 7 Linux: 5 Mac: 36 Windows: 29Mar 6 Linux: 10 Mac: 62 Windows: 33Mar 5 Linux: 7 Mac: 56 Windows: 30Mar 4 Linux: 16 Mac: 56 Windows: 36Mar 3 Linux: 7 Mac: 42 Windows: 38Mar 2 Linux: 3 Mac: 12 Windows: 12Mar 1 Linux: 3 Mac: 18 Windows: 17Feb 28 Linux: 6 Mac: 40 Windows: 26Feb 27 Linux: 6 Mac: 56 Windows: 32Feb 26 Linux: 8 Mac: 62 Windows: 36Feb 25 Linux: 8 Mac: 43 Windows: 41Feb 24 Linux: 12 Mac: 60 Windows: 34Feb 23 Linux: 5 Mac: 13 Windows: 15Feb 22 Linux: 3 Mac: 10 Windows: 14Feb 21 Linux: 6 Mac: 52 Windows: 31Feb 20 Linux: 14 Mac: 49 Windows: 41Feb 19 Linux: 12 Mac: 68 Windows: 27Feb 18 Linux: 6 Mac: 42 Windows: 36Feb 17 Linux: 13 Mac: 43 Windows: 35Feb 16 Linux: 6 Mac: 18 Windows: 19Feb 15 Linux: 7 Mac: 17 Windows: 14Feb 14 Linux: 13 Mac: 49 Windows: 21Feb 13 Linux: 16 Mac: 53 Windows: 23Feb 12 Linux: 14 Mac: 56 Windows: 31Feb 11 Linux: 13 Mac: 49 Windows: 48Feb 10 Linux: 9 Mac: 58 Windows: 33Feb 9 Linux: 4 Mac: 14 Windows: 11Mar 26 Linux: 3 Mac: 18 Windows: 12Mar 25 Linux: 7 Mac: 56 Windows: 25Mar 24 Linux: 12 Mac: 39 Windows: 42Mar 23 Linux: 1 Mac: 12 Windows: 12Mar 22 Linux: 4 Mac: 9 Windows: 14Mar 21 Linux: 6 Mac: 54 Windows: 37Mar 20 Linux: 16 Mac: 42 Windows: 35Mar 19 Linux: 9 Mac: 60 Windows: 46Mar 18 Linux: 9 Mac: 49 Windows: 32Mar 17 Linux: 9 Mac: 51 Windows: 29Mar 16 Linux: 3 Mac: 14 Windows: 12Mar 15 Linux: 4 Mac: 15 Windows: 21Mar 14 Linux: 7 Mac: 42 Windows: 38Mar 13 Linux: 11 Mac: 44 Windows: 33Mar 12 Linux: 8 Mac: 58 Windows: 38Mar 11 Linux: 14 Mac: 50 Windows: 39Mar 10 Linux: 6 Mac: 33 Windows: 44Mar 9 Linux: 2 Mac: 18 Windows: 11Mar 8 Linux: 5 Mac: 15 Windows: 14Mar 7 Linux: 5 Mac: 36 Windows: 29Mar 6 Linux: 10 Mac: 62 Windows: 33Mar 5 Linux: 7 Mac: 56 Windows: 30Mar 4 Linux: 16 Mac: 56 Windows: 36Mar 3 Linux: 7 Mac: 42 Windows: 38Mar 2 Linux: 3 Mac: 12 Windows: 12Mar 1 Linux: 3 Mac: 18 Windows: 17Feb 28 Linux: 6 Mac: 40 Windows: 26Feb 27 Linux: 6 Mac: 56 Windows: 32Feb 26 Linux: 8 Mac: 62 Windows: 36Feb 25 Linux: 8 Mac: 43 Windows: 41Feb 24 Linux: 12 Mac: 60 Windows: 34Feb 23 Linux: 5 Mac: 13 Windows: 15Feb 22 Linux: 3 Mac: 10 Windows: 14Feb 21 Linux: 6 Mac: 52 Windows: 31Feb 20 Linux: 14 Mac: 49 Windows: 41Feb 19 Linux: 12 Mac: 68 Windows: 27Feb 18 Linux: 6 Mac: 42 Windows: 36Feb 17 Linux: 13 Mac: 43 Windows: 35Feb 16 Linux: 6 Mac: 18 Windows: 19Feb 15 Linux: 7 Mac: 17 Windows: 14Feb 14 Linux: 13 Mac: 49 Windows: 21Feb 13 Linux: 16 Mac: 53 Windows: 23Feb 12 Linux: 14 Mac: 56 Windows: 31Feb 11 Linux: 13 Mac: 49 Windows: 48Feb 10 Linux: 9 Mac: 58 Windows: 33Feb 9 Linux: 4 Mac: 14 Windows: 11

Readme

Source
raw.​githubusercontent.​com

FOSSA Status

LOOKING FOR AN ADDITIONAL MAINTAINER

I haven't been giving JsFormat the attention it deserves lately, and I'd like to bring on someone else to help maintain the project. Shoot me an email if you are interested.

About the project

JsFormat is a javascript formatting plugin for Sublime Text 2. It uses jsbeautifier to format whole js or json files, or the selected portion(s).

Features

  • javascript/json formatting (obviously)
  • all settings are customizable (whitespace, formatting style, etc..)
  • .jsbeautifyrc settings files support for even more control on a per-project basis
  • puts the cursor back in the same location it was before formatting (accounts for whitespace/newline changes)
  • Sublime Text 3 support

Settings

JsFormat uses whatever tab/indent settings are configured with the standard translate_tabs_to_spaces and tab_size sublime settings.

The following JsBeautifier settings are available in JsFormat/JsFormat.sublime-settings (defaults shown below). Check out the official jsbeautifier documentation for more details on the options:

  • indent_with_tabs: false
  • max_preserve_newlines: 4
  • preserve_newlines: true
  • space_in_paren: false
  • jslint_happy: false
  • brace_style: “collapse”
  • keep_array_indentation: false
  • keep_function_indentation: false
  • eval_code: false,
  • unescape_strings: false,
  • break_chained_methods: false*
  • e4x: false
  • wrap_line_length: 0
  • space_after_anon_function: false

The following JsFormat specific settings are also exposed:

I had temporary lapse of judgment a while back and merged a pull request that modified jsbeautifier. As a result, the functionality that was added from that pull request has been lost; "ensure_space_before_linestarters" is no longer supported.

The JsFormat specific ensure_newline_at_eof_on_save setting has also been removed. This functionality exists in sublime core.

jsbeautifyrc files

JsFormat now supports .jsbeautifyrc JSON files (disabled by default), which themselves support any of the exposed JsBeautifier options. The option augmentation order is: default options -> user settings -> .jsbeautifyrc option files.

A hierarchy of .jsbeautifyrc files is supported, where rc files at the deeper levels override the settings from rc files at higher levels. For example, given the file structure listed below, formatting /home/you/myProject/app.js would inherit settings from: default -> user settings -> /home/you/myProject/.jsbeautifyrc, while formatting /home/you/myProject/tests/test.js would inherit settings from: default -> user settings -> /home/you/myProject/.jsbeautifyrc -> /home/you/myProject/tests/.jsbeautifyrc

  • /home/you/myProject/.jsbeautifyrc
  • /home/you/myProject/app.js
  • /home/you/myProject/tests/.jsbeautifyrc
  • /home/you/myProject/tests/test.js

Installation

Package Control (Recommended)

JsFormat is now included in the default repository channel for Package Control. It should show up in your install list with no changes.

If it does not show up, or you are on an older version of Package Control, add https://github.com/jdavisclark/JsFormat as a Package Control repository. JsFormat will show up in the package install list.

Git Clone

Clone this repository in to the Sublime Text 2 “Packages” directory, which is located where ever the “Preferences” -> “Browse Packages” option in sublime takes you.

Key Bindings

The default key binding is “ctrl+alt+f”

Key Binding Conflicts

Unfortunately there are other plugins that use “ctrl + alt + f”, this is a hard problem to solve. If JsFormat works OK via the command palette but does nothing when you use the “ctrl + alt + f” shortcut, you have two options:

  1. Add { "keys": ["ctrl+alt+f"], "command": "js_format", "context": [{"key": "selector", "operator": "equal", "operand": "source.js,source.json"}] } to your user keybindings file. This will override anything specified by a plugin.
  2. Find the offending plugin, and change the shortcut in its sublime-keymap file (will revert on updates)

Command Palette

Open the command palette via “ctrl + shift + p”, Jsformat appears as “Format: Javascript”


License

Copyright © 2012 Davis Clark

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

FOSSA Status