Skip to content

Commit a97c0f9

Browse files
committed
grouped snippets and added more
1 parent fca2fd1 commit a97c0f9

File tree

4 files changed

+228
-111
lines changed

4 files changed

+228
-111
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ document.removeEventListener("${1:event}", (${2:param}) => {
159159
})
160160
```
161161

162-
#### `ce =>` create element
162+
#### `cel =>` create element
163163

164164
```js
165165
document.createElement("${1:element}")
@@ -196,7 +196,7 @@ document.querySelectorAll("${1:selector}")
196196
#### `od =>` object destructuring
197197

198198
```js
199-
const { ${1:name} } = ${2:value}
199+
let { ${1:name} } = ${2:value}
200200
```
201201

202202
#### `cl =>` console log

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
"url": "https://www.linkedin.com/in/ddyakov/"
77
},
88
"publisher": "ddyakov",
9-
"keywords": ["javascript", "snippets", "vscode"],
9+
"keywords": [
10+
"javascript",
11+
"snippets",
12+
"vscode"
13+
],
1014
"repository": {
1115
"type": "git",
1216
"url": "https://github.com/mdyakov/SnipJS"
@@ -33,4 +37,4 @@
3337
}
3438
]
3539
}
36-
}
40+
}

snippets/snippets.json

Lines changed: 215 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -1,110 +1,218 @@
11
{
2-
"Let assignment": {
3-
"prefix": "la",
4-
"body": "let ${1:name} = ${2:value}"
5-
},
6-
"Var assignment": {
7-
"prefix": "va",
8-
"body": "var ${1:name} = ${2:value}"
9-
},
10-
"Const assignment": {
11-
"prefix": "ca",
12-
"body": "const ${1:name} = ${2:value}"
13-
},
14-
"Object assignment": {
15-
"prefix": "oa",
16-
"body": [
17-
"let ${1:obj} = {",
18-
" \"${2:key}\": ${3:value}",
19-
"}"
20-
]
21-
},
22-
"Array assignment": {
23-
"prefix": "aa",
24-
"body": "let ${1:name} = [${2:value1}, ${3:value2}]"
25-
},
26-
"Object destructuring": {
27-
"prefix": "od",
28-
"body": "const { ${1:name} } = ${2:value}"
29-
},
30-
"Console log": {
31-
"prefix": "cl",
32-
"body": "console.log(${1:value})"
33-
},
34-
"Arrow function": {
35-
"prefix": "af",
36-
"body": "const ${1:name} = (${2:param}) => {\n\t${0}\n}"
37-
},
38-
"Named function": {
39-
"prefix": "nf",
40-
"body": "function ${1:name} (${2:param}) {\n\t${0}\n}"
41-
},
42-
"And condition": {
43-
"prefix": "ac",
44-
"body": "${1:condition1} && ${2:condition2}"
45-
},
46-
"Or condition": {
47-
"prefix": "oc",
48-
"body": "${1:condition1} || ${2:condition2}"
49-
},
50-
"Condition operator": {
51-
"prefix": "co",
52-
"body": "let ${1:name} = ${2:condition} ? ${3:value1} : ${4:value2}"
53-
},
54-
"Length validation": {
55-
"prefix": "lv",
56-
"body": "${1:value}.length === ${2:0}"
57-
},
58-
"Null validation": {
59-
"prefix": "nv",
60-
"body": "${1:value} === null"
61-
},
62-
"Not null validation": {
63-
"prefix": "nnv",
64-
"body": "${1:value} !== null"
65-
},
66-
"Undefined validation": {
67-
"prefix": "uv",
68-
"body": "typeof ${1:value} === \"undefined\""
69-
},
70-
"Contains validation": {
71-
"prefix": "cv",
72-
"body": "${1:value}.indexOf(${2:value2}) > -1"
73-
},
74-
"Doesn't contain validation": {
75-
"prefix": "dcv",
76-
"body": "${1:value}.indexOf(${2:value2}) === -1"
77-
},
78-
"Not undefined validation": {
79-
"prefix": "nuv",
80-
"body": "typeof ${1:value} !== \"undefined\""
81-
},
82-
"Add event listener": {
83-
"prefix": "ael",
84-
"body": "document.addEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n})"
85-
},
86-
"Remove event listener": {
87-
"prefix": "rel",
88-
"body": "document.removeEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n})"
89-
},
90-
"Create element": {
91-
"prefix": "ce",
92-
"body": "document.createElement(\"${1:element}\")"
93-
},
94-
"Get element by id": {
95-
"prefix": "gei",
96-
"body": "document.getElementById(\"${1:id}\")"
97-
},
98-
"Get element by class name": {
99-
"prefix": "gec",
100-
"body": "document.getElementsByClassName(\"${1:class}\")"
101-
},
102-
"Query selector": {
103-
"prefix": "qs",
104-
"body": "document.querySelector(\"${1:selector}\")"
105-
},
106-
"Query selector all": {
107-
"prefix": "qsa",
108-
"body": "document.querySelectorAll(\"${1:selector}\")"
2+
"Assignments": {
3+
"Let assignment": {
4+
"prefix": "la",
5+
"body": "let ${1:name} = ${2:value}"
6+
},
7+
"Var assignment": {
8+
"prefix": "va",
9+
"body": "var ${1:name} = ${2:value}"
10+
},
11+
"Const assignment": {
12+
"prefix": "ca",
13+
"body": "const ${1:name} = ${2:value}"
14+
},
15+
"Object assignment": {
16+
"prefix": "oa",
17+
"body": [
18+
"let ${1:name} = {",
19+
" \"${2:key}\": ${3:value}",
20+
"}"
21+
]
22+
},
23+
"Array assignment": {
24+
"prefix": "aa",
25+
"body": "let ${1:name} = [${2:value1}, ${3:value2}]"
26+
}
27+
},
28+
"Functions": {
29+
"Arrow function": {
30+
"prefix": "af",
31+
"body": "const ${1:name} = (${2:param}) => {\n\t${0}\n}"
32+
},
33+
"Named function": {
34+
"prefix": "nf",
35+
"body": "function ${1:name} (${2:param}) {\n\t${0}\n}"
36+
}
37+
},
38+
"Conditions": {
39+
"Equal condition": {
40+
"prefix": "ec",
41+
"body": "${1:value1} === ${2:value2}"
42+
},
43+
"Not equal condition": {
44+
"prefix": "nec",
45+
"body": "${1:value1} !== ${2:value2}"
46+
},
47+
"Greater than condition": {
48+
"prefix": "gtc",
49+
"body": "${1:value1} > ${2:value2}"
50+
},
51+
"Less than condition": {
52+
"prefix": "ltc",
53+
"body": "${1:value1} < ${2:value2}"
54+
},
55+
"Greater equal than condition": {
56+
"prefix": "getc",
57+
"body": "${1:value1} >= ${2:value2}"
58+
},
59+
"Less equal than condition": {
60+
"prefix": "letc",
61+
"body": "${1:value1} <= ${2:value2}"
62+
},
63+
"Or condition": {
64+
"prefix": "oc",
65+
"body": "${1:condition1} || ${2:condition2}"
66+
},
67+
"And condition": {
68+
"prefix": "ac",
69+
"body": "${1:condition1} && ${2:condition2}"
70+
},
71+
"Condition operator": {
72+
"prefix": "co",
73+
"body": "let ${1:name} = ${2:condition} ? ${3:value1} : ${4:value2}"
74+
}
75+
},
76+
"Validations": {
77+
"Zero length validation": {
78+
"prefix": "zlv",
79+
"body": "${1:value}.length === 0"
80+
},
81+
"Positive length validation": {
82+
"prefix": "plv",
83+
"body": "${1:value}.length > 0"
84+
},
85+
"Empty string validation": {
86+
"prefix": "esv",
87+
"body": "${1:value} === \"\""
88+
},
89+
"Not empty string validation": {
90+
"prefix": "nesv",
91+
"body": "${1:value} !== \"\""
92+
},
93+
"Null validation": {
94+
"prefix": "nv",
95+
"body": "${1:value} === null"
96+
},
97+
"Not null validation": {
98+
"prefix": "nnv",
99+
"body": "${1:value} !== null"
100+
},
101+
"Undefined validation": {
102+
"prefix": "uv",
103+
"body": "typeof ${1:value} === \"undefined\""
104+
},
105+
"Not undefined validation": {
106+
"prefix": "nuv",
107+
"body": "typeof ${1:value} !== \"undefined\""
108+
},
109+
"Instance of validation": {
110+
"prefix": "iov",
111+
"body": "${1:value} instanceof ${2:value2}"
112+
},
113+
"Array validation": {
114+
"prefix": "av",
115+
"body": "Array.isArray(${1:value}) || ${1:value}.length"
116+
},
117+
"Object validation": {
118+
"prefix": "ov",
119+
"body": "Object.keys(${1:value}).length === 0 && ${1:value}.constructor === Object"
120+
},
121+
"Contains validation": {
122+
"prefix": "cv",
123+
"body": "${1:value}.indexOf(${2:value2}) > -1"
124+
},
125+
"Doesn't contain validation": {
126+
"prefix": "dcv",
127+
"body": "${1:value}.indexOf(${2:value2}) === -1"
128+
}
129+
},
130+
"DOM manipulations": {
131+
"Add event listener": {
132+
"prefix": "ael",
133+
"body": "document.addEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n})"
134+
},
135+
"Remove event listener": {
136+
"prefix": "rel",
137+
"body": "document.removeEventListener(\"${1:event}\", (${2:param}) => {\n\t${0}\n})"
138+
},
139+
"Create element": {
140+
"prefix": "cel",
141+
"body": "document.createElement(\"${1:value}\")"
142+
},
143+
"Append child": {
144+
"prefix": "ach",
145+
"body": "document.appendChild(\"${1:value}\")"
146+
},
147+
"Remove child": {
148+
"prefix": "rch",
149+
"body": "document.removeChild(\"${1:value}\")"
150+
},
151+
"Get element by id": {
152+
"prefix": "gei",
153+
"body": "document.getElementById(\"${1:value}\")"
154+
},
155+
"Get elements by class name": {
156+
"prefix": "gec",
157+
"body": "document.getElementsByClassName(\"${1:value}\")"
158+
},
159+
"Get elements by tag name": {
160+
"prefix": "get",
161+
"body": "document.getElementsByTagName(\"${1:value}\")"
162+
},
163+
"Query selector": {
164+
"prefix": "qs",
165+
"body": "document.querySelector(\"${1:value}\")"
166+
},
167+
"Query selector all": {
168+
"prefix": "qsa",
169+
"body": "document.querySelectorAll(\"${1:value}\")"
170+
}
171+
},
172+
"Console": {
173+
"Console log": {
174+
"prefix": "cl",
175+
"body": "console.log(${1:value})"
176+
},
177+
"Console warn": {
178+
"prefix": "cw",
179+
"body": "console.warn(${1:value})"
180+
},
181+
"Console error": {
182+
"prefix": "ce",
183+
"body": "console.error(${1:value})"
184+
}
185+
},
186+
"Destructuring": {
187+
"Object destructuring": {
188+
"prefix": "od",
189+
"body": "let { ${1:value1} } = ${2:value2}"
190+
},
191+
"Array destructuring": {
192+
"prefix": "ad",
193+
"body": "let [${1:value1}, ${2:value2}] = ${3:value3}"
194+
}
195+
},
196+
"Others": {
197+
"React bind this": {
198+
"prefix": "rbt",
199+
"body": "this.${1:name} = this.${1:name}.bind(this)"
200+
},
201+
"Clone array": {
202+
"prefix": "car",
203+
"body": "let ${1:name} = ...${2:value}"
204+
},
205+
"Placeholder": {
206+
"prefix": "ph1",
207+
"body": "`${${1:value1}}`"
208+
},
209+
"Placeholder2": {
210+
"prefix": "ph2",
211+
"body": "`${${1:value1}} ${${2:value2}}`"
212+
},
213+
"Placeholder3": {
214+
"prefix": "ph3",
215+
"body": "`${${1:value1}} ${${2:value2}} ${${3:value3}}`"
216+
}
109217
}
110218
}

0 commit comments

Comments
 (0)