Skip to content

Instantly share code, notes, and snippets.

@tjunghans
Created April 6, 2020 10:47
Show Gist options
  • Save tjunghans/b33dfe5b6fa8fe6144a96b5b8dbb87b4 to your computer and use it in GitHub Desktop.
Save tjunghans/b33dfe5b6fa8fe6144a96b5b8dbb87b4 to your computer and use it in GitHub Desktop.
JavaScript, Typescript and React VSCode snippets
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. 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": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"log json": {
"scope": "javascript, typescript, typescriptreact, javascriptreact",
"prefix": "json",
"body": [
"console.log(JSON.stringify($1, null, 2));$0"
],
"description": "Writes console log with stringified object"
},
"new test file": {
"scope": "javascript, typescript",
"prefix": "test",
"body": [
"/* eslint-env mocha, browser */",
"import * as assert from \"assert\";",
"import * as sinon from \"sinon\";",
"",
"describe(\"$1\", () => {",
"\t$0",
"});"
],
"description": "Test file template"
},
"print describe block": {
"scope": "javascript, typescript",
"prefix": "desc",
"body": [
"describe(\"$1\", () => {",
"\t$0",
"});"
],
"description": "writes describe block"
},
"print it block": {
"scope": "javascript, typescript",
"prefix": "it",
"body": [
"it(\"$1\", () => {",
"\t$0",
"});"
],
"description": "writes it block"
},
"print beforeEach block": {
"scope": "javascript, typescript",
"prefix": "beforeEach",
"body": [
"beforeEach(() => {",
"\t$0",
"});"
],
"description": "writes beforeEach block"
},
"print afterEach block": {
"scope": "javascript, typescript",
"prefix": "afterEach",
"body": [
"afterEach(() => {",
"\t$0",
"});"
],
"description": "writes afterEach block"
},
"print assert.equal": {
"scope": "javascript, typescript",
"prefix": "ass",
"body": [
"assert.strictEqual($1, $0)"
],
"description": "writes assert.strictEqual"
},
"log alias": {
"scope": "javascript, typescript, typescriptreact, javascriptreact",
"prefix": "c",
"body": [
"console.log(\"$0\");"
],
"description": "writes console.log"
},
"interface": {
"scope": "typescript",
"prefix": "int",
"body": [
"export interface $1 {",
"\t$0",
"}"
],
"description": "writes interface"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment