Skip to content

Instantly share code, notes, and snippets.

@melgish
Last active January 4, 2022 12:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melgish/44ce3f9ddd5e5f476bfb5ec5fa7c205e to your computer and use it in GitHub Desktop.
Save melgish/44ce3f9ddd5e5f476bfb5ec5fa7c205e to your computer and use it in GitHub Desktop.
random snippets
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Describe": {
"body": [
"describe('${1:Component}', () => {",
"\t$0",
"",
"});"
],
"description": "Insert describe() section.",
"prefix": "jdes",
"scope": "typescript, typescriptreact, javascript, javascriptreact"
},
"Test": {
"body": [
"it('${1:should}', () => {",
"\t$0",
"",
"});"
],
"description": "Insert jest/jasmine test block.",
"prefix": "jit",
"scope": "typescript,typescriptreact,javascript,javascriptreact"
},
"Async Test": {
"body": [
"it('${1:should}', async done => {",
"\t$0",
"",
"\tdone();",
"});"
],
"description": "Insert async jest/jasmine test block.",
"prefix": "jita",
"scope": "typescript, typescriptreact, javascript, javascriptreact"
},
"Before Each": {
"body": [
"beforeEach(() => {",
"\t$0",
"",
"});"
],
"description": "Insert beforeEach block.",
"prefix": "jbe",
"scope": "typescript, typescriptreact, javascript, javascriptreact"
},
"Async Before Each": {
"body": [
"beforeEach(async done => {",
"\t$0",
"",
"\tdone();",
"});"
],
"description": "Insert async beforEach block",
"prefix": "jbea",
"scope": "typescript, typescriptreact, javascript, javascriptreact"
},
"React Functional Component": {
"body": [
"import { FC, useMemo, useEffect, useCallback } from \"react\";",
"",
"",
"/**",
" * Properties for the $1 component.",
" */",
"export interface ${1:Component}Props {",
"\t$0",
"}",
"",
"/**",
" * Default Properties for the $1 component.",
" */",
"const defaultProps: Partial<$1Props> = {",
"",
"}",
"",
"/**",
" * The $1 component.",
" */",
"export const $1: FC<$1Props> = (props) => {",
" const { } = props;",
"",
" return <p>The $1 Works</p>;",
"}",
"",
"// Assign defaultProps to the component.",
"$1.defaultProps = defaultProps;",
""
],
"description": "React component file starter.",
"prefix": "rfc",
"scope": "typescriptreact"
},
"React Component Property": {
"body": [
"/**",
" * ${3:What does it affect?}",
" * @default $4",
" */",
" ${1:name}: ${2:string};",
"",
"$0"
],
"description": "Typescript property with comment.",
"prefix": "rcp",
"scope": "typescript, typescriptreact"
},
"Match Inline Snapshot": {
"body": [
"expect(${1:thing}).toMatchInlineSnapshot();",
"$0"
],
"description": "Add expectation",
"prefix": "exis",
"scope": "typescript, typescriptreact, javascript, javascriptreact"
},
"FontAwesomeIcon": {
"body": [
"<FontAwesomeIcon icon={$1:faTimes}/>",
"$0"
],
"description": "Add Icon",
"prefix": "fa",
"scope": "typescriptreact, javascriptreact"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment