Skip to content

Instantly share code, notes, and snippets.

@Icaruk
Created February 16, 2022 11:12
Show Gist options
  • Save Icaruk/d5312a892c4d8a4c8e163b136e0d6b39 to your computer and use it in GitHub Desktop.
Save Icaruk/d5312a892c4d8a4c8e163b136e0d6b39 to your computer and use it in GitHub Desktop.
VSC Snippets
{
"LOG": {
"prefix": ["cl", "clog", "log"],
"body": ["console.log( ${1:string} );"]
},
"LOG $": {
"prefix": ["clf", "logf"],
"body": ["console.log ( `${1:Texto} \\${${2:123}\\}` );"]
},
"LOG DEBUG": {
"prefix": ["cld", "logd"],
// "body": ["console.log( \"${1:string} :\", ${1} );"]
"body": ["console.log( `${1:var} (${typeof ${1:var}}):`, ${1:var} );"]
},
"LOG WARN": {
"prefix": "cw",
"body": ["console.warn( ${1:string} );"]
},
"LOG ERROR": {
"prefix": "ce",
"body": ["console.error( ${1:string} );"]
},
"Require": {
"scope": "javascript, javascriptreact",
"prefix": "req",
"body": ["const ${2:package} = require(\"${1:route}\");"]
},
"Import": {
"scope": "javascript, javascriptreact",
"prefix": "imp",
"body": ["import ${2:package} from \"${1:package}\";"]
},
"Import {}": {
"scope": "javascript, javascriptreact",
"prefix": "imp{",
"body": ["import { ${2:package} } from \"${1:package}\";"]
},
"Export default": {
"scope": "javascript, javascriptreact",
"prefix": "ed",
"body": ["export default ${1:package};"]
},
"New component": {
"scope": "javascript, javascriptreact",
"prefix": "nc",
"body": [
"",
"import React from \"react\";\r\r\r\r",
"export default function ${TM_FILENAME_BASE/(.*)/${1:/capitalcase}/g}() {\r",
"\t",
"\t",
"\treturn (\r",
"\t\t",
"\t\t<div\r",
"\t\t\tclassName=\"main-${TM_FILENAME_BASE/(.*)/${1:/downcase}/g}\"\r",
"\t\t>\r",
"\t\t\t<h1>Soy ${TM_FILENAME_BASE/(.*)/${1:/downcase}/g}</h1>\r",
"\t\t</div>\r",
"\t\t",
"\t);\r",
"\t",
"};\r\r\r",
]
},
"singleton": {
"scope": "javascript, javascriptreact",
"prefix": "singleton",
"body": [
"",
"class ${1:SingletonName} {",
"\t",
"\tconstructor() {",
"\t\t",
"\t\tif (typeof ${1:SingletonName}.instance === \"object\") return ${1:SingletonName}.instance;",
"\t\t${1:SingletonName}.instance = this;",
"\t\t",
"\t\treturn this;",
"\t};",
"\t",
"};",
"",
]
},
"jsdoc component": {
"scope": "javascript, javascriptreact",
"prefix": "jsdoccomponent",
"body": [
"",
"/**",
" * @typedef Props",
" * @property {string} propiedad1",
"*/",
"",
"/**",
" * ",
" * @param {Props} Props.",
"*/",
"",
]
},
"useState": {
"scope": "javascript, javascriptreact",
"prefix": ["us", "useS"],
"body": ["const [${1}, set${1/(.*)/${1:/capitalize}/}] = useState(null);"]
},
"useDispatch": {
"scope": "javascript, javascriptreact",
"prefix": "ud",
"body": ["const dispatch = useDispatch();"]
},
"useSelector": {
"scope": "javascript, javascriptreact",
"prefix": "use",
"body": ["const ${1} = useSelector(state => state.${2});"]
},
"useEffect": {
"scope": "javascript, javascriptreact",
"prefix": ["ue", "useE"],
"body": [
"useEffect( () => {",
"\t$2",
"}, [$1]);"
]
},
"useReducer": {
"scope": "javascript, javascriptreact",
"prefix": "ur",
"body": [
"const [${1}, set${1/(.*)/${1:/capitalize}/}] = useReducer(",
"\t(state, {key, value}) => {",
"\t\t",
"\t\tif (key === \"\\$\\$ROOT\") return value;",
"\t\t",
"\t\tconst _state = {...state};",
"\t\t_state[key] = value;",
"\t\treturn _state;",
"\t},",
"\t{}",
");",
]
},
"Const arrow fnc": {
"scope": "javascript, javascriptreact",
"prefix": "caf",
"body": [
"const ${1:name} = () => {",
"\t",
"};"
]
},
"Arrow fnc": {
"scope": "javascript, javascriptreact",
"prefix": "af",
"body": [
"() => {",
"\t${1:code}",
"};"
]
},
"Immediately invoked function expression": {
"scope": "javascript, javascriptreact",
"prefix": "iife",
"body": [
"(async() => {",
"\t${1:code}",
"})();"
]
},
"---1": {
"prefix": "lin1",
"body": "// -------------------------------"
},
"---2": {
"prefix": "lin2",
"body": "// ---------------------------------------------------------------"
},
"---3": {
"prefix": "lin3",
"body": "// -------------------------------------------------------------------------------------------------------------------------------"
},
"// ###": {
"prefix": "comm1",
"body": [
"// ############################################################",
"// ${1}",
"// ############################################################"
]
},
"// ***": {
"prefix": "comm2",
"body": [
"// ***********************************************************",
"// ${1}",
"// ***********************************************************",
]
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment