Giter Site home page Giter Site logo

sublimejscsformatter's Introduction

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
    
  3. If you are using nvm and zsh, ensure that the line to load nvm is in .zshenv and not .zshrc.

  4. 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
}
  • 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
    }
  }
}

Contributing

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

Pull requests are also encouraged.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.