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

Standard​Snippets

by vkhitev ALL

JavaScript Standard Style snippets for Sublime Text

Details

Installs

  • Total 1K
  • Win 746
  • Mac 463
  • Linux 270
Aug 15 Aug 14 Aug 13 Aug 12 Aug 11 Aug 10 Aug 9 Aug 8 Aug 7 Aug 6 Aug 5 Aug 4 Aug 3 Aug 2 Aug 1 Jul 31 Jul 30 Jul 29 Jul 28 Jul 27 Jul 26 Jul 25 Jul 24 Jul 23 Jul 22 Jul 21 Jul 20 Jul 19 Jul 18 Jul 17 Jul 16 Jul 15 Jul 14 Jul 13 Jul 12 Jul 11 Jul 10 Jul 9 Jul 8 Jul 7 Jul 6 Jul 5 Jul 4 Jul 3 Jul 2
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
01234Aug 15Aug 12Aug 9Aug 6Aug 3Jul 31Jul 28Jul 25Jul 22Jul 19Jul 16Jul 13Jul 10Jul 7Jul 4Aug 15 Linux: 0 Mac: 0 Windows: 0Aug 14 Linux: 0 Mac: 0 Windows: 0Aug 13 Linux: 0 Mac: 0 Windows: 0Aug 12 Linux: 0 Mac: 0 Windows: 0Aug 11 Linux: 0 Mac: 0 Windows: 0Aug 10 Linux: 0 Mac: 0 Windows: 0Aug 9 Linux: 0 Mac: 0 Windows: 0Aug 8 Linux: 0 Mac: 0 Windows: 0Aug 7 Linux: 0 Mac: 0 Windows: 0Aug 6 Linux: 0 Mac: 0 Windows: 0Aug 5 Linux: 0 Mac: 0 Windows: 0Aug 4 Linux: 0 Mac: 0 Windows: 0Aug 3 Linux: 0 Mac: 0 Windows: 0Aug 2 Linux: 0 Mac: 0 Windows: 0Aug 1 Linux: 0 Mac: 0 Windows: 0Jul 31 Linux: 0 Mac: 0 Windows: 0Jul 30 Linux: 0 Mac: 0 Windows: 0Jul 29 Linux: 0 Mac: 1 Windows: 0Jul 28 Linux: 0 Mac: 0 Windows: 0Jul 27 Linux: 0 Mac: 0 Windows: 0Jul 26 Linux: 0 Mac: 0 Windows: 0Jul 25 Linux: 0 Mac: 0 Windows: 0Jul 24 Linux: 0 Mac: 0 Windows: 0Jul 23 Linux: 0 Mac: 0 Windows: 0Jul 22 Linux: 0 Mac: 0 Windows: 0Jul 21 Linux: 0 Mac: 0 Windows: 0Jul 20 Linux: 0 Mac: 0 Windows: 0Jul 19 Linux: 0 Mac: 0 Windows: 0Jul 18 Linux: 0 Mac: 0 Windows: 0Jul 17 Linux: 0 Mac: 0 Windows: 0Jul 16 Linux: 0 Mac: 0 Windows: 0Jul 15 Linux: 0 Mac: 0 Windows: 0Jul 14 Linux: 0 Mac: 0 Windows: 0Jul 13 Linux: 0 Mac: 0 Windows: 0Jul 12 Linux: 0 Mac: 0 Windows: 0Jul 11 Linux: 0 Mac: 0 Windows: 0Jul 10 Linux: 0 Mac: 0 Windows: 0Jul 9 Linux: 0 Mac: 0 Windows: 0Jul 8 Linux: 0 Mac: 0 Windows: 0Jul 7 Linux: 0 Mac: 1 Windows: 0Jul 6 Linux: 0 Mac: 0 Windows: 0Jul 5 Linux: 0 Mac: 0 Windows: 0Jul 4 Linux: 0 Mac: 0 Windows: 0Jul 3 Linux: 0 Mac: 0 Windows: 0Jul 2 Linux: 0 Mac: 0 Windows: 0Aug 15 Linux: 0 Mac: 0 Windows: 0Aug 14 Linux: 0 Mac: 0 Windows: 0Aug 13 Linux: 0 Mac: 0 Windows: 0Aug 12 Linux: 0 Mac: 0 Windows: 0Aug 11 Linux: 0 Mac: 0 Windows: 0Aug 10 Linux: 0 Mac: 0 Windows: 0Aug 9 Linux: 0 Mac: 0 Windows: 0Aug 8 Linux: 0 Mac: 0 Windows: 0Aug 7 Linux: 0 Mac: 0 Windows: 0Aug 6 Linux: 0 Mac: 0 Windows: 0Aug 5 Linux: 0 Mac: 0 Windows: 0Aug 4 Linux: 0 Mac: 0 Windows: 0Aug 3 Linux: 0 Mac: 0 Windows: 0Aug 2 Linux: 0 Mac: 0 Windows: 0Aug 1 Linux: 0 Mac: 0 Windows: 0Jul 31 Linux: 0 Mac: 0 Windows: 0Jul 30 Linux: 0 Mac: 0 Windows: 0Jul 29 Linux: 0 Mac: 1 Windows: 0Jul 28 Linux: 0 Mac: 0 Windows: 0Jul 27 Linux: 0 Mac: 0 Windows: 0Jul 26 Linux: 0 Mac: 0 Windows: 0Jul 25 Linux: 0 Mac: 0 Windows: 0Jul 24 Linux: 0 Mac: 0 Windows: 0Jul 23 Linux: 0 Mac: 0 Windows: 0Jul 22 Linux: 0 Mac: 0 Windows: 0Jul 21 Linux: 0 Mac: 0 Windows: 0Jul 20 Linux: 0 Mac: 0 Windows: 0Jul 19 Linux: 0 Mac: 0 Windows: 0Jul 18 Linux: 0 Mac: 0 Windows: 0Jul 17 Linux: 0 Mac: 0 Windows: 0Jul 16 Linux: 0 Mac: 0 Windows: 0Jul 15 Linux: 0 Mac: 0 Windows: 0Jul 14 Linux: 0 Mac: 0 Windows: 0Jul 13 Linux: 0 Mac: 0 Windows: 0Jul 12 Linux: 0 Mac: 0 Windows: 0Jul 11 Linux: 0 Mac: 0 Windows: 0Jul 10 Linux: 0 Mac: 0 Windows: 0Jul 9 Linux: 0 Mac: 0 Windows: 0Jul 8 Linux: 0 Mac: 0 Windows: 0Jul 7 Linux: 0 Mac: 1 Windows: 0Jul 6 Linux: 0 Mac: 0 Windows: 0Jul 5 Linux: 0 Mac: 0 Windows: 0Jul 4 Linux: 0 Mac: 0 Windows: 0Jul 3 Linux: 0 Mac: 0 Windows: 0Jul 2 Linux: 0 Mac: 0 Windows: 0Aug 15 Linux: 0 Mac: 0 Windows: 0Aug 14 Linux: 0 Mac: 0 Windows: 0Aug 13 Linux: 0 Mac: 0 Windows: 0Aug 12 Linux: 0 Mac: 0 Windows: 0Aug 11 Linux: 0 Mac: 0 Windows: 0Aug 10 Linux: 0 Mac: 0 Windows: 0Aug 9 Linux: 0 Mac: 0 Windows: 0Aug 8 Linux: 0 Mac: 0 Windows: 0Aug 7 Linux: 0 Mac: 0 Windows: 0Aug 6 Linux: 0 Mac: 0 Windows: 0Aug 5 Linux: 0 Mac: 0 Windows: 0Aug 4 Linux: 0 Mac: 0 Windows: 0Aug 3 Linux: 0 Mac: 0 Windows: 0Aug 2 Linux: 0 Mac: 0 Windows: 0Aug 1 Linux: 0 Mac: 0 Windows: 0Jul 31 Linux: 0 Mac: 0 Windows: 0Jul 30 Linux: 0 Mac: 0 Windows: 0Jul 29 Linux: 0 Mac: 1 Windows: 0Jul 28 Linux: 0 Mac: 0 Windows: 0Jul 27 Linux: 0 Mac: 0 Windows: 0Jul 26 Linux: 0 Mac: 0 Windows: 0Jul 25 Linux: 0 Mac: 0 Windows: 0Jul 24 Linux: 0 Mac: 0 Windows: 0Jul 23 Linux: 0 Mac: 0 Windows: 0Jul 22 Linux: 0 Mac: 0 Windows: 0Jul 21 Linux: 0 Mac: 0 Windows: 0Jul 20 Linux: 0 Mac: 0 Windows: 0Jul 19 Linux: 0 Mac: 0 Windows: 0Jul 18 Linux: 0 Mac: 0 Windows: 0Jul 17 Linux: 0 Mac: 0 Windows: 0Jul 16 Linux: 0 Mac: 0 Windows: 0Jul 15 Linux: 0 Mac: 0 Windows: 0Jul 14 Linux: 0 Mac: 0 Windows: 0Jul 13 Linux: 0 Mac: 0 Windows: 0Jul 12 Linux: 0 Mac: 0 Windows: 0Jul 11 Linux: 0 Mac: 0 Windows: 0Jul 10 Linux: 0 Mac: 0 Windows: 0Jul 9 Linux: 0 Mac: 0 Windows: 0Jul 8 Linux: 0 Mac: 0 Windows: 0Jul 7 Linux: 0 Mac: 1 Windows: 0Jul 6 Linux: 0 Mac: 0 Windows: 0Jul 5 Linux: 0 Mac: 0 Windows: 0Jul 4 Linux: 0 Mac: 0 Windows: 0Jul 3 Linux: 0 Mac: 0 Windows: 0Jul 2 Linux: 0 Mac: 0 Windows: 0

Readme

Source
raw.​githubusercontent.​com

Standard JavaScript Snippets for Sublime Text

A collection of standardjs code style snippets for JavaScript development in Sublime Text.

js-standard-style

Yes!, no semicolons: - Are Semicolons Necessary in JavaScript? - An Open Letter to JavaScript Leaders Regarding Semicolons - JavaScript Semicolon Insertion - Everything You Need to Know

Installation

Installation via Package Control

  1. Open PackageControl (Ctrl+Shift+P).
  2. Type and press 'Install Package'.
  3. Find and install 'StandardSnippets'

Manual installation

  1. Preferences - Browse Packages.
  2. Add content of this repo anywhere.

Disabling default snippets

You don't need them with this beautiful package!
  1. Install PackageResourceViewer via Package Control (Ctrl+Shift+P - Install Package - PackageResourceViewer).
  2. Extract JavaScript package (Ctrl+Shift+P - Extract - JavaScript).
  3. Open packages folder (Preferences - Browse Packages).
  4. Remove JavaScript/Snippets and rename JavaScript folder to any other (e.g. JavaScript-custom).
  5. Add JavaScript to ignored packages (Ctrl+Shift+P - Disable Package - JavaScript)

Contents

Declarations

l⇥ let assignment

let ${1:name} = ${2:value}

co⇥ const assignment

const ${1:name} = ${2:value}

yi⇥ const assignment

yield ${1:value}

Flow Control

if⇥ if statement

if (${1:condition}) {
  ${0}
}

el⇥ else statement

else {
  ${0}
}

ife⇥ else statement

if (${1:condition}) {
  ${0}
} else {

}

ei⇥ else if statement

else if (${1:condition}) {
  ${0}
}

for⇥ for loop

for (let ${1:i} = ${2:start}; ${1:i} < ${3:end}; ${1:i} += 1) {
  ${0}
}

rfor⇥ reversed for loop

for (let ${1:i} = ${2:start}; ${1:i} >= ${3:end}; ${1:i} -= 1) {
  ${0}
}

fi⇥ for in loop

for (const ${1:key} in ${2:collection}) {
  ${0}
}

fo⇥ for of loop

for (const ${1:value} of ${2:collection}) {
  ${0}
}
}

wl⇥ while loop

while (${1:condition}) {
  ${0}
}

tc⇥ try/catch

try {
 ${0}
} catch (${1:err}) {

}

tf⇥ try/finally

try {
 ${0}
} finally {

}

tcf⇥ try/catch/finally

try {
  ${0}
} catch (${1:err}) {

} finally {

}

Functions

fun⇥ anonymous function

function (${1:arguments}) {
  ${0}
}

fn⇥ named function

function ${1:name} (${2:arguments}) {
  ${0}
}

fas⇥ function assignment

const ${1:name} = function ${1:name} (${2:arguments}) {
  ${0}
}

iife⇥ immediately-invoked function expression (IIFE)

;(function (${1:arguments}) {
  ${0}
})(${2})

af⇥ arrow function

(${1:arguments}) => ${2:statement}

afb⇥ arrow function with body

(${1:arguments}) => {
  ${0}
}

gfun⇥ generator function

function* (${1:arguments}) {
  ${0}
}

gfn⇥ named generator function

function* ${1:name}(${1:arguments}) {
  ${0}
}

gfn⇥ generator assignment

const ${1:name} = function* ${1:name} (${2:arguments}) {
  ${0}
}

Iterables

fe⇥ forEach loop

forEach((${2:item}) => {
  ${0}
})

map⇥ map function

map((${2:item}) => {
  ${0}
})

reduce⇥ reduce function

reduce((${2:previous}, ${3:current}) => {
  ${0}
}${4:, initial})

filter⇥ filter function

filter((${2:item}) => {
  ${0}
})

find⇥ ES6 find function

find((${2:item}) => {
  ${0}
})

every⇥ every function

every((${2:item}) => {
  ${0}
})

some⇥ some function

some((${2:item}) => {
  ${0}
})

Objects and classes

cs⇥ class (ES6)

class ${1:name} {
  constructor(${2:arguments}) {
    ${0}
  }
}

csx⇥ child class (ES6)

class ${1:name} extends ${2:base} {
  constructor(${2:arguments}) {
    super(${2:arguments})
    ${0}
  }
}

kv⇥ key/value pair

Javascript:

${1:key}: ${2:'value'}

JSON:

"${1:key}": ${2:"value"}

m⇥ method (ES6 syntax)

${1:method}(${2:arguments}) {
  ${0}
}

proto⇥ prototype method (chainable)

${1:Class}.prototype.${2:methodName} = function (${3:arguments}) {
  ${0}
}

ok Object.keys

Object.keys(${1:obj})

oa Object.assign

Object.assign(${1:dest}, ${2:source})

hop⇥ has own property

Object.prototype.hasOwnProperty.call(${1:object}, ${2:key})

Returning values

ret⇥ return

return ${0}

rp⇥ return Promise (ES6)

return new Promise((resolve, reject) => {
  ${0}
})

Types

S⇥ String

N⇥ Number

O⇥ Object

A⇥ Array

D⇥ Date

Rx⇥ RegExp

tof⇥ typeof comparison

typeof ${1:source} === '${2:undefined}'

iof⇥ instanceof comparison

${1:source} instanceof ${2:Object}

ia⇥ isArray

Array.isArray(${1:source})

Promises

p⇥ new Promise (ES6)

new Promise((resolve, reject) => {
  ${0}
})

then⇥ Promise.then (chainable)

${1:promise}.then((${2:value}) => {
  ${0}
})

catch⇥ Promise.catch (chainable)

${1:promise}.catch((${2:err}) => {
  ${0}
})

ES6 modules

exp⇥ module export

export ${1:member}

exd⇥ module default export

export default ${1:member}

imp⇥ module import

import ${1:*} from '${2:module}'

ima⇥ module import as

import ${1:*} as ${2:name} from '${3:module}'

imd⇥ module import destructuring

import {$1} from '${2:module}'

BDD testing (Mocha, Jasmine, etc.)

desc⇥ describe

describe('${1:description}', function () {
  ${0}
})

its⇥ synchronous “it”

it('${1:description}', function () {
  ${0}
})

ita⇥ asynchronous “it”

it('${1:description}', function (done) {
  ${0}
})

bf⇥ before test suite

before(function () {
  ${0}
})

bfe⇥ before each test

beforeEach(function () {
  ${0}
})

aft⇥ after test suite

after(function () {
  ${0}
})

afe⇥ after each test

afterEach(function () {
  ${0}
})

Timers

st⇥ setTimeout

setTimeout(() => {
  ${0}
}, ${1:delay})

si⇥ setInterval

setInterval(() => {
  ${0}
}, ${1:delay})

sim⇥ setImmediate

setImmediate(() => {
  ${0}
})

DOM

ae⇥ addEventListener

${1:document}.addEventListener('${2:event}', ${3:ev} => {
  ${0}
})

rel⇥ removeEventListener

${1:document}.removeEventListener('${2:event}', ${3:listener})

gi⇥ getElementById

${1:document}.getElementById('${2:id}')

gc⇥ getElementsByClassName

Array.from(${1:document}.getElementsByClassName('${2:class}'))

gt⇥ getElementsByTagName

Array.from(${1:document}.getElementsByTagName('${2:tag}'))

qs⇥ querySelector

${1:document}.querySelector('${2:selector}')

qsa⇥ querySelectorAll

Array.from(${1:document}.querySelectorAll('${2:selector}'))

cdf⇥ createDocumentFragment

${1:document}.createDocumentFragment(${2:elem});

cel⇥ createElement

${1:document}.createElement(${2:elem});

ac⇥ appendChild

${1:document}.appendChild(${2:elem});

rc⇥ removeChild

${1:document}.removeChild(${2:elem});

cla⇥ classList.add

${1:document}.classList.add('${2:class}');

ct⇥ classList.toggle

${1:document}.classList.toggle('${2:class}');

cr⇥ classList.remove

${1:document}.classList.remove('${2:class}');

ga⇥ getAttribute

${1:document}.getAttribute('${2:attr}');

sa⇥ setAttribute

${1:document}.setAttribute('${2:attr}', ${3:value});

ra⇥ removeAttribute

${1:document}.removeAttribute('${2:attr}');

Node.js

cb⇥ Node.js callback

(err, ${1:arguments}) => {
  if (err) {
    throw err
  }
  ${0}
}

req⇥ require a module

require('${1:module}')

cre⇥ require and assign a module

const ${1:module} = require('${2:module}')

em⇥ export member

exports.${1:name} = ${2:value}

me⇥ module.exports

module.exports = ${1:name}

on⇥ attach an event handler

on('${1:event}', (${2:arguments}) => {
  ${0}
})

xm⇥ Express middleware

(req, res${1:, next}) => {
  ${0}
}

xerr⇥ Express error handler

(err, req, res, next) => {
  ${0}
}

Miscellaneous

us⇥ use strict

'use strict'

js⇥ JSON Stringify

JSON.stringify($0)

jp⇥ JSON Parse

JSON.parse($0)

car⇥ copy array

const ${1:copy} = [...${2:original}${3:, new}]

cas⇥ copy assign

const ${1:copy} = { ...${2:original}${3:, new} }

swap⇥ swap values

[${1}, ${2}] = [${2}, ${1}]

Console

cl⇥ console.log

console.log(${0})

ce⇥ console.error

console.error(${0})

cw⇥ console.warn

console.warn(${0})

cd⇥ console.dir

console.dir(${0})

Contributing

More than happy to accept external contributions to the project in the form of feedback, bug reports and even better pull requests. Please read the contributing guidelines

Related Repositories

Alternatives to Standard Style

  • Semistandard - standard, with semicolons
  • XO - JavaScript happiness style, by Sindre Sorhus

License

The MIT License (MIT)

Copyright © 2017, Vlad Khitev

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 NON INFRINGEMENT. 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.