GithubHelp home page GithubHelp logo

isabella232 / sublime-jsfmt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from automattic/sublime-jsfmt

0.0 0.0 0.0 2.77 MB

jsfmt plugin for Sublime Text

License: MIT License

JavaScript 45.14% Python 54.86%

sublime-jsfmt's Introduction

jsfmt for Sublime Text 2/3

If you want your javascript automatically formatted to abide a particular style, then jsfmt is for you. No need to read warnings and fix things yourself. Just keep it all auto. Boom boom jsfmt is pretty tight. And yeah, if you want it in Sublime Text this is your homeboy.

Enable autoformat then save the file and it gets formatted.

Installation

## go to your ST packages folder. maybe something like …
cd ~/Library/"Application Support/Sublime Text 3"/Packages

# clone this repo
git clone https://github.com/Automattic/sublime-jsfmt jsfmt

On windows open cmd and:

cd %APPDATA%\"Sublime Text 3"\Packages
git clone https://github.com/Automattic/sublime-jsfmt jsfmt

Plugins included

Settings

{
    // autoformat on save
    "autoformat": false,

    // array of extensions for autoformat
    "extensions": ["js", "sublime-settings"],

    // options for jsfmt
    "options": {
        "preset": "jquery",
        "indent": {
            "value": "    "
        },
        // plugins included
        "plugins": [
            // "esformatter-quotes",
            // "esformatter-semicolons",
            // "esformatter-braces",
            // "esformatter-dot-notation"
        ]
    },
    "options-JSON": {
        "plugins": [
            "esformatter-quotes"
        ],
        "quotes": {
            "type": "double"
        }
    },
    "alert-errors": true,
    // path to nodejs
    "node-path": "node"
}

Commands

Command palette:

  • JSFMT: Format the current file
  • JSFMT: Toggle autoformat
  • JSFMT: Settings - Default
  • JSFMT: Settings - User

Menu:
Preferences -> Package Settings -> Sublime JSFMT

Formatting rules

You can set global rules via a .jsfmtrc. Be crazy and establish one for all your projects in ~/.jsfmtrc. (like in dotfiles)

Otherwise you're probably pretty levelheaded and will probably provide one in your project root. It'll be read and applied.

Rules you can intuit from these esformatter preset files.

There's a .jsfmtrc-sample in this repo. It's a good start. Rename it and toss it somewhere. Try it out.

Installing plugins

If you want to use a plugin that is not installed by default you will need to follow the next steps:

  1. Go to the packages folder (Preferences -> Browse Packages)
  2. cd into the jsfmt folder.
  3. Install the plugins you need.
  4. Go to your jsfmt settings file and add the name of the plugin in the plugins array.

Compatibility

Should work in both ST2 and ST3.

Contributing

If you find any bugs feel free to report them here
Pull requests are also encouraged.

sublime-jsfmt's People

Contributors

akirk avatar arthurvr avatar blowery avatar mihai-vlc avatar paulirish avatar

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.