Skip to content

Instantly share code, notes, and snippets.

@brettz9
Last active November 4, 2023 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brettz9/23af5e9909a714ccf600a6c1818b021e to your computer and use it in GitHub Desktop.
Save brettz9/23af5e9909a714ccf600a6c1818b021e to your computer and use it in GitHub Desktop.
VSC JS snippets (work in progress): ~/Library/Application Support/Code/User/snippets/javascript.json
{
// Place your snippets for javascript here. Each snippet is defined under
// a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and
// the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position,
// and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"it mocha": {
"prefix": "it",
"body": [
"it('$1', function () {",
" $2",
"});"
],
"description": "Mocha it test"
},
"describe mocha": {
"prefix": "desc",
"body": [
"describe('$1', function () {",
" $2",
"});"
]
},
"console.log": {
"prefix": "co",
"body": [
"console.log('$1');"
],
"description": "Console logging"
},
"istanbul": {
"prefix": "is",
"body": [
"/* istanbul ignore next -- $1 */"
],
"description": "Istanbul coverage"
},
"cy get": {
"prefix": "cy",
"body": [
"cy.get('$1');"
]
},
"ESLint disable next line": {
"prefix": "es",
"body": [
"// eslint-disable-next-line $1"
]
},
"JSON.stringify": {
"prefix": "json",
"body": [
"JSON.stringify($1)"
]
},
"arrow function": {
"prefix": "af",
"body": [
"($1) => {}"
]
},
"export default": {
"prefix": "ed",
"body": [
"export default $1;"
]
},
"JSDoc @param": {
"prefix": "pa",
"body": [
"@param {} "
]
},
"JSDoc @param with block": {
"prefix": "par",
"body": [
"/**\n * @param {} $1\n */"
]
},
"JSDoc @returns": {
"prefix": "re",
"body": [
"@returns {$1}"
]
},
"JSDoc @typedef": {
"prefix": "typedef",
"body": [
"/**",
" * @typedef {} $1",
" */"
]
},
"JSDoc config": {
"prefix": "cfg",
"body": [
"/**",
" * @param {object} cfg",
" * @param {} cfg.$1",
" */"
]
},
"JSDoc block": {
"prefix": "jsdoc",
"body": [
"/**",
" * $1",
" */"
]
},
"@type (short)": {
"prefix": "type",
"body": [
"/** @type {} */ ($1)"
]
},
"@type (long)": {
"prefix": "typ",
"body": [
"/**\n * @type {$1}\n */"
]
},
"@returns": {
"prefix": "re",
"body": [
"@returns {$1}"
]
},
"@returns {void}": {
"prefix": "ret",
"body": [
"/**\n * @returns {void}\n */"
]
},
"void": {
"prefix": "void",
"body": [
"@returns {void}"
]
},
"function": {
"prefix": "fu",
"body": [
"function $1 () {\n}"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment