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

JSCS-Formatter

by TheSavior ALL

Sublime Text 3 Plugin to Autoformat with JSCS

Details

Installs

  • Total 53K
  • Win 32K
  • Mac 17K
  • Linux 5K
Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 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
Windows 0 2 0 1 0 1 4 2 2 1 0 0 2 3 2 0 3 2 0 2 3 1 0 1 0 1 1 1 1 1 0 1 0 2 0 1 1 3 0 2 1 0 1 0 2 1
Mac 0 1 2 0 0 0 4 1 3 3 0 0 1 0 1 3 1 0 0 1 1 1 2 2 0 0 2 2 1 3 1 1 1 1 1 2 6 2 0 1 2 1 2 0 2 1
Linux 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

SublimeJSCSFormatter for Sublime Text 3

Sublime Text 3 Plugin to autoformat your javascript code according to the JSCS configuration files you already have.

Installation

Linter installation

JSCS (with autoformatting) must be installed on your system before this plugin will work. To install jscs, do the following:

  1. Install Node.js (and npm on Linux).

  2. Install jscs by typing the following in a terminal:

npm install -g jscs
  1. If you are using nvm and zsh, ensure that the line to load nvm is in .zshenv and not .zshrc.

  2. If you are using zsh and oh-my-zsh, do not load the nvm plugin for oh-my-zsh.

Plugin installation

Please use Package Control to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here.

To install via Package Control, do the following:

  1. Within Sublime Text, bring up the Command Palette and type install. Among the commands you should see Package Control: Install Package. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins.

  2. When the plugin list appears, type jscs format. Among the entries you should see JSCSFormatter. If that entry is not highlighted, use the keyboard or mouse to select it.

Commands

Command palette:

  • JSCSFormatter: Format this file

Shortcut key:

  • Linux/Windows: [Ctrl + Shift + H]
  • Mac: [Cmd + Shift + H]

Settings

By default, JSCSFormatter will supply the following settings:

{
  // The Nodejs installation path
  "node_path": {
    "windows": "node.exe",
    "linux": "/usr/bin/nodejs",
    "osx": "/usr/local/bin/node"
  },

  // The location of the the globally installed jscs package
  "jscs_path": {
    "windows": "%APPDATA%/npm/node_modules/jscs/bin/jscs",
    "linux": "/usr/bin/jscs",
    "osx": "/usr/local/bin/jscs"
  },

  // Specify this path to a JSCS config file to override the default behavior.
  // Passed to JSCS as --config. Read more here:
  // http://jscs.info/overview.html#-config-
  "config_path": "",

  // Automatically format when a file is saved.
  "format_on_save": false,

  // Only attempt to format files with whitelisted extensions on save.
  // Leave empty to disable the check
  "format_on_save_extensions": [
    "js",
    "jsx",
    "es",
    "es6",
    "babel"
  ]
}
  • Modify any settings within the Preferences -> Package Settings -> JSCS Formatter -> Settings - User file.

Project-specific settings override

To override global plugin configuration for a specific project, add a settings object with a JSCS-Formatter key in your .sublime-project. This file is accessible via Project -> Edit Project.

For example:

{
  "folders": [
    {
      "path": "."
    }
  ],
  "settings": {
    "JSCS-Formatter": {
      "format_on_save": true
    }
  }
}

Setting up paths in Sublime with NVM

  1. Find path of Node and JSCS “ npm config get prefix
2. Return to Sublime
Modify the file at `Preferences > Package Settings > JSCS-Formatter > Settings-User`.
Update the `node_path` and `jscs_path` settings.

```javascript
{
  "node_path": {
    "linux": "/home/YOURUSER/.nvm/versions/node/v6.9.2/bin/node",
  },

  "jscs_path": {
    "linux": "/home/YOURUSER/.nvm/versions/node/v6.9.2/bin/jscs",
  },
}

Contributing

If you find any bugs feel free to report them here.

Pull requests are also encouraged.