My SublimeText 2/3 snippets. From BDD through
assertto singleton pattern, es6 fat arrows and es6 import
zip javascript-charlike-snippets.sublime-package -r javascript-charlike-snippets && cp javascript-charlike-snippets.sublime-package ~/.config/sublime-text-3/Installed\ Packages/
This snippets use standard to maintain code style and consistency, and to avoid style arguments. You are encouraged to install it globally.
- module system
- rrnode variable require
- reqnode require
- impjavascript import
 
- functions-and-arrows
- fates6 arrow function
- ofates6 arrow function as object property
- memodule.exports
- menmodule.exports - named function
- meamodule.exports - anonymous function
- fnnamed function
- afnanonymous function
- ofnnamed function as object property
- oafnanonymous function as object property
- fixturefixture function (useful when assert.throws)
- iifeimmediately-invoked function expression
 
- assert
- aseassert.equal
- asnassert.notEqual
- asseassert.strictEqual
- assnassert.notStrictEqual
- asdassert.deepEqual
- asdnassert.notDeepEqual
- assdassert.deepStrictEqual
- assdnassert.notDeepStrictEqual
- asiassert.ifError
- astassert.throws(actual, expected, msg)
- asteassert.throws fixture Error
- asttypeassert.throws fixture TypeError
- astreassert.throws fixture regexp message
 
- testing
- descdescribe
- itait async
- itsit sync
 
- console and misc
- clconsole.log
- ceconsole.error
- selfself this
- ususe strict
- loopfast while loop
- singletonsingleton pattern
- varvariable assigning, e.g.- var foo = bar
- iftypeofif block with typeof check
- iferrif block with typeof check and throw TypeError
- typeoftypeof check with strict equality
- thrthrow error
- thnthrow error with new
 
- [rr] node variable require
var ${2:pkg} = require('${1:package}')${0}- [req] node require
require('${1:package}')${0}- [imp] javascript import
import ${2:pkg} from '${1:package}'${0}- [fat] es6 arrow
(${1:args}) => ${0}- [ofat] es6 arrow as object property
${1:name}: (${2:args}) => ${0}- [me] module.exports
module.exports = ${0}- [men] module.exports - named function
module.exports = function ${1:name} (${2:args}) {
  ${0}
}- [mea] module.exports - anonymous function
module.exports = function (${2:args}) {
  ${0}
}- [fn] named function
function ${1:name} (${2:args}) {
  ${0}
}- [afn] anonymous function
function (${1:args}) {
  ${0}
}- [ofn] named function as object property
${1:name}: function ${1:name} (${2:args}) {
  ${0}
}- [oafn] anonymous function as object property
${1:name}: function (${2:args}) {
  ${0}
}- [fixture] fixture function (useful when assert.throws)
function fixture () {
  ${1:fnName}
}${0}- [ase] assert equal
${1:assert}.equal(${2:actual}, ${3:expected}, ${4:msg})${0}- [asn] assert notEqual
${1:assert}.notEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [asse] assert strictEqual
${1:assert}.strictEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [assn] assert notStrictEqual
${1:assert}.notStrictEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [asd] assert deepEqual
${1:assert}.deepEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [asdn] assert notDeepEqual
${1:assert}.notDeepEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [assd] assert.deepStrictEqual
${1:assert}.deepStrictEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [assdn] assert.notDeepStrictEqual
${1:assert}.notDeepStrictEqual(${2:actual}, ${3:expected}, ${4:msg})${0}- [asi] assert.ifError
${1:assert}.ifError(${2:err})${0}- [ast] assert.throws
${1:assert}.throws(${2:actual}, ${3:expected}, ${4:msg})${0}- [aste] assert.throws fixture Error
${1:assert}.throws(${2:fixture}, Error)${0}- [asttype] assert.throws fixture TypeError
${1:assert}.throws(${2:fixture}, TypeError)${0}- [astre] assert.throws fixture regexp message
${1:assert}.throws(${2:fixture}, /${3:expected msg}/)${0}- [desc] describe
${1:describe}('${2:description}', function () {
  ${0}
})- [ita] it async
${1:it}('${2:description}', function (${3:done}) {
  ${0}
  ${4:done}()
})- [its] it sync
${1:it}('${2:description}', function () {
  ${0}
})- [cl] console.log
console.log(${1:actual})${0}- [ce] console.error
console.error(${1:actual})${0}- [self] self this
var self = this- [us] use strict
'use strict'- [loop] fast while loop
var len = ${1:arr}.length
var i = 0
while (i < len) {
  var val = ${1:arr}[${2:i++}]
  ${0}
}- [singleton] singleton pattern
function ${1:ClassName} (${2:options}) {
  if (!(this instanceof ${1:ClassName})) {
    return new ${1:ClassName}(${2:options})
  }
  ${0}
}- [var] variable assigning
var ${2:foo} = ${1:bar}${0}- [iftypeof] if block with typeof check
if (typeof ${1:actual} === ${2:expected}) {
  ${0}
}- [iferr] if block with typeof check and throw TypeError
if (typeof ${1:actual} === ${2:expected}) {
  throw new ${3:TypeError}('${4:message}')
}${0}- [typeof] typeof check with strict equality
typeof ${1:actual} === ${2:expected}- [thr] throw error
throw ${1:err}- [thn] throw error with new
throw new ${1:TypeError}('${2:message}')${0}Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.