JSPM

  • Created
  • Published
  • Downloads 1004507
  • Score
    100M100P100Q196636F
  • License MIT

JavaScript Standard Style

Package Exports

  • standard
  • standard/bin/cmd
  • standard/bin/cmd.js
  • standard/package.json

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (standard) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

standard travis npm downloads

JavaScript Standard Style

Rules

  • No semicolons (it's finereally!)
  • Indentation is 2 spaces
  • Strings use single quotes
  • Unix-style line breaks (LF)
  • Spaces after keywords:
    • if (condition) { ... }
  • Spaces before/after function definitions:, like this:
    • function name (arg1, arg2) { ... }
  • Always name the context variable self:
    • var self = this

To get a better idea, take a look at a sample file.

install

npm install standard

usage

The easiest way to use standard is to install it globally as a Node command line program. To do so, simply run the following command in your terminal (flag -g installs standard globally on your system, omit it if you want to install in the current working directory):

npm install standard -g

After you've done that you should be able to use the standard program. The simplest use case would be checking the style of all JavaScript files in the current working directory:

$ standard
Error: Code style check failed:
  /Users/feross/code/webtorrent/lib/torrent.js:950:11: Expected '===' and instead saw '=='.

what you might do if you're clever

  1. Add it to package.json
{
  "name": "my-cool-package",
  "devDependencies": {
    "standard": "*"
  },
  "scripts": {
    "test": "standard && node my-normal-tests.js"
  }
}
  1. Check style automatically when you run npm test
$ npm test
Error: Code style check failed:
  /Users/feross/code/webtorrent/lib/torrent.js:950:11: Expected '===' and instead saw '=='.
  1. Never give style feedback on a pull request again!

license

MIT. Copyright (c) Feross Aboukhadijeh.