|
| 1 | +{ |
| 2 | + "Arrow Function": { |
| 3 | + "prefix": "af", |
| 4 | + "body": ["($1) => { $2 }"], |
| 5 | + "description": "arrow function" |
| 6 | + }, |
| 7 | + "Export Function": { |
| 8 | + "prefix": "ef", |
| 9 | + "body": [ |
| 10 | + "export function ${1:name}()$2 {", |
| 11 | + "\treturn $3;", |
| 12 | + "}" |
| 13 | + ], |
| 14 | + "description": "Export Function" |
| 15 | + }, |
| 16 | + "Export Default Function": { |
| 17 | + "prefix": "edf", |
| 18 | + "body": [ |
| 19 | + "export default function ${1:name}()$2 {", |
| 20 | + "\treturn $3;", |
| 21 | + "}" |
| 22 | + ], |
| 23 | + "description": "Export Default Function" |
| 24 | + }, |
| 25 | + "Function": { |
| 26 | + "prefix": "func", |
| 27 | + "body": [ |
| 28 | + "function ${1:name}()$2 {", |
| 29 | + "\treturn $3;", |
| 30 | + "}" |
| 31 | + ], |
| 32 | + "description": "Function" |
| 33 | + }, |
| 34 | + "Async Function": { |
| 35 | + "prefix": "async", |
| 36 | + "body": [ |
| 37 | + "async function ${1:name}()$2 {", |
| 38 | + "\treturn $3;", |
| 39 | + "}" |
| 40 | + ], |
| 41 | + "description": "Async function" |
| 42 | + }, |
| 43 | + "For Loop": { |
| 44 | + "prefix": "for", |
| 45 | + "body": [ |
| 46 | + "for (let ${1:index} = 0; ${1:index} < ${2:array}.length; ${1:index}++) {", |
| 47 | + "\tconst ${3:element} = ${2:array}[${1:index}];", |
| 48 | + "\t$0", |
| 49 | + "}" |
| 50 | + ], |
| 51 | + "description": "For Loop" |
| 52 | + }, |
| 53 | + "For-Each Loop using =>": { |
| 54 | + "prefix": "foreach =>", |
| 55 | + "body": ["${1:array}.forEach(${2:element} => {", "\t$0", "});"], |
| 56 | + "description": "For-Each Loop using =>" |
| 57 | + }, |
| 58 | + "For-In Loop": { |
| 59 | + "prefix": "forin", |
| 60 | + "body": [ |
| 61 | + "for (const ${1:key} in ${2:object}) {", |
| 62 | + "\tif (${2:object}.hasOwnProperty(${1:key})) {", |
| 63 | + "\t\tconst ${3:element} = ${2:object}[${1:key}];", |
| 64 | + "\t\t$0", |
| 65 | + "\t}", |
| 66 | + "}" |
| 67 | + ], |
| 68 | + "description": "For-In Loop" |
| 69 | + }, |
| 70 | + "For-Of Loop": { |
| 71 | + "prefix": "forof", |
| 72 | + "body": ["for (const ${1:iterator} of ${2:object}) {", "\t$0", "}"], |
| 73 | + "description": "For-Of Loop" |
| 74 | + }, |
| 75 | + "Switch Statement": { |
| 76 | + "prefix": "switch", |
| 77 | + "body": [ |
| 78 | + "switch (${1:key}) {", |
| 79 | + "\tcase ${2:value}:", |
| 80 | + "\t\t$0", |
| 81 | + "\t\tbreak;", |
| 82 | + "", |
| 83 | + "\tdefault:", |
| 84 | + "\t\tbreak;", |
| 85 | + "}" |
| 86 | + ], |
| 87 | + "description": "Switch Statement" |
| 88 | + }, |
| 89 | + "Try-Catch Statement": { |
| 90 | + "prefix": "try", |
| 91 | + "body": ["try {", "\t$0", "} catch (${1:error}) {", "\t", "}"], |
| 92 | + "description": "Try-Catch Statement" |
| 93 | + }, |
| 94 | + "import destructing": { |
| 95 | + "key": "importDestructing", |
| 96 | + "prefix": "imd", |
| 97 | + "body": ["import { ${2:second} } from '${1:first}'"], |
| 98 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 99 | + }, |
| 100 | + "import default": { |
| 101 | + "key": "import", |
| 102 | + "prefix": "imp", |
| 103 | + "body": ["import ${2:second} from '${1:first}'"], |
| 104 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 105 | + }, |
| 106 | + "import react": { |
| 107 | + "key": "import react", |
| 108 | + "prefix": "imr", |
| 109 | + "body": ["import React from 'react';"], |
| 110 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 111 | + }, |
| 112 | + "import test": { |
| 113 | + "key": "importTest", |
| 114 | + "prefix": "imt", |
| 115 | + "body": [ |
| 116 | + "import React from 'react';", |
| 117 | + "import {screen, render, fireEvent, waitFor} from '@testing-library/react';", |
| 118 | + "import user from '@testing-library/user-event';" |
| 119 | + ], |
| 120 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 121 | + }, |
| 122 | + "require": { |
| 123 | + "key": "require", |
| 124 | + "prefix": "requ", |
| 125 | + "body": ["const { ${2:second} } = require('${1:first}')"], |
| 126 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 127 | + }, |
| 128 | + "setInterval": { |
| 129 | + "key": "setInterval", |
| 130 | + "prefix": "sti", |
| 131 | + "body": ["setInterval(() => { ${1:first} }, ${2:second})"], |
| 132 | + "description": "Executes the given function at specified intervals", |
| 133 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 134 | + }, |
| 135 | + "setTimeOut": { |
| 136 | + "key": "setTimeOut", |
| 137 | + "prefix": "sto", |
| 138 | + "body": ["setTimeout(() => { ${1:first} }, ${2:second})"], |
| 139 | + "description": "Executes the given function after the specified delay", |
| 140 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 141 | + }, |
| 142 | + "promise": { |
| 143 | + "key": "promise", |
| 144 | + "prefix": "prom", |
| 145 | + "body": ["return new Promise((resolve, reject) => { ${1:first} })"], |
| 146 | + "description": "Creates and returns a new Promise in the standard ES7 syntax", |
| 147 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 148 | + }, |
| 149 | + "------------------------------------------------------------------------": { |
| 150 | + "body": "console.xxx()" |
| 151 | + }, |
| 152 | + "Console Assert": { |
| 153 | + "prefix": "cas", |
| 154 | + "body": "console.assert(${1:expression}, ${2:object})", |
| 155 | + "description": "If the specified expression is false, the message is written to the console along with a stack trace" |
| 156 | + }, |
| 157 | + "Console Clear": { |
| 158 | + "prefix": "ccl", |
| 159 | + "body": "console.clear()", |
| 160 | + "description": "Clears the console" |
| 161 | + }, |
| 162 | + "Console Count": { |
| 163 | + "prefix": "cco", |
| 164 | + "body": "console.count(${1:label})", |
| 165 | + "description": "Writes the the number of times that count() has been invoked at the same line and with the same label" |
| 166 | + }, |
| 167 | + "Console Dir": { |
| 168 | + "prefix": "cdi", |
| 169 | + "body": "console.dir(${1:object})", |
| 170 | + "description": "Prints a JavaScript representation of the specified object" |
| 171 | + }, |
| 172 | + "Console Error": { |
| 173 | + "prefix": "cer", |
| 174 | + "body": "console.error(${1:object})", |
| 175 | + "description": "Displays a message in the console and also includes a stack trace from where the method was called" |
| 176 | + }, |
| 177 | + "Console Group": { |
| 178 | + "prefix": "cgr", |
| 179 | + "body": "console.group(\"${1:label}\")", |
| 180 | + "description": "Groups and indents all following output by an additional level, until console.groupEnd() is called." |
| 181 | + }, |
| 182 | + "Console Group End": { |
| 183 | + "prefix": "cge", |
| 184 | + "body": "console.groupEnd()", |
| 185 | + "description": "Closes out the corresponding console.group()." |
| 186 | + }, |
| 187 | + "Console Log": { |
| 188 | + "prefix": "clg", |
| 189 | + "body": "console.log(${1:object})", |
| 190 | + "description": "Displays a message in the console" |
| 191 | + }, |
| 192 | + "Console Log": { |
| 193 | + "prefix": "log", |
| 194 | + "body": "console.log(${1:object})", |
| 195 | + "description": "Displays a message in the console" |
| 196 | + }, |
| 197 | + "Console Trace": { |
| 198 | + "prefix": "ctr", |
| 199 | + "body": "console.trace(${1:object})", |
| 200 | + "description": "Prints a stack trace from the point where the method was called" |
| 201 | + }, |
| 202 | + "Console Warn": { |
| 203 | + "prefix": "cwa", |
| 204 | + "body": "console.warn(${1:object})", |
| 205 | + "description": "Displays a message in the console but also displays a yellow warning icon along with the logged message" |
| 206 | + }, |
| 207 | + "Console Info": { |
| 208 | + "prefix": "cin", |
| 209 | + "body": "console.info(${1:object})", |
| 210 | + "description": "Displays a message in the console but also displays a blue information icon along with the logged message" |
| 211 | + }, |
| 212 | + "------------------------------------------------------------------------": { |
| 213 | + "body": "react hooks" |
| 214 | + }, |
| 215 | + "typescriptReactFunctionalExportComponent": { |
| 216 | + "key": "typescriptReactFunctionalExportComponent", |
| 217 | + "prefix": "rfc", |
| 218 | + "body": [ |
| 219 | + "import React from 'react'", |
| 220 | + "", |
| 221 | + "type ${2}Props = {}", |
| 222 | + "", |
| 223 | + "export const ${1:${TM_FILENAME_BASE}} = (props: ${2}Props) => {", |
| 224 | + " return (", |
| 225 | + " <div>${1:first}</div>", |
| 226 | + " )", |
| 227 | + "}", |
| 228 | + "" |
| 229 | + ], |
| 230 | + "description": "Creates a React Functional Component with ES7 module system and TypeScript interface", |
| 231 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 232 | + }, |
| 233 | + "useState": { |
| 234 | + "prefix": "useState", |
| 235 | + "body": [ |
| 236 | + "const [${1:state}, set${2:state}] = useState(${3:initialState})" |
| 237 | + ] |
| 238 | + }, |
| 239 | + "setState": { |
| 240 | + "prefix": "setS", |
| 241 | + "body": [ |
| 242 | + "set${1:State}((state)=>({", |
| 243 | + "\t...state,", |
| 244 | + "\t${2:loading : true},", |
| 245 | + "}))" |
| 246 | + ] |
| 247 | + }, |
| 248 | + "useEffect": { |
| 249 | + "prefix": "useEffect", |
| 250 | + "body": [ |
| 251 | + "useEffect(() => {", |
| 252 | + "\t${1:effect}", |
| 253 | + "\treturn () => {", |
| 254 | + "\t\t${2:cleanup}", |
| 255 | + "\t}", |
| 256 | + "}, [${3:input}])" |
| 257 | + ] |
| 258 | + }, |
| 259 | + "useContext": { |
| 260 | + "prefix": "useContext", |
| 261 | + "body": ["const ${1:context} = useContext(${2:contextValue})"] |
| 262 | + }, |
| 263 | + "useReducer": { |
| 264 | + "prefix": "useReducer", |
| 265 | + "body": [ |
| 266 | + "const [state, dispatch] = useReducer(${1:reducer}, ${2:initialState}, ${3:init})" |
| 267 | + ] |
| 268 | + }, |
| 269 | + "useCallback": { |
| 270 | + "prefix": "useCallback", |
| 271 | + "body": [ |
| 272 | + "useCallback(", |
| 273 | + "\t() => {", |
| 274 | + "\t\t${1:callback}", |
| 275 | + "\t},", |
| 276 | + "\t[${2:input}],", |
| 277 | + ")" |
| 278 | + ] |
| 279 | + }, |
| 280 | + "useMemo": { |
| 281 | + "prefix": "useMemo", |
| 282 | + "body": ["useMemo(() => ${1:function}, ${2:input})"] |
| 283 | + }, |
| 284 | + "useRef": { |
| 285 | + "prefix": "useRef", |
| 286 | + "body": ["const ${1:ref} = useRef(${2:initialValue})"] |
| 287 | + }, |
| 288 | + "useImperativeHandle": { |
| 289 | + "prefix": "useImperativeHandle", |
| 290 | + "body": [ |
| 291 | + "useImperativeHandle(", |
| 292 | + "\t${1:ref},", |
| 293 | + "\t() => {", |
| 294 | + "\t\t${2:handler}", |
| 295 | + "\t},", |
| 296 | + "\t[${3:input}],", |
| 297 | + ")" |
| 298 | + ] |
| 299 | + }, |
| 300 | + "useDebugValue": { |
| 301 | + "prefix": "useDebugValue", |
| 302 | + "body": ["useDebugValue(${1:value})"] |
| 303 | + }, |
| 304 | + "useLayoutEffect": { |
| 305 | + "prefix": "useLayoutEffect", |
| 306 | + "body": [ |
| 307 | + "useLayoutEffect(() => {", |
| 308 | + "\t${1:effect}", |
| 309 | + "\treturn () => {", |
| 310 | + "\t\t${2:cleanup}", |
| 311 | + "\t};", |
| 312 | + "}, [${3:input}])" |
| 313 | + ] |
| 314 | + }, |
| 315 | + "useSelector": { |
| 316 | + "prefix": "useSelector", |
| 317 | + "body": ["const ${1:state} = useSelector(state => state.${1:state})"] |
| 318 | + }, |
| 319 | + "useDispatch": { |
| 320 | + "prefix": "useDispatch", |
| 321 | + "body": ["const dispatch = useDispatch(${1:function})"] |
| 322 | + }, |
| 323 | + "------------------------------------------------------------------------": { |
| 324 | + "body": "jest - test" |
| 325 | + }, |
| 326 | + "describeBlock": { |
| 327 | + "key": "describeBlock", |
| 328 | + "prefix": "desc", |
| 329 | + "body": [ |
| 330 | + "describe('${1:first}', () => { ", |
| 331 | + "\tit('${2:should}', ${3|,async |}() => {", |
| 332 | + "\t\texpect($4)$5", |
| 333 | + "\t})", |
| 334 | + "})" |
| 335 | + ], |
| 336 | + "description": "Testing `describe` block", |
| 337 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 338 | + }, |
| 339 | + "itBlock": { |
| 340 | + "key": "itBlock", |
| 341 | + "prefix": "it", |
| 342 | + "body": ["it('${2:should }', ${3|,async |}() => {", "\t$4", "})"], |
| 343 | + "description": "Testing `it` block", |
| 344 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 345 | + }, |
| 346 | + "beforeEach": { |
| 347 | + "key": "beforeEach", |
| 348 | + "prefix": "beforeEach", |
| 349 | + "body": ["beforeEach(() => {", "\t${1}", "})"], |
| 350 | + "description": "Testing `beforeEach` block", |
| 351 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 352 | + }, |
| 353 | + "afterEach": { |
| 354 | + "key": "afterEach", |
| 355 | + "prefix": "afterEach", |
| 356 | + "body": ["afterEach(() => {", "\t${1}", "})"], |
| 357 | + "description": "Testing `afterEach` block", |
| 358 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 359 | + }, |
| 360 | + "beforeAll": { |
| 361 | + "key": "beforeAll", |
| 362 | + "prefix": "beforeAll", |
| 363 | + "body": ["beforeAll(() => {", "\t${1}", "})"], |
| 364 | + "description": "Testing `beforeAll` block", |
| 365 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 366 | + }, |
| 367 | + "afterAll": { |
| 368 | + "key": "afterAll", |
| 369 | + "prefix": "afterAll", |
| 370 | + "body": ["afterAll(() => {", "\t${1}", "})"], |
| 371 | + "description": "Testing `afterAll` block", |
| 372 | + "scope": "typescript,typescriptreact,javascript,javascriptreact" |
| 373 | + } |
| 374 | +} |
0 commit comments