Skip to content

Commit cfbf929

Browse files
committed
add javascript react snippets
fixes microsoft#3415
1 parent b534d17 commit cfbf929

2 files changed

Lines changed: 145 additions & 0 deletions

File tree

extensions/javascript/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@
5858
{
5959
"language": "javascript",
6060
"path": "./snippets/javascript.json"
61+
},
62+
{
63+
"language": "javascriptreact",
64+
"path": "./snippets/javascriptreact.json"
6165
}
6266
],
6367
"jsonValidation": [
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
{
2+
"define module": {
3+
"prefix": "define",
4+
"body": [
5+
"define([",
6+
"\t'require',",
7+
"\t'${dependency}'",
8+
"], function(require, ${factory}) {",
9+
"\t'use strict';",
10+
"\t$0",
11+
"});"
12+
],
13+
"description": "define module"
14+
},
15+
"For Loop": {
16+
"prefix": "for",
17+
"body": [
18+
"for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {",
19+
"\tvar ${element} = ${array}[${index}];",
20+
"\t$0",
21+
"}"
22+
],
23+
"description": "For Loop"
24+
},
25+
"For-Each Loop": {
26+
"prefix": "foreach",
27+
"body": [
28+
"${array}.forEach(function(${element}) {",
29+
"\t$0",
30+
"}, this);"
31+
],
32+
"description": "For-Each Loop"
33+
},
34+
"For-In Loop": {
35+
"prefix": "forin",
36+
"body": [
37+
"for (var ${key} in ${object}) {",
38+
"\tif (${object}.hasOwnProperty(${key})) {",
39+
"\t\tvar ${element} = ${object}[${key}];",
40+
"\t\t$0",
41+
"\t}",
42+
"}"
43+
],
44+
"description": "For-In Loop"
45+
},
46+
"Function Statement": {
47+
"prefix": "function",
48+
"body": [
49+
"function ${name}(${params}) {",
50+
"\t$0",
51+
"}"
52+
],
53+
"description": "Function Statement"
54+
},
55+
"If Statement": {
56+
"prefix": "if",
57+
"body": [
58+
"if (${condition}) {",
59+
"\t$0",
60+
"}"
61+
],
62+
"description": "If Statement"
63+
},
64+
"If-Else Statement": {
65+
"prefix": "ifelse",
66+
"body": [
67+
"if (${condition}) {",
68+
"\t$0",
69+
"} else {",
70+
"\t",
71+
"}"
72+
],
73+
"description": "If-Else Statement"
74+
},
75+
"New Statement": {
76+
"prefix": "new",
77+
"body": [
78+
"var ${name} = new ${type}(${arguments});$0"
79+
],
80+
"description": "New Statement"
81+
},
82+
"Switch Statement": {
83+
"prefix": "switch",
84+
"body": [
85+
"switch (${key}) {",
86+
"\tcase ${value}:",
87+
"\t\t$0",
88+
"\t\tbreak;",
89+
"",
90+
"\tdefault:",
91+
"\t\tbreak;",
92+
"}"
93+
],
94+
"description": "Switch Statement"
95+
},
96+
"While Statement": {
97+
"prefix": "while",
98+
"body": [
99+
"while (${condition}) {",
100+
"\t$0",
101+
"}"
102+
],
103+
"description": "While Statement"
104+
},
105+
"Do-While Statement": {
106+
"prefix": "dowhile",
107+
"body": [
108+
"do {",
109+
"\t$0",
110+
"} while (${condition});"
111+
],
112+
"description": "Do-While Statement"
113+
},
114+
"Try-Catch Statement":{
115+
"prefix": "trycatch",
116+
"body": [
117+
"try {",
118+
"\t$0",
119+
"} catch (${error}) {",
120+
"\t",
121+
"}"
122+
],
123+
"description": "Try-Catch Statement"
124+
},
125+
"Set Timeout Function": {
126+
"prefix": "settimeout",
127+
"body": [
128+
"setTimeout(function() {",
129+
"\t$0",
130+
"}, ${timeout});"
131+
],
132+
"description": "Set Timeout Function"
133+
},
134+
"Relative Reference to another File": {
135+
"prefix": "reference",
136+
"body": [
137+
"/// <reference path=\"$1\" />$0"
138+
],
139+
"description": "Relative Reference to another File"
140+
}
141+
}

0 commit comments

Comments
 (0)