-
Notifications
You must be signed in to change notification settings - Fork 0
/
js-ts-jsx-tsx.jsonc
255 lines (252 loc) · 7.31 KB
/
js-ts-jsx-tsx.jsonc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
{
// ########### javascript ###############
"Print log to console": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "log",
"body": ["console.log('$hello',$hello)"],
"description": "Log output to console"
},
"Alert Hello World": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "alert",
"body": ["alert(\"Hello, Genius!\");"],
"description": "Alert Hello Genius"
},
"Window prompt() Method": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "promt",
"body": ["const ${1:userInput} = prompt('${2:What is your name?}');"],
"description": "Window prompt() Method"
},
"for loop": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "for",
"body": [
"for (let x = 0; x < 10; x++) {",
" ${1:console.log('hello');}",
"}"
],
"description": "for loop"
},
"for loop in": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "forin",
"body": [
"for (let x in ${1:object}) {",
" ${2:console.log('hello');}",
"}"
],
"description": "for loop"
},
"Javascript arrow function": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "func",
"body": [
"const $myfunc = () => {",
"$0",
" console.log('hello');",
"};",
"",
"$myfunc();",
""
],
"description": "Javascript arrow function"
},
"Conditional (ternary) operator": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "ternary",
"body": ["const check = (${1:condition}) ? ${2:ifTrue} : ${3:ifFalse};"],
"description": "Conditional (ternary) operator"
},
"JavaScript Switch Statement": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "switch",
"body": [
"switch(${1:key}) {",
" case x:",
" // code block",
" break;",
" case y:",
" // code block",
" break;",
" default:",
" // code block",
"}"
],
"description": "JavaScript Switch Statement"
},
"Asynchronously request for a resource with fetch() method": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "fetch",
"body": [
"fetch('${1:example}')",
" .then(res=>res.json())",
" .then(json=>console.log(json))",
"$0"
],
"description": "Asynchronously request for a resource with fetch() method"
},
"Get element by Id": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "getid",
"body": ["const $el = document.getElementById('$el');", "$0"],
"description": "Get element by Id"
},
"Get element by Class": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "getclass",
"body": ["const $el = document.getElementsByClassName('$el');", "$0"],
"description": "Get element by Class"
},
"DOM querySelectorAll() Method": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "getquery",
"body": [
"",
" const ${1:example} = document.querySelector('#${1:example}');"
],
"description": "DOM querySelectorAll() Method"
},
"Placeholder {JSON} ": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "placeholderapi",
"body": ["`https://jsonplaceholder.typicode.com/post`"],
"description": "Placeholder {JSON} "
},
"Placeholder Image": {
"scope": "html,javascript,javascriptreact,typescript,typescriptreact",
"prefix": "getimg",
"body": ["https://via.placeholder.com/300"],
"description": "Placeholder Image"
},
// ################ react ################
// import libraries
"import react": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "impreact",
"body": ["import React from 'react';"],
"description": "import react"
},
"import useState": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "impstate",
"body": ["import {useState} from 'react';"],
"description": "import useState from react"
},
"import useEffect": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "impeffect",
"body": ["import {useEffect} from 'react';"],
"description": "import useEffect from react"
},
"import styled component": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "impstyled",
"body": ["import styled from 'styled-components';"],
"description": "import styled component"
},
"import react-bootstrap": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "impboot",
"body": [
"import { Button, Container, Row, Col, Nav, Navbar, Dropdown} from 'react-bootstrap';"
],
"description": "import react-bootstrap"
},
"import react-router-dom": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "improuter",
"body": [
"import {BrowserRouter as Router, Switch, Route, Link, NavLink} from \"react-router-dom\";"
],
"description": "import react-router-dom"
},
//implementation
"useEffect react hook": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "effect",
"body": ["useEffect(() => {", " $0 ", "},[]);"],
"description": "useEffect react hook"
},
"useState react hook": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "state",
"body": [
"const [${1/(.*)/${1:/camel}/}, set${1/(.)/${1:/capitalize}/}] = useState(${2:0});",
"$0"
],
"description": "useState react hook"
},
"React router implementation": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "router",
"body": [
"<Router>",
" <Switch>",
" <Route exact path=\"/${1:path}\" component={${1:component}} />",
" <Route exact path=\"/${2:path}\" component={${2:component}} />",
" <Route exact path=\"/${3:path}\" component={${3:component}} />",
" <Route component={${4:Error}} />",
" </Switch>",
"</Router>"
],
"description": "React router implementation"
},
"React functional component": {
"prefix": "rafce",
"body": [
"",
"const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} = () => {",
" return (",
" <>",
" <h1>${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}</h1>",
" </>",
" )",
"}",
"",
"export default ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/};"
],
"description": "React functional component"
},
"Next functional component": {
"prefix": "_rafce",
"body": [
"",
"const ${TM_DIRECTORY/.*\\/(.*)/${1:/pascalcase}/} = () => {",
" return (",
" <>",
" <h1>${TM_DIRECTORY/.*\\/(.*)/${1:/pascalcase}/}</h1>",
" </>",
" )",
"}",
"",
"export default ${TM_DIRECTORY/.*\\/(.*)/${1:/pascalcase}/};"
],
"description": "React functional component"
},
// ################ css ################
"Globals CSS": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "*{}",
"body": [
"*{",
" box-sizing: border-box;",
" margin: 0;",
" padding: 0;",
" scroll-behavior: smooth;",
"}"
],
"description": "Globals CSS"
},
"User select property": {
"scope": "javascript,javascriptreact,typescript,typescriptreact",
"prefix": "user-select",
"body": [
"-webkit-user-drag: none;",
"user-select: none;",
"-webkit-user-select: none;",
"-ms-user-select: none;"
],
"description": "User select property"
}
}