From dfa2d9e188e1ef44a72f4f60ec28180a55b11743 Mon Sep 17 00:00:00 2001 From: AminurAlam <64137875+AminurAlam@users.noreply.github.com> Date: Mon, 2 Dec 2024 01:12:03 +0000 Subject: [PATCH 01/27] lua: fix snippets (#505) --- snippets/lua/lua.json | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/snippets/lua/lua.json b/snippets/lua/lua.json index 0da132f4..fdafb237 100644 --- a/snippets/lua/lua.json +++ b/snippets/lua/lua.json @@ -1,7 +1,7 @@ { "require": { "prefix": "req", - "body": ["require(\"${1:module}\")"], + "body": ["require(${1:module})"], "description": "Require module" }, "return": { @@ -12,26 +12,24 @@ "assigment": { "prefix": "ll", "body": ["local ${1:varName} = ${0:value}"], - "description": "create a variable" + "description": "define a variable" }, "local": { "prefix": "l", "body": ["local ${0}"], - "description": "create a variable" + "description": "declare a variable" }, "locreq": { "prefix": "lreq", - "body": ["local ${1:var} = require(\"${2:module}\")"], + "body": ["local ${1:var} = require(${2:module})"], "description": "Require module as a variable" }, "class": { "prefix": "cl", "body": [ - "${1:className} = {}\n", + "${1:M} = {}\n", "$1.${2:new} = function($3)", - "\tlocal ${4:varName} = ${5:value}\n", - "\t${6: --code}\n", - "\treturn $4", + "\t${6}", "end" ], "description": "Create a class" @@ -56,22 +54,22 @@ "forline": { "prefix": "forline", "body": [ - "f = io.open(${1:\"${2:filename}\"}, \"${3:r}\")\n", + "local f = io.open(${1:${2:filename}}, \"${3:r}\")\n", "while true do", "\tline = f:read()", "\tif line == nil then break end\n", - "\t${0:-- code}", + "\t${0}", "end" ], "description": "read file line by line" }, "function": { "prefix": "fu", - "body": ["function ${1:name}($2)", "\t${0:-- code}", "end"] + "body": ["function ${1:name}($2)", "\t${0}", "end"] }, "inline-function": { "prefix": "f=", - "body": ["local ${1:name} = function($2)", "\t${0:-- code}", "end"] + "body": ["local ${1:name} = function($2)", "\t${0}", "end"] }, "print": { "prefix": "p", From 59c18134ac92bb9444f9e37fd52ea428b4065e9f Mon Sep 17 00:00:00 2001 From: Eveeifyeve <88671402+Eveeifyeve@users.noreply.github.com> Date: Mon, 2 Dec 2024 12:36:01 +1100 Subject: [PATCH 02/27] fix: issues with pr #491 (#531) * fix(zig): fix buildexe name escape * fix(zig): libraries spelling * chore(zig): removed an unneeded comma * fix(zig): json formatting * fix(cmake): package json formatting * chore(zig): reformatted zig json to proper standard --- package.json | 8 ++++---- snippets/zig.json | 50 ++++++++++++++++++++++------------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/package.json b/package.json index 1c6c7167..f33d7b10 100644 --- a/package.json +++ b/package.json @@ -584,10 +584,10 @@ "language": "loremipsum", "path": "./snippets/loremipsum.json" }, - { - "language": "cmake", - "path": "./snippets/cmake.json" - }, + { + "language": "cmake", + "path": "./snippets/cmake.json" + }, { "language": "zig", "path": "./snippets/zig.json" diff --git a/snippets/zig.json b/snippets/zig.json index 7a06b3ee..19a72c4b 100644 --- a/snippets/zig.json +++ b/snippets/zig.json @@ -1,29 +1,25 @@ { - "Import": { - "prefix": "import", - "body": ["const ${1} = @import(\"${1}\")"], - "description": "Importing Librarys" - }, - "CImport": { - "prefix": "cimport", - "body": [ - "const c = @cImport({", - "@cDefine(\"${1}\")", - "});" - ], - "description": "Importing C Header Files" - }, - "buildExe": { - "prefix": "bExe", - "body": [ - "const exe = b.addExecutable(.{", - ".name = \"${1}",\", - ".root_source_file = b.path(\"${2: path}\"),", - ".target = target,", - ".optimize = optimize,", - "});", - "\n\n\n b.installArtifact(exe);", - ], - "description": "Building an exe" - } + "Import": { + "prefix": "import", + "body": ["const ${1} = @import(\"${1}\")"], + "description": "Importing Libraries" + }, + "CImport": { + "prefix": "cimport", + "body": ["const c = @cImport({", " @cDefine(\"${1}\")", "});"], + "description": "Importing C Header Files" + }, + "buildExe": { + "prefix": "bExe", + "body": [ + "const exe = b.addExecutable(.{", + " .name = \"${1}\",", + " .root_source_file = b.path(\"${2:path}\"),", + " .target = target,", + " .optimize = optimize,", + "});", + "b.installArtifact(exe);" + ], + "description": "Building an exe" + } } From 4b320fe7e34723b8f07edda3935143c6b7323ba5 Mon Sep 17 00:00:00 2001 From: Fredrik Averpil Date: Mon, 2 Dec 2024 02:55:24 +0100 Subject: [PATCH 03/27] fix(go): "if err != nil" (`ir~`) (#522) The snippets in go.json works great, except this one. It causes an error. --- snippets/go.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/go.json b/snippets/go.json index 5f1fb609..02209ae0 100644 --- a/snippets/go.json +++ b/snippets/go.json @@ -116,7 +116,7 @@ }, "if err != nil": { "prefix": "ir", - "body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}", + "body": "if err != nil {\n\treturn ${1:nil}, ${2:err}\n}", "description": "Snippet for if err != nil" }, "fmt.Println": { From 93c2af7842a7775972a077836105467f139b7df1 Mon Sep 17 00:00:00 2001 From: Karanveer B <52545097+KaranveerB@users.noreply.github.com> Date: Sun, 1 Dec 2024 17:59:19 -0800 Subject: [PATCH 04/27] Fix typo of foreign in sql snippets (#518) --- snippets/sql.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/sql.json b/snippets/sql.json index 1e656258..d47c3d17 100644 --- a/snippets/sql.json +++ b/snippets/sql.json @@ -224,15 +224,15 @@ "body": ["CONSTRAINT ${1:attribute} PRIMARY KEY(${2:attribute(s)})"], "description": "Constraint Primary Key" }, - "foreingk": { - "prefix": "foreingk", + "foreignk": { + "prefix": "foreignk", "body": [ "FOREIGN KEY(${1:attribute}) REFERENCES ${2:tableName}(${3:attribute})" ], "description": "Foreign Key" }, - "foreingkc": { - "prefix": "foreingkc", + "foreignkc": { + "prefix": "foreignkc", "body": [ "CONSTRAINT ${1:attribute} FOREIGN KEY (${2:attribute(s)})", "\tREFERENCES ${3:tableName}(${4:attribute})" From 2f12a938a81740dd0631fb917ca5667e190c098e Mon Sep 17 00:00:00 2001 From: Urmish Shah <33273194+surmish@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:02:17 -0800 Subject: [PATCH 05/27] file print string needs to be a separate placeholder (#508) --- snippets/perl.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.json b/snippets/perl.json index c45b5013..807dc2ad 100644 --- a/snippets/perl.json +++ b/snippets/perl.json @@ -92,7 +92,7 @@ }, "print to file": { "prefix": "file print", - "body": ["print \\$${1:fh} \"${1:string}\\n\";"] + "body": ["print \\$${1:fh} \"${2:string}\\n\";"] }, "read file into a scalar": { "prefix": "slurp", From 8a934f901090c23bc58d416335cb9780a271ad2b Mon Sep 17 00:00:00 2001 From: c24-tj <144437372+c24-tj@users.noreply.github.com> Date: Mon, 2 Dec 2024 03:18:04 +0100 Subject: [PATCH 06/27] Add enum snippet for php (#511) --- snippets/php/php.json | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/snippets/php/php.json b/snippets/php/php.json index 88e365e7..10125055 100644 --- a/snippets/php/php.json +++ b/snippets/php/php.json @@ -251,5 +251,16 @@ "prefix": "vd", "body": ["var_dump($0);"], "description": "var_dump" + }, + "enum …": { + "prefix": "enum", + "body": [ + "enum ${1:EnumName}", + "{", + "\tcase $0;", + "}", + "" + ], + "description": "Enum definition" } } From f774bce11f520f0a89a21984109df4ab0aaeff72 Mon Sep 17 00:00:00 2001 From: multivac61 Date: Mon, 2 Dec 2024 02:19:28 +0000 Subject: [PATCH 07/27] elixir.json: Add "df" and "dfw" for one-liner functions (#519) * elixir.json: Add "df" and "dfw" for one-liner functions (with when guard) --- snippets/elixir.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/snippets/elixir.json b/snippets/elixir.json index d62cfc4b..7886f4a4 100644 --- a/snippets/elixir.json +++ b/snippets/elixir.json @@ -14,6 +14,16 @@ "body": ["defp ${1:name}() do", " $0", "end"], "description": "Define a private function" }, + "df": { + "prefix": "df", + "body": "def ${1:name}(), do: $0", + "description": "Define a one-liner function" + }, + "dfw": { + "prefix": "dfw", + "body": "def ${1:name}(${2:args}) when ${3:guard}, do: $0", + "description": "Define a one-liner function with when guard" + }, "IO.puts": { "prefix": "put", "body": "IO.puts($0)" From 7ab7eda993a5e652f75e30880f1fbe4340f7eb5e Mon Sep 17 00:00:00 2001 From: insidewhy <97685+insidewhy@users.noreply.github.com> Date: Mon, 2 Dec 2024 10:26:22 +0800 Subject: [PATCH 08/27] javascript/typescript: improve ifelse snippet (#532) --- snippets/javascript/javascript.json | 2 +- snippets/javascript/typescript.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/javascript/javascript.json b/snippets/javascript/javascript.json index 0de4d787..5500ecc8 100644 --- a/snippets/javascript/javascript.json +++ b/snippets/javascript/javascript.json @@ -631,7 +631,7 @@ }, "If-Else Statement": { "prefix": "ifelse", - "body": ["if (${1:condition}) {", "\t$0", "} else {", "\t", "}"], + "body": ["if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}"], "description": "If-Else Statement" }, "New Statement": { diff --git a/snippets/javascript/typescript.json b/snippets/javascript/typescript.json index 665aeff2..29b447a8 100644 --- a/snippets/javascript/typescript.json +++ b/snippets/javascript/typescript.json @@ -165,7 +165,7 @@ }, "If-Else Statement": { "prefix": "ifelse", - "body": ["if (${1:condition}) {", "\t$0", "} else {", "\t", "}"], + "body": ["if (${1:condition}) {", "\t$2", "} else {", "\t$0", "}"], "description": "If-Else Statement" }, "New Statement": { From efff286dd74c22f731cdec26a70b46e5b203c619 Mon Sep 17 00:00:00 2001 From: Heitor Augusto Date: Sun, 1 Dec 2024 23:27:50 -0300 Subject: [PATCH 09/27] Add more nix snippets (#506) * feat(nix): add with expression snippet * feat(nix): add inherit snippet --- snippets/nix.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/snippets/nix.json b/snippets/nix.json index 340f1bfe..8cb7cce2 100644 --- a/snippets/nix.json +++ b/snippets/nix.json @@ -93,5 +93,15 @@ "};" ], "description": "Nixpkgs' minimal meta attribute set" + }, + "with": { + "prefix": "with", + "body": ["with $1; $0;"], + "description": "with expression" + }, + "inherit": { + "prefix": "inherit", + "body": ["inherit $1;"], + "description": "inherit expression" } } From 1789b90e0973316639a33c7ae737acacdc63836a Mon Sep 17 00:00:00 2001 From: Nicholas O'Kelley Date: Sun, 1 Dec 2024 22:14:10 -0500 Subject: [PATCH 10/27] fix: rename duplicate key --- snippets/norg.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/norg.json b/snippets/norg.json index a5a32e54..974416e1 100644 --- a/snippets/norg.json +++ b/snippets/norg.json @@ -266,7 +266,7 @@ "body": ["^ ${1:title}", "${2:content}"], "description": "footnote (short version)" }, - "single_footnote": { + "ranged_single_footnote": { "prefix": "footnoter", "body": ["^^ ${1:title}", "${2:content}", "^^"], "description": "footnote (ranged version)" From cecc1f4ebca50fd24e206e9f9fc307c2ae600b8a Mon Sep 17 00:00:00 2001 From: Nicholas O'Kelley Date: Sun, 1 Dec 2024 22:15:04 -0500 Subject: [PATCH 11/27] chore: format json file --- snippets/norg.json | 530 ++++++++++++++++++++++----------------------- 1 file changed, 265 insertions(+), 265 deletions(-) diff --git a/snippets/norg.json b/snippets/norg.json index 974416e1..bde52d68 100644 --- a/snippets/norg.json +++ b/snippets/norg.json @@ -1,280 +1,280 @@ { - "h1": { - "prefix": "h1", - "body": ["* $0"], - "description": "level 1 heading" - }, - "h2": { - "prefix": "h2", - "body": ["** $0"], - "description": "level 2 heading" - }, - "h3": { - "prefix": "h3", - "body": ["*** $0"], - "description": "level 3 heading" - }, - "h4": { - "prefix": "h4", - "body": ["**** $0"], - "description": "level 4 heading" - }, - "h5": { - "prefix": "h5", - "body": ["***** $0"], - "description": "level 5 heading" - }, - "h6": { - "prefix": "h6", - "body": ["****** $0"], - "description": "level 6 heading" - }, + "h1": { + "prefix": "h1", + "body": ["* $0"], + "description": "level 1 heading" + }, + "h2": { + "prefix": "h2", + "body": ["** $0"], + "description": "level 2 heading" + }, + "h3": { + "prefix": "h3", + "body": ["*** $0"], + "description": "level 3 heading" + }, + "h4": { + "prefix": "h4", + "body": ["**** $0"], + "description": "level 4 heading" + }, + "h5": { + "prefix": "h5", + "body": ["***** $0"], + "description": "level 5 heading" + }, + "h6": { + "prefix": "h6", + "body": ["****** $0"], + "description": "level 6 heading" + }, - "hr": { - "prefix": "hr", - "body": ["___", "$0"], - "description": "horizontal rule" - }, + "hr": { + "prefix": "hr", + "body": ["___", "$0"], + "description": "horizontal rule" + }, - "bold": { - "prefix": "bold", - "body": ["*$0*"], - "description": "bold words" - }, - "italic": { - "prefix": "italic", - "body": ["/$0/"], - "description": "italic words" - }, - "underline": { - "prefix": "underline", - "body": ["_$0_"], - "description": "underline words" - }, - "spoiler": { - "prefix": "spoiler", - "body": ["!$0!"], - "description": "spoiler" - }, - "strikethrough": { - "prefix": "strikethrough", - "body": ["-$0-"], - "description": "strike through" - }, - "inlinecomment": { - "prefix": "inlinecomment", - "body": ["%$0%"], - "description": "inline comment" - }, + "bold": { + "prefix": "bold", + "body": ["*$0*"], + "description": "bold words" + }, + "italic": { + "prefix": "italic", + "body": ["/$0/"], + "description": "italic words" + }, + "underline": { + "prefix": "underline", + "body": ["_$0_"], + "description": "underline words" + }, + "spoiler": { + "prefix": "spoiler", + "body": ["!$0!"], + "description": "spoiler" + }, + "strikethrough": { + "prefix": "strikethrough", + "body": ["-$0-"], + "description": "strike through" + }, + "inlinecomment": { + "prefix": "inlinecomment", + "body": ["%$0%"], + "description": "inline comment" + }, - "inlinecode": { - "prefix": "inlinecode", - "body": ["`$0`"], - "description": "inline code" - }, - "code": { - "prefix": "code", - "body": ["@code ${1:lang}", "$0", "@end"], - "description": "code block" - }, + "inlinecode": { + "prefix": "inlinecode", + "body": ["`$0`"], + "description": "inline code" + }, + "code": { + "prefix": "code", + "body": ["@code ${1:lang}", "$0", "@end"], + "description": "code block" + }, - "data": { - "prefix": "data", - "body": ["@data", "$0", "@end"], - "description": "data tags" - }, + "data": { + "prefix": "data", + "body": ["@data", "$0", "@end"], + "description": "data tags" + }, - "link": { - "prefix": "link", - "body": ["{${1:object}}[${2:description}]"], - "description": "links" - }, - "anchor": { - "prefix": "anchor", - "body": ["[${1:description}]{${2:object}}"], - "description": "anchors" - }, + "link": { + "prefix": "link", + "body": ["{${1:object}}[${2:description}]"], + "description": "links" + }, + "anchor": { + "prefix": "anchor", + "body": ["[${1:description}]{${2:object}}"], + "description": "anchors" + }, - "subscript": { - "prefix": "subscript", - "body": [",$0,"], - "description": "subscript" - }, - "superscript": { - "prefix": "superscript", - "body": ["^$0^"], - "description": "superscript" - }, - "inlinemath": { - "prefix": "inlinemath", - "body": ["$$0$"], - "description": "inline math" - }, - "rigidmath": { - "prefix": "rigidmath", - "body": ["$|$0|$"], - "description": "inline math (rigid syntax version)" - }, - "math": { - "prefix": "math", - "body": ["@math", "$0", "@end"], - "description": "math block" - }, + "subscript": { + "prefix": "subscript", + "body": [",$0,"], + "description": "subscript" + }, + "superscript": { + "prefix": "superscript", + "body": ["^$0^"], + "description": "superscript" + }, + "inlinemath": { + "prefix": "inlinemath", + "body": ["$$0$"], + "description": "inline math" + }, + "rigidmath": { + "prefix": "rigidmath", + "body": ["$|$0|$"], + "description": "inline math (rigid syntax version)" + }, + "math": { + "prefix": "math", + "body": ["@math", "$0", "@end"], + "description": "math block" + }, - "table": { - "prefix": "table", - "body": ["@table", "$0", "@end"], - "description": "table" - }, + "table": { + "prefix": "table", + "body": ["@table", "$0", "@end"], + "description": "table" + }, - "unordered_list": { - "prefix": "ulist1", - "body": ["- ${1:item}"], - "description": "level 1 unordered list" - }, - "unordered_list_2": { - "prefix": "ulist2", - "body": ["-- ${1:item}"], - "description": "level 2 unordered list" - }, - "unordered_list_3": { - "prefix": "ulist3", - "body": ["--- ${1:item}"], - "description": "level 3 unordered list" - }, - "unordered_list_4": { - "prefix": "ulist4", - "body": ["---- ${1:item}"], - "description": "level 4 unordered list" - }, - "unordered_list_5": { - "prefix": "ulist5", - "body": ["----- ${1:item}"], - "description": "level 5 unordered list" - }, - "unordered_list_6": { - "prefix": "ulist6", - "body": ["------ ${1:item}"], - "description": "level 6 unordered list" - }, + "unordered_list": { + "prefix": "ulist1", + "body": ["- ${1:item}"], + "description": "level 1 unordered list" + }, + "unordered_list_2": { + "prefix": "ulist2", + "body": ["-- ${1:item}"], + "description": "level 2 unordered list" + }, + "unordered_list_3": { + "prefix": "ulist3", + "body": ["--- ${1:item}"], + "description": "level 3 unordered list" + }, + "unordered_list_4": { + "prefix": "ulist4", + "body": ["---- ${1:item}"], + "description": "level 4 unordered list" + }, + "unordered_list_5": { + "prefix": "ulist5", + "body": ["----- ${1:item}"], + "description": "level 5 unordered list" + }, + "unordered_list_6": { + "prefix": "ulist6", + "body": ["------ ${1:item}"], + "description": "level 6 unordered list" + }, - "ordered_list": { - "prefix": "olist1", - "body": ["~ ${1:item}"], - "description": "level 1 ordered list" - }, - "ordered_list_2": { - "prefix": "olist2", - "body": ["~~ ${1:item}"], - "description": "level 2 ordered list" - }, - "ordered_list_3": { - "prefix": "olist3", - "body": ["~~~ ${1:item}"], - "description": "level 3 ordered list" - }, - "ordered_list_4": { - "prefix": "olist4", - "body": ["~~~~ ${1:item}"], - "description": "level 4 ordered list" - }, - "ordered_list_5": { - "prefix": "olist5", - "body": ["~~~~~ ${1:item}"], - "description": "level 5 ordered list" - }, - "ordered_list_6": { - "prefix": "olist6", - "body": ["~~~~~~ ${1:item}"], - "description": "level 6 ordered list" - }, + "ordered_list": { + "prefix": "olist1", + "body": ["~ ${1:item}"], + "description": "level 1 ordered list" + }, + "ordered_list_2": { + "prefix": "olist2", + "body": ["~~ ${1:item}"], + "description": "level 2 ordered list" + }, + "ordered_list_3": { + "prefix": "olist3", + "body": ["~~~ ${1:item}"], + "description": "level 3 ordered list" + }, + "ordered_list_4": { + "prefix": "olist4", + "body": ["~~~~ ${1:item}"], + "description": "level 4 ordered list" + }, + "ordered_list_5": { + "prefix": "olist5", + "body": ["~~~~~ ${1:item}"], + "description": "level 5 ordered list" + }, + "ordered_list_6": { + "prefix": "olist6", + "body": ["~~~~~~ ${1:item}"], + "description": "level 6 ordered list" + }, - "quote_1": { - "prefix": "quote1", - "body": ["> $0"], - "description": "level 1 quote" - }, - "quote_2": { - "prefix": "quote2", - "body": [">> $0"], - "description": "level 2 quote" - }, - "quote_3": { - "prefix": "quote3", - "body": [">>> $0"], - "description": "level 3 quote" - }, - "quote_4": { - "prefix": "quote4", - "body": [">>>> $0"], - "description": "level 4 quote" - }, - "quote_5": { - "prefix": "quote5", - "body": [">>>>> $0"], - "description": "level 5 quote" - }, - "quote_6": { - "prefix": "quote6", - "body": [">>>>>> $0"], - "description": "level 6 quote" - }, + "quote_1": { + "prefix": "quote1", + "body": ["> $0"], + "description": "level 1 quote" + }, + "quote_2": { + "prefix": "quote2", + "body": [">> $0"], + "description": "level 2 quote" + }, + "quote_3": { + "prefix": "quote3", + "body": [">>> $0"], + "description": "level 3 quote" + }, + "quote_4": { + "prefix": "quote4", + "body": [">>>> $0"], + "description": "level 4 quote" + }, + "quote_5": { + "prefix": "quote5", + "body": [">>>>> $0"], + "description": "level 5 quote" + }, + "quote_6": { + "prefix": "quote6", + "body": [">>>>>> $0"], + "description": "level 6 quote" + }, - "task": { - "prefix": "task", - "body": ["- ( ) ${1:task}"], - "description": "task" - }, - "done_task": { - "prefix": "dtask", - "body": ["- (x) ${1:task}"], - "description": "task (done)" - }, - "input_task": { - "prefix": "itask", - "body": ["- (?) ${1:task}"], - "description": "task (needs further input)" - }, - "urgent_task": { - "prefix": "utask", - "body": ["- (!) ${1:task}"], - "description": "task (high priority)" - }, - "recurring_task": { - "prefix": "rtask", - "body": ["- (+) ${1:task}"], - "description": "task (recurring, with children)" - }, - "pending_task": { - "prefix": "ptask", - "body": ["- (-) ${1:task}"], - "description": "task (in progress)" - }, - "hold_task": { - "prefix": "htask", - "body": ["- (=) ${1:task}"], - "description": "task (on hold)" - }, - "cancelled_task": { - "prefix": "ctask", - "body": ["- (_) ${1:task}"], - "description": "task (cancelled)" - }, + "task": { + "prefix": "task", + "body": ["- ( ) ${1:task}"], + "description": "task" + }, + "done_task": { + "prefix": "dtask", + "body": ["- (x) ${1:task}"], + "description": "task (done)" + }, + "input_task": { + "prefix": "itask", + "body": ["- (?) ${1:task}"], + "description": "task (needs further input)" + }, + "urgent_task": { + "prefix": "utask", + "body": ["- (!) ${1:task}"], + "description": "task (high priority)" + }, + "recurring_task": { + "prefix": "rtask", + "body": ["- (+) ${1:task}"], + "description": "task (recurring, with children)" + }, + "pending_task": { + "prefix": "ptask", + "body": ["- (-) ${1:task}"], + "description": "task (in progress)" + }, + "hold_task": { + "prefix": "htask", + "body": ["- (=) ${1:task}"], + "description": "task (on hold)" + }, + "cancelled_task": { + "prefix": "ctask", + "body": ["- (_) ${1:task}"], + "description": "task (cancelled)" + }, - "single_footnote": { - "prefix": "footnote", - "body": ["^ ${1:title}", "${2:content}"], - "description": "footnote (short version)" - }, - "ranged_single_footnote": { - "prefix": "footnoter", - "body": ["^^ ${1:title}", "${2:content}", "^^"], - "description": "footnote (ranged version)" - }, + "single_footnote": { + "prefix": "footnote", + "body": ["^ ${1:title}", "${2:content}"], + "description": "footnote (short version)" + }, + "ranged_single_footnote": { + "prefix": "footnoter", + "body": ["^^ ${1:title}", "${2:content}", "^^"], + "description": "footnote (ranged version)" + }, - "var": { - "prefix": "var", - "body": ["&${1:variable}&"], - "description": "variable" - } + "var": { + "prefix": "var", + "body": ["&${1:variable}&"], + "description": "variable" + } } From c92b8f05bfe3b3b99c72368dc59649214e5b4181 Mon Sep 17 00:00:00 2001 From: monoira Date: Mon, 10 Feb 2025 15:15:15 +0400 Subject: [PATCH 12/27] feat: improved react snippets massively and fixed "Compoment" typos with "Component" - removed all "import React from 'React'" snippets. since react 17, importing react like that is no longer needed. - changed all "import React, { someComponent }" to "import { some Component }" for same reason as above. - fixed all "Compoment" typos with "Component" in javascript/ directory. --- snippets/javascript/react-es7.json | 116 ++-- snippets/javascript/react-native-ts.json | 9 +- snippets/javascript/react-native.json | 11 +- snippets/javascript/react-ts.json | 746 +++++++++++------------ snippets/javascript/react.json | 736 +++++++++++----------- 5 files changed, 801 insertions(+), 817 deletions(-) diff --git a/snippets/javascript/react-es7.json b/snippets/javascript/react-es7.json index ee54f252..0bdb4a25 100644 --- a/snippets/javascript/react-es7.json +++ b/snippets/javascript/react-es7.json @@ -11,7 +11,7 @@ "prefix": "tsrcc", "description": "Creates a React component class with ES7 module system and TypeScript interfaces", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "type Props = {}", "", @@ -31,7 +31,7 @@ "typescriptReactClassExportComponent": { "prefix": "tsrce", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "type Props = {}", "", @@ -54,8 +54,7 @@ "typescriptReactFunctionalExportComponent": { "prefix": "tsrfce", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "function ${1:${TM_FILENAME_BASE}}({}: Props) {", @@ -71,8 +70,7 @@ "typescriptReactFunctionalComponent": { "prefix": "tsrfc", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "export default function ${1:${TM_FILENAME_BASE}}({}: Props) {", @@ -86,8 +84,7 @@ "typescriptReactArrowFunctionExportComponent": { "prefix": "tsrafce", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -103,8 +100,7 @@ "typescriptReactArrowFunctionComponent": { "prefix": "tsrafc", "body": [ - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -118,7 +114,7 @@ "typescriptReactClassPureComponent": { "prefix": "tsrpc", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "type Props = {}", "", @@ -135,7 +131,7 @@ "typescriptReactClassExportPureComponent": { "prefix": "tsrpce", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "type Props = {}", "", @@ -155,7 +151,7 @@ "prefix": "tsrcredux", "body": [ "import { connect } from 'react-redux'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "type Props = {}", "", @@ -183,8 +179,7 @@ "prefix": "tsrnf", "body": [ "import { View, Text } from 'react-native'", - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -203,8 +198,7 @@ "prefix": "tsrnfs", "body": [ "import { StyleSheet, Text, View } from 'react-native'", - "import React from 'react'", - "", + "type Props = {}", "", "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {", @@ -224,8 +218,7 @@ "reactArrowFunctionComponent": { "prefix": "rafc", "body": [ - "import React from 'react'", - "", + "export const ${1:${TM_FILENAME_BASE}} = () => {", " return (", "
${1:first}
", @@ -238,7 +231,7 @@ "reactArrowFunctionComponentWithPropTypes": { "prefix": "rafcp", "body": [ - "import React from 'react'", + "import PropTypes from 'prop-types'", "", "const ${1:${TM_FILENAME_BASE}} = props => {", @@ -256,8 +249,7 @@ "reactArrowFunctionExportComponent": { "prefix": "rafce", "body": [ - "import React from 'react'", - "", + "const ${1:${TM_FILENAME_BASE}} = () => {", " return (", "
${1:first}
", @@ -271,7 +263,7 @@ "reactClassComponent": { "prefix": "rcc", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -288,7 +280,7 @@ "prefix": "rccp", "body": [ "import PropTypes from 'prop-types'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " static propTypes = {${2:second}: ${3:third}}", @@ -306,7 +298,7 @@ "reactClassComponentRedux": { "prefix": "rcredux", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "import { connect } from 'react-redux'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", @@ -329,7 +321,7 @@ "prefix": "rcreduxp", "body": [ "import PropTypes from 'prop-types'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "import { connect } from 'react-redux'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", @@ -355,7 +347,7 @@ "reactClassExportComponent": { "prefix": "rce", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -373,7 +365,7 @@ "prefix": "rcep", "body": [ "import PropTypes from 'prop-types'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", " static propTypes = {}", @@ -392,7 +384,7 @@ "reactClassExportPureComponent": { "prefix": "rpce", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -409,7 +401,7 @@ "reactClassPureComponent": { "prefix": "rpc", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -426,7 +418,7 @@ "prefix": "rpcp", "body": [ "import PropTypes from 'prop-types'", - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " static propTypes = {}", @@ -444,7 +436,7 @@ "reactFunctionMemoComponent": { "prefix": "rmc", "body": [ - "import React, { memo } from 'react'", + "import { memo } from 'react'", "", "const ${1:${TM_FILENAME_BASE}} = memo(() => {", " return (", @@ -460,7 +452,7 @@ "prefix": "rmcp", "body": [ "import PropTypes from 'prop-types'", - "import React, { memo } from 'react'", + "import { memo } from 'react'", "", "const ${1:${TM_FILENAME_BASE}} = memo((props) => {", " return (", @@ -477,8 +469,7 @@ "reactFunctionalComponent": { "prefix": "rfc", "body": [ - "import React from 'react'", - "", + "export default function ${1:${TM_FILENAME_BASE}}() {", " return (", "
${1:first}
", @@ -503,7 +494,7 @@ "reactFunctionalComponentRedux": { "prefix": "rfcredux", "body": [ - "import React from 'react'", + "import { connect } from 'react-redux'", "", "export const ${1:${TM_FILENAME_BASE}} = (props) => {", @@ -524,7 +515,7 @@ "prefix": "rfcreduxp", "body": [ "import PropTypes from 'prop-types'", - "import React from 'react'", + "import { connect } from 'react-redux'", "", "export const ${1:${TM_FILENAME_BASE}} = (props) => {", @@ -548,7 +539,7 @@ "reactFunctionalComponentWithPropTypes": { "prefix": "rfcp", "body": [ - "import React from 'react'", + "import PropTypes from 'prop-types'", "", "function ${1:${TM_FILENAME_BASE}}(props) {", @@ -567,8 +558,7 @@ "reactFunctionalExportComponent": { "prefix": "rfce", "body": [ - "import React from 'react'", - "", + "function ${1:${TM_FILENAME_BASE}}() {", " return (", "
${1:first}
", @@ -775,36 +765,36 @@ }, "importReactWithComponent": { "prefix": "imrc", - "body": ["import React, { Component } from 'react'"] + "body": ["import { Component } from 'react'"] }, "importReactWithComponentAndPropTypes": { "prefix": "imrcp", "body": [ - "import React, { Component } from 'react'", + "import { Component } from 'react'", "import PropTypes from 'prop-types'", "" ] }, "importReactWithMemo": { "prefix": "imrm", - "body": ["import React, { memo } from 'react'"] + "body": ["import { memo } from 'react'"] }, "importReactWithMemoAndPropTypes": { "prefix": "imrmp", "body": [ - "import React, { memo } from 'react'", + "import { memo } from 'react'", "import PropTypes from 'prop-types'", "" ] }, "importReactWithPureComponent": { "prefix": "imrpc", - "body": ["import React, { PureComponent } from 'react'"] + "body": ["import { PureComponent } from 'react'"] }, "importReactWithPureComponentAndPropTypes": { "prefix": "imrpcp", "body": [ - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "import PropTypes from 'prop-types'", "" ] @@ -990,7 +980,7 @@ "prefix": "rnc", "body": [ "import { Text, View } from 'react-native'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -1007,7 +997,7 @@ "prefix": "rnce", "body": [ "import { Text, View } from 'react-native'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -1026,7 +1016,7 @@ "prefix": "rncs", "body": [ "import { Text, StyleSheet, View } from 'react-native'", - "import React, { Component } from 'react'", + "import { Component } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends Component {", " render() {", @@ -1045,8 +1035,7 @@ "prefix": "rnf", "body": [ "import { View, Text } from 'react-native'", - "import React from 'react'", - "", + "export default function ${1:${TM_FILENAME_BASE}}() {", " return (", " ", @@ -1060,8 +1049,7 @@ "prefix": "rnfs", "body": [ "import { StyleSheet, Text, View } from 'react-native'", - "import React from 'react'", - "", + "export default function ${1:${TM_FILENAME_BASE}}() {", " return (", " ", @@ -1077,8 +1065,7 @@ "prefix": "rnfe", "body": [ "import { View, Text } from 'react-native'", - "import React from 'react'", - "", + "const ${1:${TM_FILENAME_BASE}} = () => {", " return (", " ", @@ -1094,8 +1081,7 @@ "prefix": "rnfes", "body": [ "import { StyleSheet, Text, View } from 'react-native'", - "import React from 'react'", - "", + "const ${1:${TM_FILENAME_BASE}} = () => {", " return (", " ", @@ -1117,7 +1103,7 @@ "prefix": "rnpc", "body": [ "import { Text, View } from 'react-native'", - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -1134,7 +1120,7 @@ "prefix": "rnpce", "body": [ "import { Text, View } from 'react-native'", - "import React, { PureComponent } from 'react'", + "import { PureComponent } from 'react'", "", "export class ${1:${TM_FILENAME_BASE}} extends PureComponent {", " render() {", @@ -1243,7 +1229,7 @@ "setupReactComponentTestWithRedux": { "prefix": "srtest", "body": [ - "import React from 'react'", + "import renderer from 'react-test-renderer'", "import { Provider } from 'react-redux'", "", @@ -1269,7 +1255,7 @@ "prefix": "sntest", "body": [ "import 'react-native'", - "import React from 'react'", + "import renderer from 'react-test-renderer'", "", "import ${1:${TM_FILENAME_BASE}} from '../${1:${TM_FILENAME_BASE}}'", @@ -1288,7 +1274,7 @@ "prefix": "snrtest", "body": [ "import 'react-native'", - "import React from 'react'", + "import renderer from 'react-test-renderer'", "import { Provider } from 'react-redux'", "", @@ -1312,7 +1298,7 @@ "setupReactTest": { "prefix": "stest", "body": [ - "import React from 'react'", + "import renderer from 'react-test-renderer'", "", "import { ${1:${TM_FILENAME_BASE}} } from '../${1:${TM_FILENAME_BASE}}'", @@ -1532,7 +1518,7 @@ "hocComponentWithRedux": { "prefix": "hocredux", "body": [ - "import React from 'react'", + "import { connect } from 'react-redux'", "import PropTypes from 'prop-types'", "", @@ -1555,7 +1541,7 @@ "hocComponent": { "prefix": "hoc", "body": [ - "import React from 'react'", + "import PropTypes from 'prop-types'", "", "export default (WrappedComponent) => {", diff --git a/snippets/javascript/react-native-ts.json b/snippets/javascript/react-native-ts.json index aaf0c311..4eae9c11 100644 --- a/snippets/javascript/react-native-ts.json +++ b/snippets/javascript/react-native-ts.json @@ -2,7 +2,7 @@ "statefulComponent": { "prefix": "rnc", "body": [ - "import React, { Component } from 'react';", + "import { Component } from 'react';", "", "import { View } from 'react-native';", "", @@ -20,8 +20,7 @@ "statelessComponent": { "prefix": "rnsc", "body": [ - "import React from 'react';", - "", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -36,7 +35,7 @@ "componentFunctional": { "prefix": "rnfc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -53,7 +52,7 @@ "componentFunctionalTypescript": { "prefix": "rnfcc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", diff --git a/snippets/javascript/react-native.json b/snippets/javascript/react-native.json index 918183fb..ed2f3531 100644 --- a/snippets/javascript/react-native.json +++ b/snippets/javascript/react-native.json @@ -2,7 +2,7 @@ "statefulComponent": { "prefix": "rnc", "body": [ - "import React, { Component } from 'react';", + "import { Component } from 'react';", "", "import { View } from 'react-native';", "", @@ -20,7 +20,7 @@ "statefulReduxComponent": { "prefix": "rnrc", "body": [ - "import React, { Component } from 'react';", + "import { Component } from 'react';", "", "import { View } from 'react-native';", "", @@ -51,8 +51,7 @@ "statelessComponent": { "prefix": "rnsc", "body": [ - "import React from 'react';", - "", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -67,7 +66,7 @@ "componentFunctional": { "prefix": "rnfc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", @@ -84,7 +83,7 @@ "componentFunctionalTypescript": { "prefix": "rnfcc", "body": [ - "import React from 'react';", + "import { View } from 'react-native';", "", "// import { Container } from './styles';", diff --git a/snippets/javascript/react-ts.json b/snippets/javascript/react-ts.json index ff02f6b1..372eb6d1 100644 --- a/snippets/javascript/react-ts.json +++ b/snippets/javascript/react-ts.json @@ -1,375 +1,375 @@ { - "destructuring of props": { - "prefix": "dp", - "body": ["const { ${1:name} } = this.props"] - }, - "destructuring of state": { - "prefix": "ds", - "body": ["const { ${1:name} } = this.state"] - }, - "reactClassCompoment": { - "prefix": "rcc", - "body": "import React, { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", - "description": "Creates a React component class" - }, - "reactJustClassCompoment": { - "prefix": "rcjc", - "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", - "description": "Creates a React component class" - }, - "reactClassCompomentPropTypes": { - "prefix": "rccp", - "body": "import React, { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes" - }, - "reactClassCompomentWithMethods": { - "prefix": "rcfc", - "body": "import React, { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes and all lifecycle methods" - }, - "reactFunctionComponent": { - "prefix": "rfc", - "body": "import React from 'react'\n\nexport const ${TM_FILENAME_BASE} = (props : {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component without PropTypes" - }, - "reactFunctionComponentWithEmotion": { - "prefix": "rfce", - "body": "import { css } from '@emotion/core'\nimport React from 'react'\n\nexport const ${TM_FILENAME_BASE} = (props: {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component with emotion import" - }, - "classConstructor": { - "prefix": "con", - "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props as arguments" - }, - "classConstructorContext": { - "prefix": "conc", - "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props and context as arguments" - }, - "componentWillMount": { - "prefix": "cwm", - "body": "\ncomponentWillMount () {\n\t$0\n}\n", - "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" - }, - "componentDidMount": { - "prefix": "cdm", - "body": "componentDidMount () {\n\t$0\n}\n", - "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." - }, - "componentWillReceiveProps": { - "prefix": "cwr", - "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", - "description": "Invoked when a component is receiving new props. This method is not called for the initial render." - }, - "componentGetDerivedStateFromProps": { - "prefix": "cgd", - "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", - "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." - }, - "shouldComponentUpdate": { - "prefix": "scu", - "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked before rendering when new props or state are being received. " - }, - "componentWillUpdate": { - "prefix": "cwup", - "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked immediately before rendering when new props or state are being received." - }, - "componentDidUpdate": { - "prefix": "cdup", - "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", - "description": "Invoked immediately after the component's updates are flushed to the DOM." - }, - "componentWillUnmount": { - "prefix": "cwun", - "body": "componentWillUnmount () {\n\t$0\n}\n", - "description": "Invoked immediately before a component is unmounted from the DOM." - }, - "componentRender": { - "prefix": "ren", - "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "When called, it should examine this.props and this.state and return a single child element." - }, - "componentSetStateObject": { - "prefix": "sst", - "body": "this.setState($0)", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentSetStateFunc": { - "prefix": "ssf", - "body": "this.setState((state, props) => { return { $0 }})\n", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentProps": { - "prefix": "tp", - "body": "this.props.$0", - "description": "Access component's props" - }, - "componentState": { - "prefix": "ts", - "body": "this.state.$0", - "description": "Access component's state" - }, - "propTypes": { - "prefix": "rpt", - "body": "$1.propTypes = {\n\t$2\n}", - "description": "Creates empty propTypes declaration" - }, - "propTypeArray": { - "prefix": "pta", - "body": "PropTypes.array,", - "description": "Array prop type" - }, - "propTypeArrayRequired": { - "prefix": "ptar", - "body": "PropTypes.array.isRequired,", - "description": "Array prop type required" - }, - "propTypeBool": { - "prefix": "ptb", - "body": "PropTypes.bool,", - "description": "Bool prop type" - }, - "propTypeBoolRequired": { - "prefix": "ptbr", - "body": "PropTypes.bool.isRequired,", - "description": "Bool prop type required" - }, - "propTypeFunc": { - "prefix": "ptf", - "body": "PropTypes.func,", - "description": "Func prop type" - }, - "propTypeFuncRequired": { - "prefix": "ptfr", - "body": "PropTypes.func.isRequired,", - "description": "Func prop type required" - }, - "propTypeNumber": { - "prefix": "ptn", - "body": "PropTypes.number,", - "description": "Number prop type" - }, - "propTypeNumberRequired": { - "prefix": "ptnr", - "body": "PropTypes.number.isRequired,", - "description": "Number prop type required" - }, - "propTypeObject": { - "prefix": "pto", - "body": "PropTypes.object,", - "description": "Object prop type" - }, - "propTypeObjectRequired": { - "prefix": "ptor", - "body": "PropTypes.object.isRequired,", - "description": "Object prop type required" - }, - "propTypeString": { - "prefix": "pts", - "body": "PropTypes.string,", - "description": "String prop type" - }, - "propTypeStringRequired": { - "prefix": "ptsr", - "body": "PropTypes.string.isRequired,", - "description": "String prop type required" - }, - "propTypeNode": { - "prefix": "ptnd", - "body": "PropTypes.node,", - "description": "Anything that can be rendered: numbers, strings, elements or an array" - }, - "propTypeNodeRequired": { - "prefix": "ptndr", - "body": "PropTypes.node.isRequired,", - "description": "Anything that can be rendered: numbers, strings, elements or an array required" - }, - "propTypeElement": { - "prefix": "ptel", - "body": "PropTypes.element,", - "description": "React element prop type" - }, - "propTypeElementRequired": { - "prefix": "ptelr", - "body": "PropTypes.element.isRequired,", - "description": "React element prop type required" - }, - "propTypeInstanceOf": { - "prefix": "pti", - "body": "PropTypes.instanceOf($0),", - "description": "Is an instance of a class prop type" - }, - "propTypeInstanceOfRequired": { - "prefix": "ptir", - "body": "PropTypes.instanceOf($0).isRequired,", - "description": "Is an instance of a class prop type required" - }, - "propTypeEnum": { - "prefix": "pte", - "body": "PropTypes.oneOf(['$0']),", - "description": "Prop type limited to specific values by treating it as an enum" - }, - "propTypeEnumRequired": { - "prefix": "pter", - "body": "PropTypes.oneOf(['$0']).isRequired,", - "description": "Prop type limited to specific values by treating it as an enum required" - }, - "propTypeOneOfType": { - "prefix": "ptet", - "body": "PropTypes.oneOfType([\n\t$0\n]),", - "description": "An object that could be one of many types" - }, - "propTypeOneOfTypeRequired": { - "prefix": "ptetr", - "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", - "description": "An object that could be one of many types required" - }, - "propTypeArrayOf": { - "prefix": "ptao", - "body": "PropTypes.arrayOf($0),", - "description": "An array of a certain type" - }, - "propTypeArrayOfRequired": { - "prefix": "ptaor", - "body": "PropTypes.arrayOf($0).isRequired,", - "description": "An array of a certain type required" - }, - "propTypeObjectOf": { - "prefix": "ptoo", - "body": "PropTypes.objectOf($0),", - "description": "An object with property values of a certain type" - }, - "propTypeObjectOfRequired": { - "prefix": "ptoor", - "body": "PropTypes.objectOf($0).isRequired,", - "description": "An object with property values of a certain type required" - }, - "propTypeShape": { - "prefix": "ptsh", - "body": "PropTypes.shape({\n\t$0\n}),", - "description": "An object taking on a particular shape" - }, - "propTypeShapeRequired": { - "prefix": "ptshr", - "body": "PropTypes.shape({\n\t$0\n}).isRequired,", - "description": "An object taking on a particular shape required" - }, - "jsx element": { - "prefix": "j", - "body": "<${1:elementName}>\n\t$0\n", - "description": "an element" - }, - "jsx element self closed": { - "prefix": "jc", - "body": "<${1:elementName} />", - "description": "an element self closed" - }, - "jsx elements map": { - "prefix": "jm", - "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", - "description": "an element self closed" - }, - "jsx elements map with return": { - "prefix": "jmr", - "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", - "description": "an element self closed" - }, - "jsx element wrap selection": { - "prefix": "jsx wrap selection with element", - "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", - "description": "an element" - }, - "useState": { - "prefix": "us", - "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", - "description": "React useState() hook" - }, - "useEffect": { - "prefix": "ue", - "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], - "description": "React useEffect() hook" - }, - "useEffect with cleanup": { - "prefix": "uec", - "body": [ - "useEffect(() => {", - "\t$1", - "\n\treturn () => {", - "\t\t$2", - "\t}", - "}, [${3:dependencies}])$0" - ], - "description": "React useEffect() hook with a cleanup function" - }, - "createContext": { - "prefix": "cc", - "body": [ - "export const $1 = createContext<$2>(", - "\t(null as any) as $2", - ")" - ], - "description": "creates a react context" - }, - "useContext": { - "prefix": "uc", - "body": ["const $1 = useContext($2)$0"], - "description": "React useContext() hook" - }, - "useRef": { - "prefix": "ur", - "body": ["const ${1:elName}El = useRef(null)$0"], - "description": "React useRef() hook" - }, - "useCallback": { - "prefix": "ucb", - "body": [ - "const ${1:memoizedCallback} = useCallback(", - "\t() => {", - "\t\t${2:doSomething}(${3:a}, ${4:b})", - "\t},", - "\t[${5:a}, ${6:b}],", - ")$0" - ], - "description": "React useCallback() hook" - }, - "useMemo": { - "prefix": "ume", - "body": [ - "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" - ], - "description": "React useMemo() hook" - }, - "createReactHook": { - "prefix": "crh", - "body": [ "export const use$0 = () => {", "", "}" ], - "description": "Create React Hook" - }, - "createReactHookWithName": { - "prefix": "crhn", - "body": [ "export const ${TM_FILENAME_BASE} = () => {", "\t$0", "}"], - "description": "Create React Hook using File name" - }, - "describeBlock": { - "prefix": "desc", - "body": ["describe('$1', () => {", " $0", "})", ""], - "description": "Testing `describe` block" - }, - "testBlock": { - "prefix": "test", - "body": ["test('should $1', () => {", " $0", "})", ""], - "description": "Testing `test` block" - }, - "itBlock": { - "prefix": "tit", - "body": ["it('should $1', () => {", " $0", "})", ""], - "description": "Testing `it` block" - }, - "itAsyncBlock": { - "prefix": "tita", - "body": ["it('should $1', async () => {", " $0", "})", ""], - "description": "Testing async `it` block" - } + "destructuring of props": { + "prefix": "dp", + "body": ["const { ${1:name} } = this.props"] + }, + "destructuring of state": { + "prefix": "ds", + "body": ["const { ${1:name} } = this.state"] + }, + "reactClassComponent": { + "prefix": "rcc", + "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", + "description": "Creates a React component class" + }, + "reactJustClassComponent": { + "prefix": "rcjc", + "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", + "description": "Creates a React component class" + }, + "reactClassComponentPropTypes": { + "prefix": "rccp", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes" + }, + "reactClassComponentWithMethods": { + "prefix": "rcfc", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes and all lifecycle methods" + }, + "reactFunctionComponent": { + "prefix": "rfc", + "body": "export const ${TM_FILENAME_BASE} = (props : {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "Creates a React functional component without PropTypes" + }, + "reactFunctionComponentWithEmotion": { + "prefix": "rfce", + "body": "import { css } from '@emotion/core'\nexport const ${TM_FILENAME_BASE} = (props: {}) => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "Creates a React functional component with emotion import" + }, + "classConstructor": { + "prefix": "con", + "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props as arguments" + }, + "classConstructorContext": { + "prefix": "conc", + "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props and context as arguments" + }, + "componentWillMount": { + "prefix": "cwm", + "body": "\ncomponentWillMount () {\n\t$0\n}\n", + "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" + }, + "componentDidMount": { + "prefix": "cdm", + "body": "componentDidMount () {\n\t$0\n}\n", + "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." + }, + "componentWillReceiveProps": { + "prefix": "cwr", + "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", + "description": "Invoked when a component is receiving new props. This method is not called for the initial render." + }, + "componentGetDerivedStateFromProps": { + "prefix": "cgd", + "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", + "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." + }, + "shouldComponentUpdate": { + "prefix": "scu", + "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked before rendering when new props or state are being received. " + }, + "componentWillUpdate": { + "prefix": "cwup", + "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked immediately before rendering when new props or state are being received." + }, + "componentDidUpdate": { + "prefix": "cdup", + "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", + "description": "Invoked immediately after the component's updates are flushed to the DOM." + }, + "componentWillUnmount": { + "prefix": "cwun", + "body": "componentWillUnmount () {\n\t$0\n}\n", + "description": "Invoked immediately before a component is unmounted from the DOM." + }, + "componentRender": { + "prefix": "ren", + "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "When called, it should examine this.props and this.state and return a single child element." + }, + "componentSetStateObject": { + "prefix": "sst", + "body": "this.setState($0)", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentSetStateFunc": { + "prefix": "ssf", + "body": "this.setState((state, props) => { return { $0 }})\n", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentProps": { + "prefix": "tp", + "body": "this.props.$0", + "description": "Access component's props" + }, + "componentState": { + "prefix": "ts", + "body": "this.state.$0", + "description": "Access component's state" + }, + "propTypes": { + "prefix": "rpt", + "body": "$1.propTypes = {\n\t$2\n}", + "description": "Creates empty propTypes declaration" + }, + "propTypeArray": { + "prefix": "pta", + "body": "PropTypes.array,", + "description": "Array prop type" + }, + "propTypeArrayRequired": { + "prefix": "ptar", + "body": "PropTypes.array.isRequired,", + "description": "Array prop type required" + }, + "propTypeBool": { + "prefix": "ptb", + "body": "PropTypes.bool,", + "description": "Bool prop type" + }, + "propTypeBoolRequired": { + "prefix": "ptbr", + "body": "PropTypes.bool.isRequired,", + "description": "Bool prop type required" + }, + "propTypeFunc": { + "prefix": "ptf", + "body": "PropTypes.func,", + "description": "Func prop type" + }, + "propTypeFuncRequired": { + "prefix": "ptfr", + "body": "PropTypes.func.isRequired,", + "description": "Func prop type required" + }, + "propTypeNumber": { + "prefix": "ptn", + "body": "PropTypes.number,", + "description": "Number prop type" + }, + "propTypeNumberRequired": { + "prefix": "ptnr", + "body": "PropTypes.number.isRequired,", + "description": "Number prop type required" + }, + "propTypeObject": { + "prefix": "pto", + "body": "PropTypes.object,", + "description": "Object prop type" + }, + "propTypeObjectRequired": { + "prefix": "ptor", + "body": "PropTypes.object.isRequired,", + "description": "Object prop type required" + }, + "propTypeString": { + "prefix": "pts", + "body": "PropTypes.string,", + "description": "String prop type" + }, + "propTypeStringRequired": { + "prefix": "ptsr", + "body": "PropTypes.string.isRequired,", + "description": "String prop type required" + }, + "propTypeNode": { + "prefix": "ptnd", + "body": "PropTypes.node,", + "description": "Anything that can be rendered: numbers, strings, elements or an array" + }, + "propTypeNodeRequired": { + "prefix": "ptndr", + "body": "PropTypes.node.isRequired,", + "description": "Anything that can be rendered: numbers, strings, elements or an array required" + }, + "propTypeElement": { + "prefix": "ptel", + "body": "PropTypes.element,", + "description": "React element prop type" + }, + "propTypeElementRequired": { + "prefix": "ptelr", + "body": "PropTypes.element.isRequired,", + "description": "React element prop type required" + }, + "propTypeInstanceOf": { + "prefix": "pti", + "body": "PropTypes.instanceOf($0),", + "description": "Is an instance of a class prop type" + }, + "propTypeInstanceOfRequired": { + "prefix": "ptir", + "body": "PropTypes.instanceOf($0).isRequired,", + "description": "Is an instance of a class prop type required" + }, + "propTypeEnum": { + "prefix": "pte", + "body": "PropTypes.oneOf(['$0']),", + "description": "Prop type limited to specific values by treating it as an enum" + }, + "propTypeEnumRequired": { + "prefix": "pter", + "body": "PropTypes.oneOf(['$0']).isRequired,", + "description": "Prop type limited to specific values by treating it as an enum required" + }, + "propTypeOneOfType": { + "prefix": "ptet", + "body": "PropTypes.oneOfType([\n\t$0\n]),", + "description": "An object that could be one of many types" + }, + "propTypeOneOfTypeRequired": { + "prefix": "ptetr", + "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", + "description": "An object that could be one of many types required" + }, + "propTypeArrayOf": { + "prefix": "ptao", + "body": "PropTypes.arrayOf($0),", + "description": "An array of a certain type" + }, + "propTypeArrayOfRequired": { + "prefix": "ptaor", + "body": "PropTypes.arrayOf($0).isRequired,", + "description": "An array of a certain type required" + }, + "propTypeObjectOf": { + "prefix": "ptoo", + "body": "PropTypes.objectOf($0),", + "description": "An object with property values of a certain type" + }, + "propTypeObjectOfRequired": { + "prefix": "ptoor", + "body": "PropTypes.objectOf($0).isRequired,", + "description": "An object with property values of a certain type required" + }, + "propTypeShape": { + "prefix": "ptsh", + "body": "PropTypes.shape({\n\t$0\n}),", + "description": "An object taking on a particular shape" + }, + "propTypeShapeRequired": { + "prefix": "ptshr", + "body": "PropTypes.shape({\n\t$0\n}).isRequired,", + "description": "An object taking on a particular shape required" + }, + "jsx element": { + "prefix": "j", + "body": "<${1:elementName}>\n\t$0\n", + "description": "an element" + }, + "jsx element self closed": { + "prefix": "jc", + "body": "<${1:elementName} />", + "description": "an element self closed" + }, + "jsx elements map": { + "prefix": "jm", + "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", + "description": "an element self closed" + }, + "jsx elements map with return": { + "prefix": "jmr", + "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", + "description": "an element self closed" + }, + "jsx element wrap selection": { + "prefix": "jsx wrap selection with element", + "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", + "description": "an element" + }, + "useState": { + "prefix": "us", + "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", + "description": "React useState() hook" + }, + "useEffect": { + "prefix": "ue", + "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], + "description": "React useEffect() hook" + }, + "useEffect with cleanup": { + "prefix": "uec", + "body": [ + "useEffect(() => {", + "\t$1", + "\n\treturn () => {", + "\t\t$2", + "\t}", + "}, [${3:dependencies}])$0" + ], + "description": "React useEffect() hook with a cleanup function" + }, + "createContext": { + "prefix": "cc", + "body": [ + "export const $1 = createContext<$2>(", + "\t(null as any) as $2", + ")" + ], + "description": "creates a react context" + }, + "useContext": { + "prefix": "uc", + "body": ["const $1 = useContext($2)$0"], + "description": "React useContext() hook" + }, + "useRef": { + "prefix": "ur", + "body": ["const ${1:elName}El = useRef(null)$0"], + "description": "React useRef() hook" + }, + "useCallback": { + "prefix": "ucb", + "body": [ + "const ${1:memoizedCallback} = useCallback(", + "\t() => {", + "\t\t${2:doSomething}(${3:a}, ${4:b})", + "\t},", + "\t[${5:a}, ${6:b}],", + ")$0" + ], + "description": "React useCallback() hook" + }, + "useMemo": { + "prefix": "ume", + "body": [ + "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" + ], + "description": "React useMemo() hook" + }, + "createReactHook": { + "prefix": "crh", + "body": ["export const use$0 = () => {", "", "}"], + "description": "Create React Hook" + }, + "createReactHookWithName": { + "prefix": "crhn", + "body": ["export const ${TM_FILENAME_BASE} = () => {", "\t$0", "}"], + "description": "Create React Hook using File name" + }, + "describeBlock": { + "prefix": "desc", + "body": ["describe('$1', () => {", " $0", "})", ""], + "description": "Testing `describe` block" + }, + "testBlock": { + "prefix": "test", + "body": ["test('should $1', () => {", " $0", "})", ""], + "description": "Testing `test` block" + }, + "itBlock": { + "prefix": "tit", + "body": ["it('should $1', () => {", " $0", "})", ""], + "description": "Testing `it` block" + }, + "itAsyncBlock": { + "prefix": "tita", + "body": ["it('should $1', async () => {", " $0", "})", ""], + "description": "Testing async `it` block" + } } diff --git a/snippets/javascript/react.json b/snippets/javascript/react.json index b51c5847..a41e83d9 100644 --- a/snippets/javascript/react.json +++ b/snippets/javascript/react.json @@ -1,370 +1,370 @@ { - "destructuring of props": { - "prefix": "dp", - "body": ["const { ${1:name} } = this.props"] - }, - "destructuring of state": { - "prefix": "ds", - "body": ["const { ${1:name} } = this.state"] - }, - "if falsy return null": { - "prefix": "ifr", - "body": "if (!${1:condition}) {\n\treturn null\n}" - }, - "reactClassCompoment": { - "prefix": "rcc", - "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", - "description": "Creates a React component class" - }, - "reactJustClassCompoment": { - "prefix": "rcjc", - "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", - "description": "Creates a React component class" - }, - "reactClassCompomentPropTypes": { - "prefix": "rccp", - "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes" - }, - "reactClassCompomentWithMethods": { - "prefix": "rcfc", - "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", - "description": "Creates a React component class with PropTypes and all lifecycle methods" - }, - "reactFunctionComponent": { - "prefix": "rfc", - "body": "\nconst ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${TM_FILENAME_BASE}", - "description": "Creates a React function component without PropTypes" - }, - "reactFunctionComponentWithCustomName": { - "prefix": "rfcn", - "body": "\nconst ${1:functionname} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${1:functionname}", - "description": "Creates a React function component with custom name" - }, - "reactFunctionComponentWithEmotion": { - "prefix": "rfce", - "body": "import { css } from '@emotion/core'\n\nexport const ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "Creates a React functional component with emotion" - }, - "reactStatelessProps": { - "prefix": "rfcp", - "body": "import { PropTypes } from 'react'\n\nconst ${TM_FILENAME_BASE} = props => {\n\treturn (\n\t\t
\n\t\t\t\n\t\t
\n\t)\n}\n\n${1}.propTypes = {\n\t$0\n}\n\nexport default ${1}", - "description": "Creates a React function component with PropTypes" - }, - "classConstructor": { - "prefix": "con", - "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props as arguments" - }, - "classConstructorContext": { - "prefix": "conc", - "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", - "description": "Adds a default constructor for the class that contains props and context as arguments" - }, - "componentWillMount": { - "prefix": "cwm", - "body": "\ncomponentWillMount () {\n\t$0\n}\n", - "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" - }, - "componentDidMount": { - "prefix": "cdm", - "body": "componentDidMount () {\n\t$0\n}\n", - "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." - }, - "componentWillReceiveProps": { - "prefix": "cwr", - "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", - "description": "Invoked when a component is receiving new props. This method is not called for the initial render." - }, - "componentGetDerivedStateFromProps": { - "prefix": "cgd", - "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", - "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." - }, - "shouldComponentUpdate": { - "prefix": "scu", - "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked before rendering when new props or state are being received. " - }, - "componentWillUpdate": { - "prefix": "cwup", - "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", - "description": "Invoked immediately before rendering when new props or state are being received." - }, - "componentDidUpdate": { - "prefix": "cdup", - "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", - "description": "Invoked immediately after the component's updates are flushed to the DOM." - }, - "componentWillUnmount": { - "prefix": "cwun", - "body": "componentWillUnmount () {\n\t$0\n}\n", - "description": "Invoked immediately before a component is unmounted from the DOM." - }, - "componentRender": { - "prefix": "ren", - "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", - "description": "When called, it should examine this.props and this.state and return a single child element." - }, - "componentSetStateObject": { - "prefix": "sst", - "body": "this.setState($0)", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentSetStateFunc": { - "prefix": "ssf", - "body": "this.setState((state, props) => { return { $0 }})\n", - "description": "Performs a shallow merge of nextState into current state" - }, - "componentProps": { - "prefix": "tp", - "body": "this.props.$0", - "description": "Access component's props" - }, - "componentState": { - "prefix": "ts", - "body": "this.state.$0", - "description": "Access component's state" - }, - "propTypes": { - "prefix": "rpt", - "body": "$1.propTypes = {\n\t$2\n}", - "description": "Creates empty propTypes declaration" - }, - "propTypeArray": { - "prefix": "pta", - "body": "PropTypes.array,", - "description": "Array prop type" - }, - "propTypeArrayRequired": { - "prefix": "ptar", - "body": "PropTypes.array.isRequired,", - "description": "Array prop type required" - }, - "propTypeBool": { - "prefix": "ptb", - "body": "PropTypes.bool,", - "description": "Bool prop type" - }, - "propTypeBoolRequired": { - "prefix": "ptbr", - "body": "PropTypes.bool.isRequired,", - "description": "Bool prop type required" - }, - "propTypeFunc": { - "prefix": "ptf", - "body": "PropTypes.func,", - "description": "Func prop type" - }, - "propTypeFuncRequired": { - "prefix": "ptfr", - "body": "PropTypes.func.isRequired,", - "description": "Func prop type required" - }, - "propTypeNumber": { - "prefix": "ptn", - "body": "PropTypes.number,", - "description": "Number prop type" - }, - "propTypeNumberRequired": { - "prefix": "ptnr", - "body": "PropTypes.number.isRequired,", - "description": "Number prop type required" - }, - "propTypeObject": { - "prefix": "pto", - "body": "PropTypes.object,", - "description": "Object prop type" - }, - "propTypeObjectRequired": { - "prefix": "ptor", - "body": "PropTypes.object.isRequired,", - "description": "Object prop type required" - }, - "propTypeString": { - "prefix": "pts", - "body": "PropTypes.string,", - "description": "String prop type" - }, - "propTypeStringRequired": { - "prefix": "ptsr", - "body": "PropTypes.string.isRequired,", - "description": "String prop type required" - }, - "propTypeNode": { - "prefix": "ptnd", - "body": "PropTypes.node,", - "description": "Anything that can be rendered: numbers, strings, elements or an array" - }, - "propTypeNodeRequired": { - "prefix": "ptndr", - "body": "PropTypes.node.isRequired,", - "description": "Anything that can be rendered: numbers, strings, elements or an array required" - }, - "propTypeElement": { - "prefix": "ptel", - "body": "PropTypes.element,", - "description": "React element prop type" - }, - "propTypeElementRequired": { - "prefix": "ptelr", - "body": "PropTypes.element.isRequired,", - "description": "React element prop type required" - }, - "propTypeInstanceOf": { - "prefix": "pti", - "body": "PropTypes.instanceOf($0),", - "description": "Is an instance of a class prop type" - }, - "propTypeInstanceOfRequired": { - "prefix": "ptir", - "body": "PropTypes.instanceOf($0).isRequired,", - "description": "Is an instance of a class prop type required" - }, - "propTypeEnum": { - "prefix": "pte", - "body": "PropTypes.oneOf(['$0']),", - "description": "Prop type limited to specific values by treating it as an enum" - }, - "propTypeEnumRequired": { - "prefix": "pter", - "body": "PropTypes.oneOf(['$0']).isRequired,", - "description": "Prop type limited to specific values by treating it as an enum required" - }, - "propTypeOneOfType": { - "prefix": "ptet", - "body": "PropTypes.oneOfType([\n\t$0\n]),", - "description": "An object that could be one of many types" - }, - "propTypeOneOfTypeRequired": { - "prefix": "ptetr", - "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", - "description": "An object that could be one of many types required" - }, - "propTypeArrayOf": { - "prefix": "ptao", - "body": "PropTypes.arrayOf($0),", - "description": "An array of a certain type" - }, - "propTypeArrayOfRequired": { - "prefix": "ptaor", - "body": "PropTypes.arrayOf($0).isRequired,", - "description": "An array of a certain type required" - }, - "propTypeObjectOf": { - "prefix": "ptoo", - "body": "PropTypes.objectOf($0),", - "description": "An object with property values of a certain type" - }, - "propTypeObjectOfRequired": { - "prefix": "ptoor", - "body": "PropTypes.objectOf($0).isRequired,", - "description": "An object with property values of a certain type required" - }, - "propTypeShape": { - "prefix": "ptsh", - "body": "PropTypes.shape({\n\t$0\n}),", - "description": "An object taking on a particular shape" - }, - "propTypeShapeRequired": { - "prefix": "ptshr", - "body": "PropTypes.shape({\n\t$0\n}).isRequired,", - "description": "An object taking on a particular shape required" - }, - "jsx element": { - "prefix": "j", - "body": "<${1:elementName}>\n\t$0\n", - "description": "an element" - }, - "jsx element self closed": { - "prefix": "jc", - "body": "<${1:elementName} />", - "description": "an element self closed" - }, - "jsx elements map": { - "prefix": "jm", - "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", - "description": "an element self closed" - }, - "jsx elements map with return": { - "prefix": "jmr", - "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", - "description": "an element self closed" - }, - "jsx element wrap selection": { - "prefix": "jsx wrap selection with element", - "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", - "description": "an element" - }, - "useState": { - "prefix": "us", - "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", - "description": "React useState() hook" - }, - "useEffect": { - "prefix": "ue", - "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], - "description": "React useEffect() hook" - }, - "useEffect with return": { - "prefix": "uer", - "body": [ - "useEffect(() => {", - "\t$1", - "\n\treturn () => {", - "\t\t$2", - "\t}", - "}, [${3:dependencies}])$0" - ], - "description": "React useEffect() hook with return statement" - }, - "useContext": { - "prefix": "uc", - "body": ["const $1 = useContext($2)$0"], - "description": "React useContext() hook" - }, - "useRef": { - "prefix": "ur", - "body": ["const ${1:elName}El = useRef(null)$0"], - "description": "React useContext() hook" - }, - "useCallback": { - "prefix": "ucb", - "body": [ - "const ${1:memoizedCallback} = useCallback(", - "\t() => {", - "\t\t${2:doSomething}(${3:a}, ${4:b})", - "\t},", - "\t[${5:a}, ${6:b}],", - ")$0" - ], - "description": "React useCallback() hook" - }, - "useMemo": { - "prefix": "ume", - "body": [ - "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" - ], - "description": "React useMemo() hook" - }, - "describeBlock": { - "prefix": "desc", - "body": ["describe('$1', () => {", " $0", "})", ""], - "description": "Testing `describe` block" - }, - "testBlock": { - "prefix": "test", - "body": ["test('should $1', () => {", " $0", "})", ""], - "description": "Testing `test` block" - }, - "itBlock": { - "prefix": "tit", - "body": ["it('should $1', () => {", " $0", "})", ""], - "description": "Testing `it` block" - }, - "itAsyncBlock": { - "prefix": "tita", - "body": ["it('should $1', async () => {", " $0", "})", ""], - "description": "Testing async `it` block" - } + "destructuring of props": { + "prefix": "dp", + "body": ["const { ${1:name} } = this.props"] + }, + "destructuring of state": { + "prefix": "ds", + "body": ["const { ${1:name} } = this.state"] + }, + "if falsy return null": { + "prefix": "ifr", + "body": "if (!${1:condition}) {\n\treturn null\n}" + }, + "reactClassComponent": { + "prefix": "rcc", + "body": "import { Component } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\nexport default ${1}", + "description": "Creates a React component class" + }, + "reactJustClassComponent": { + "prefix": "rcjc", + "body": "class ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n", + "description": "Creates a React component class" + }, + "reactClassComponentPropTypes": { + "prefix": "rccp", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\trender () {\n\t\treturn (\n\t\t\t
\n\t\t\t\t$0\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes" + }, + "reactClassComponentWithMethods": { + "prefix": "rcfc", + "body": "import { Component, PropTypes } from 'react'\n\nclass ${TM_FILENAME_BASE} extends Component {\n\tconstructor(props) {\n\t\tsuper(props)\n\n\t}\n\n\tcomponentWillMount () {\n\n\t}\n\n\tcomponentDidMount () {\n\n\t}\n\n\tcomponentWillReceiveProps (nextProps) {\n\n\t}\n\n\tshouldComponentUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentWillUpdate (nextProps, nextState) {\n\n\t}\n\n\tcomponentDidUpdate (prevProps, prevState) {\n\n\t}\n\n\tcomponentWillUnmount () {\n\n\t}\n\n\trender () {\n\t\treturn (\n\t\t\t
\n\n\t\t\t
\n\t\t)\n\t}\n}\n\n${1}.propTypes = {\n\n}\n\nexport default ${1}", + "description": "Creates a React component class with PropTypes and all lifecycle methods" + }, + "reactFunctionComponent": { + "prefix": "rfc", + "body": "\nconst ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${TM_FILENAME_BASE}", + "description": "Creates a React function component without PropTypes" + }, + "reactFunctionComponentWithCustomName": { + "prefix": "rfcn", + "body": "\nconst ${1:functionname} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}\n\nexport default ${1:functionname}", + "description": "Creates a React function component with custom name" + }, + "reactFunctionComponentWithEmotion": { + "prefix": "rfce", + "body": "import { css } from '@emotion/core'\n\nexport const ${TM_FILENAME_BASE} = () => {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "Creates a React functional component with emotion" + }, + "reactStatelessProps": { + "prefix": "rfcp", + "body": "import { PropTypes } from 'react'\n\nconst ${TM_FILENAME_BASE} = props => {\n\treturn (\n\t\t
\n\t\t\t\n\t\t
\n\t)\n}\n\n${1}.propTypes = {\n\t$0\n}\n\nexport default ${1}", + "description": "Creates a React function component with PropTypes" + }, + "classConstructor": { + "prefix": "con", + "body": "constructor (props) {\n\tsuper(props)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props as arguments" + }, + "classConstructorContext": { + "prefix": "conc", + "body": "constructor (props, context) {\n\tsuper(props, context)\n\t$0\n}\n", + "description": "Adds a default constructor for the class that contains props and context as arguments" + }, + "componentWillMount": { + "prefix": "cwm", + "body": "\ncomponentWillMount () {\n\t$0\n}\n", + "description": "Invoked once, both on the client and server, immediately before the initial rendering occurs" + }, + "componentDidMount": { + "prefix": "cdm", + "body": "componentDidMount () {\n\t$0\n}\n", + "description": "Invoked once, only on the client (not on the server), immediately after the initial rendering occurs." + }, + "componentWillReceiveProps": { + "prefix": "cwr", + "body": "componentWillReceiveProps (nextProps) {\n\t$0\n}\n", + "description": "Invoked when a component is receiving new props. This method is not called for the initial render." + }, + "componentGetDerivedStateFromProps": { + "prefix": "cgd", + "body": "\nstatic getDerivedStateFromProps(nextProps, prevState) {\n\t$0\n}\n", + "description": "Invoked after a component is instantiated as well as when it receives new props. It should return an object to update state, or null to indicate that the new props do not require any state updates." + }, + "shouldComponentUpdate": { + "prefix": "scu", + "body": "shouldComponentUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked before rendering when new props or state are being received. " + }, + "componentWillUpdate": { + "prefix": "cwup", + "body": "componentWillUpdate (nextProps, nextState) {\n\t$0\n}\n", + "description": "Invoked immediately before rendering when new props or state are being received." + }, + "componentDidUpdate": { + "prefix": "cdup", + "body": "componentDidUpdate (prevProps, prevState) {\n\t$0\n}\n", + "description": "Invoked immediately after the component's updates are flushed to the DOM." + }, + "componentWillUnmount": { + "prefix": "cwun", + "body": "componentWillUnmount () {\n\t$0\n}\n", + "description": "Invoked immediately before a component is unmounted from the DOM." + }, + "componentRender": { + "prefix": "ren", + "body": "render () {\n\treturn (\n\t\t
\n\t\t\t$0\n\t\t
\n\t)\n}", + "description": "When called, it should examine this.props and this.state and return a single child element." + }, + "componentSetStateObject": { + "prefix": "sst", + "body": "this.setState($0)", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentSetStateFunc": { + "prefix": "ssf", + "body": "this.setState((state, props) => { return { $0 }})\n", + "description": "Performs a shallow merge of nextState into current state" + }, + "componentProps": { + "prefix": "tp", + "body": "this.props.$0", + "description": "Access component's props" + }, + "componentState": { + "prefix": "ts", + "body": "this.state.$0", + "description": "Access component's state" + }, + "propTypes": { + "prefix": "rpt", + "body": "$1.propTypes = {\n\t$2\n}", + "description": "Creates empty propTypes declaration" + }, + "propTypeArray": { + "prefix": "pta", + "body": "PropTypes.array,", + "description": "Array prop type" + }, + "propTypeArrayRequired": { + "prefix": "ptar", + "body": "PropTypes.array.isRequired,", + "description": "Array prop type required" + }, + "propTypeBool": { + "prefix": "ptb", + "body": "PropTypes.bool,", + "description": "Bool prop type" + }, + "propTypeBoolRequired": { + "prefix": "ptbr", + "body": "PropTypes.bool.isRequired,", + "description": "Bool prop type required" + }, + "propTypeFunc": { + "prefix": "ptf", + "body": "PropTypes.func,", + "description": "Func prop type" + }, + "propTypeFuncRequired": { + "prefix": "ptfr", + "body": "PropTypes.func.isRequired,", + "description": "Func prop type required" + }, + "propTypeNumber": { + "prefix": "ptn", + "body": "PropTypes.number,", + "description": "Number prop type" + }, + "propTypeNumberRequired": { + "prefix": "ptnr", + "body": "PropTypes.number.isRequired,", + "description": "Number prop type required" + }, + "propTypeObject": { + "prefix": "pto", + "body": "PropTypes.object,", + "description": "Object prop type" + }, + "propTypeObjectRequired": { + "prefix": "ptor", + "body": "PropTypes.object.isRequired,", + "description": "Object prop type required" + }, + "propTypeString": { + "prefix": "pts", + "body": "PropTypes.string,", + "description": "String prop type" + }, + "propTypeStringRequired": { + "prefix": "ptsr", + "body": "PropTypes.string.isRequired,", + "description": "String prop type required" + }, + "propTypeNode": { + "prefix": "ptnd", + "body": "PropTypes.node,", + "description": "Anything that can be rendered: numbers, strings, elements or an array" + }, + "propTypeNodeRequired": { + "prefix": "ptndr", + "body": "PropTypes.node.isRequired,", + "description": "Anything that can be rendered: numbers, strings, elements or an array required" + }, + "propTypeElement": { + "prefix": "ptel", + "body": "PropTypes.element,", + "description": "React element prop type" + }, + "propTypeElementRequired": { + "prefix": "ptelr", + "body": "PropTypes.element.isRequired,", + "description": "React element prop type required" + }, + "propTypeInstanceOf": { + "prefix": "pti", + "body": "PropTypes.instanceOf($0),", + "description": "Is an instance of a class prop type" + }, + "propTypeInstanceOfRequired": { + "prefix": "ptir", + "body": "PropTypes.instanceOf($0).isRequired,", + "description": "Is an instance of a class prop type required" + }, + "propTypeEnum": { + "prefix": "pte", + "body": "PropTypes.oneOf(['$0']),", + "description": "Prop type limited to specific values by treating it as an enum" + }, + "propTypeEnumRequired": { + "prefix": "pter", + "body": "PropTypes.oneOf(['$0']).isRequired,", + "description": "Prop type limited to specific values by treating it as an enum required" + }, + "propTypeOneOfType": { + "prefix": "ptet", + "body": "PropTypes.oneOfType([\n\t$0\n]),", + "description": "An object that could be one of many types" + }, + "propTypeOneOfTypeRequired": { + "prefix": "ptetr", + "body": "PropTypes.oneOfType([\n\t$0\n]).isRequired,", + "description": "An object that could be one of many types required" + }, + "propTypeArrayOf": { + "prefix": "ptao", + "body": "PropTypes.arrayOf($0),", + "description": "An array of a certain type" + }, + "propTypeArrayOfRequired": { + "prefix": "ptaor", + "body": "PropTypes.arrayOf($0).isRequired,", + "description": "An array of a certain type required" + }, + "propTypeObjectOf": { + "prefix": "ptoo", + "body": "PropTypes.objectOf($0),", + "description": "An object with property values of a certain type" + }, + "propTypeObjectOfRequired": { + "prefix": "ptoor", + "body": "PropTypes.objectOf($0).isRequired,", + "description": "An object with property values of a certain type required" + }, + "propTypeShape": { + "prefix": "ptsh", + "body": "PropTypes.shape({\n\t$0\n}),", + "description": "An object taking on a particular shape" + }, + "propTypeShapeRequired": { + "prefix": "ptshr", + "body": "PropTypes.shape({\n\t$0\n}).isRequired,", + "description": "An object taking on a particular shape required" + }, + "jsx element": { + "prefix": "j", + "body": "<${1:elementName}>\n\t$0\n", + "description": "an element" + }, + "jsx element self closed": { + "prefix": "jc", + "body": "<${1:elementName} />", + "description": "an element self closed" + }, + "jsx elements map": { + "prefix": "jm", + "body": "{${1:array}.map((item) => <${2:elementName} key={item.id}>\n\t$0\n)}", + "description": "an element self closed" + }, + "jsx elements map with return": { + "prefix": "jmr", + "body": "{${1:array}.map((item) => {\n\treturn <${2:elementName} key={item.id}>\n\t$0\n\n})}", + "description": "an element self closed" + }, + "jsx element wrap selection": { + "prefix": "jsx wrap selection with element", + "body": "<${1:elementName}>\n\t{$TM_SELECTED_TEXT}\n", + "description": "an element" + }, + "useState": { + "prefix": "us", + "body": "const [${1:state}, set${1/(.*)/${1:/capitalize}/}] = useState(${2:initValue})$0", + "description": "React useState() hook" + }, + "useEffect": { + "prefix": "ue", + "body": ["useEffect(() => {", "\t$1", "}, [${3:dependencies}])$0"], + "description": "React useEffect() hook" + }, + "useEffect with return": { + "prefix": "uer", + "body": [ + "useEffect(() => {", + "\t$1", + "\n\treturn () => {", + "\t\t$2", + "\t}", + "}, [${3:dependencies}])$0" + ], + "description": "React useEffect() hook with return statement" + }, + "useContext": { + "prefix": "uc", + "body": ["const $1 = useContext($2)$0"], + "description": "React useContext() hook" + }, + "useRef": { + "prefix": "ur", + "body": ["const ${1:elName}El = useRef(null)$0"], + "description": "React useContext() hook" + }, + "useCallback": { + "prefix": "ucb", + "body": [ + "const ${1:memoizedCallback} = useCallback(", + "\t() => {", + "\t\t${2:doSomething}(${3:a}, ${4:b})", + "\t},", + "\t[${5:a}, ${6:b}],", + ")$0" + ], + "description": "React useCallback() hook" + }, + "useMemo": { + "prefix": "ume", + "body": [ + "const ${1:memoizedValue} = useMemo(() => ${2:computeExpensiveValue}(${3:a}, ${4:b}), [${5:a}, ${6:b}])$0" + ], + "description": "React useMemo() hook" + }, + "describeBlock": { + "prefix": "desc", + "body": ["describe('$1', () => {", " $0", "})", ""], + "description": "Testing `describe` block" + }, + "testBlock": { + "prefix": "test", + "body": ["test('should $1', () => {", " $0", "})", ""], + "description": "Testing `test` block" + }, + "itBlock": { + "prefix": "tit", + "body": ["it('should $1', () => {", " $0", "})", ""], + "description": "Testing `it` block" + }, + "itAsyncBlock": { + "prefix": "tita", + "body": ["it('should $1', async () => {", " $0", "})", ""], + "description": "Testing async `it` block" + } } From e8a643f2b363ce53f7b669a330223059025a886c Mon Sep 17 00:00:00 2001 From: Jack Gallant <79932560+pianoboy71@users.noreply.github.com> Date: Sun, 20 Apr 2025 22:01:19 +0100 Subject: [PATCH 13/27] Add Console.ReadLine snippet for csharp (#534) * Update csharp.json * Remove "System" before WriteLine and ReadLine snippets in csharp * Update html.json --- snippets/csharp/csharp.json | 9 ++++++++- snippets/html.json | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/snippets/csharp/csharp.json b/snippets/csharp/csharp.json index cfa210a4..119e30c0 100644 --- a/snippets/csharp/csharp.json +++ b/snippets/csharp/csharp.json @@ -52,10 +52,17 @@ "Console.WriteLine": { "prefix": "cw", "body": [ - "System.Console.WriteLine($0);" + "Console.WriteLine($0);" ], "description": "Console.WriteLine" }, + "Console.ReadLine": { + "prefix": "cr", + "body": [ + "Console.ReadLine($0);" + ], + "description": "Console.ReadLine" + }, "do...while loop": { "prefix": "do", "body": [ diff --git a/snippets/html.json b/snippets/html.json index 839032a6..258d2493 100644 --- a/snippets/html.json +++ b/snippets/html.json @@ -1,4 +1,22 @@ { + "!": { + "prefix": "!", + "body": [ + "", + "", + "", + "\t", + "\t", + "\t${5:Document}", + "", + "", + "\t${6}", + "", + "" + ], + "description": "HTML - Defines a template for a html5 document", + "scope": "text.html" + }, "doctype": { "prefix": "doctype", "body": ["", "$1"], From 39e44072b57a70d612af2ecc1e856a63e92a1939 Mon Sep 17 00:00:00 2001 From: WieeRd Date: Mon, 21 Apr 2025 06:19:32 +0900 Subject: [PATCH 14/27] feat(lua): for / function snippets overhaul (#537) * feat(lua): for statement snippets overhaul * feat(lua): function snippets overhaul * feat(lua): separate snippet `f)` for anonymous functions --- snippets/lua/lua.json | 57 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 12 deletions(-) diff --git a/snippets/lua/lua.json b/snippets/lua/lua.json index fdafb237..39f70f04 100644 --- a/snippets/lua/lua.json +++ b/snippets/lua/lua.json @@ -7,17 +7,17 @@ "return": { "prefix": "rt", "body": ["return $0"], - "description": "return value" + "description": "Return value" }, "assigment": { "prefix": "ll", "body": ["local ${1:varName} = ${0:value}"], - "description": "define a variable" + "description": "Define a variable" }, "local": { "prefix": "l", "body": ["local ${0}"], - "description": "declare a variable" + "description": "Declare a variable" }, "locreq": { "prefix": "lreq", @@ -44,12 +44,23 @@ }, "for": { "prefix": "for", - "body": ["for ${1:i}=${2:1},${3:10} do", "\t$0", "end"], - "description": "for loop range" + "body": ["for $1 do", "\t$0", "end"], + "description": "for statement" }, - "foreach": { - "prefix": "foreach", - "body": ["for i, ${1:x} in pairs(${2:table}) do", "\t$0", "end"] + "for-numeric": { + "prefix": "forn", + "body": ["for ${1:i} = ${2:1}, ${3:10} do", "\t$0", "end"], + "description": "for numeric range statement" + }, + "for-ipairs": { + "prefix": "fori", + "body": ["for ${1:i}, ${2:x} in ipairs(${3:t}) do", "\t$0", "end"], + "description": "for i, x in ipairs(t)" + }, + "for-pairs": { + "prefix": "forp", + "body": ["for ${1:k}, ${2:v} in pairs(${3:t}) do", "\t$0", "end"], + "description": "for k, v in pairs(t)" }, "forline": { "prefix": "forline", @@ -61,15 +72,37 @@ "\t${0}", "end" ], - "description": "read file line by line" + "description": "Read file line by line" }, "function": { "prefix": "fu", - "body": ["function ${1:name}($2)", "\t${0}", "end"] + "body": ["function ${1:name}($2)", "\t${0}", "end"], + "description": "Define a function" }, - "inline-function": { + "assign-function": { "prefix": "f=", - "body": ["local ${1:name} = function($2)", "\t${0}", "end"] + "body": ["${1:name} = function($2)", "\t${0}", "end"], + "description": "Assign a function to a variable" + }, + "local-function": { + "prefix": "lfu", + "body": ["local function ${1:name}($2)", "\t${0}", "end"], + "description": "Define a local function" + }, + "local-assign-function": { + "prefix": "lf=", + "body": ["local ${1:name} = function($2)", "\t${0}", "end"], + "description": "Assign a function to a local variable" + }, + "anonymous-function": { + "prefix": "f)", + "body": ["function($1)", "\t${0}", "end"], + "description": "Create an anonymous function" + }, + "member-function": { + "prefix": "f,", + "body": ["${1:name} = function($2)", "\t${0}", "end,"], + "description": "Assign a function to a table key" }, "print": { "prefix": "p", From a795ca45bbe61d4d6c28e5253f78257b171c39eb Mon Sep 17 00:00:00 2001 From: WieeRd Date: Mon, 21 Apr 2025 06:23:03 +0900 Subject: [PATCH 15/27] chore: add .editorconfig (#538) --- .editorconfig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..9b946fdf --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +[*] +end_of_line = lf +insert_final_newline = true + +[*.json] +indent_style = space +indent_size = 4 + +[*.lua] +indent_style = tab +indent_size = 4 + +[*.md] +indent_style = space +indent_size = 2 + +[*.yml] +indent_style = space +indent_size = 2 From c2f5ce17e6166cd6ba52760f88e37c821b66aedb Mon Sep 17 00:00:00 2001 From: WieeRd Date: Mon, 21 Apr 2025 06:30:19 +0900 Subject: [PATCH 16/27] feat(lua): `lreq` (local require) snippet improvement (#544) Utilize nested placeholder to prefill the `require()` module path with the name of the local variable the module is being assigned to. --- snippets/lua/lua.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/lua/lua.json b/snippets/lua/lua.json index 39f70f04..814a34ee 100644 --- a/snippets/lua/lua.json +++ b/snippets/lua/lua.json @@ -21,7 +21,7 @@ }, "locreq": { "prefix": "lreq", - "body": ["local ${1:var} = require(${2:module})"], + "body": ["local ${1:module} = require(\"${2:$1}\")$0"], "description": "Require module as a variable" }, "class": { From f774e0241dd978323d39d5a5722d5782823c1809 Mon Sep 17 00:00:00 2001 From: WhoAmiI <70663049+chuan2984@users.noreply.github.com> Date: Sun, 20 Apr 2025 14:37:14 -0700 Subject: [PATCH 17/27] feat(ruby): add rspec snippets (#501) --- package.json | 4 + snippets/ruby/rspec.json | 360 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 364 insertions(+) create mode 100644 snippets/ruby/rspec.json diff --git a/package.json b/package.json index f33d7b10..c254ebec 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,10 @@ "language": "rails", "path": "./snippets/frameworks/rails.json" }, + { + "language": "rspec", + "path": "./snippets/ruby/rspec.json" + }, { "language": "rust", "path": "./snippets/rust/rust.json" diff --git a/snippets/ruby/rspec.json b/snippets/ruby/rspec.json new file mode 100644 index 00000000..96574d46 --- /dev/null +++ b/snippets/ruby/rspec.json @@ -0,0 +1,360 @@ +{ + "rspec_spec_skeleton": { + "prefix": "rspec", + "body": "# frozen_string_literal: true\n\nrequire 'spec_helper'\nrequire 'rails_helper'\n\nRSpec.describe ${1:${TM_DIRECTORY/(?:(?:\\~?\\/.*\\/)|_)([A-Za-z0-9]+)?/${1:/capitalize}/g}}::${2:${TM_FILENAME_BASE/(?:^|_)([A-Za-z0-9]+)(?:_spec)?/${1:/capitalize}/g}} do\n $0\nend\n", + "description": "RSpec test skeleton" + }, + + "rspec_describe": { + "prefix": "des", + "body": "describe '${1:}' do\n ${2:}$0\nend\n", + "description": "RSpec describe case" + }, + + "rspec_context": { + "prefix": "con", + "body": "context 'when ${1:some case}' do\n ${2:}$0\nend\n", + "description": "RSpec context case" + }, + + "rspec_let": { + "prefix": "let", + "body": "let(:${1:object}) { $0 }", + "description": "Use `let` to define memoized helper method" + }, + + "rspec_let!": { + "prefix": "letb", + "body": "let!(:${1:object}) { $0 }", + "description": [ + "Use `let!` to define a memoized", + "helper method that is called", + "in a `before` hook" + ] + }, + + "rspec_it": { + "prefix": "it", + "body": "it '${1:has some behaviour}' do\n ${2:}$0\nend\n", + "description": "example" + }, + + "rspec_pending": { + "prefix": "pending", + "body": "pending${1: '${2:reason}'}", + "description": "pending example" + }, + + "rspec_shared_example": { + "prefix": "sharex", + "body": "RSpec.shared_examples '${1:some example}' do ${3:|${2:parameter}|}\n ${4:$0}\nend\n", + "description": "RSpec shared example declaration" + }, + + "rspec_behaves_like": { + "prefix": "itbl", + "body": "it_behaves_like ${2:'$1'}$0", + "description": "RSpec shared example usage" + }, + + "rspec_expect_do": { + "prefix": "expdo", + "body": "expect do\n ${1:action}\nend.to ${2:matcher}$0", + "description": "expect do ... end.to something" + }, + "rspec_expect": { + "prefix": "exp", + "body": "expect(${1:subject}).to ${2:matcher}$0", + "description": "expect(subject).to something" + }, + + "rspec_expect_block": { + "prefix": "expto", + "body": "expect {${2: ${1:expression} }}.to ${3:matcher}", + "description": "expect with block" + }, + + "rspec_expect_be": { + "prefix": "expbe", + "body": "expect(${1:subject}).to be$0", + "description": [ + "Scenarios:", + "be matcher" + ] + }, + + "rspec_expect_be_": { + "prefix": "expbpm", + "body": "expect(${1:subject}).to be_${2|truthy,falsey,nil|}$0", + "description": [ + "Scenarios:", + "be_truthy matcher", + "be_falsey matcher", + "be_nil matcher" + ] + }, + + "rspec_expect_eq": { + "prefix": "expeq", + "body": "expect(${1:subject}).to eq(${2:value})$0", + "description": [ + "Equality matcher", + "compare using eq (==)" + ] + }, + + "rspec_expect_eql": { + "prefix": "expeql", + "body": "expect(${1:subject}).to eql(${2:value})$0", + "description": [ + "Equality matcher", + "compare using eql (eql?)" + ] + }, + + "rspec_expect_equal": { + "prefix": "expequal", + "body": "expect(${1:subject}).to equal(${2:value})$0", + "description": [ + "Equality matcher", + "compare using equal (equal?)" + ] + }, + + "rspec_expect_all": { + "prefix": "expall", + "body": "expect(${1:enumerable}).to all( ${2:matcher} )$0", + "description": [ + "Used to specify that a collection's", + "objects all pass an expected", + "matcher. This works on any", + "enumerable object." + ] + }, + + "rspec_expect_include": { + "prefix": "expinclude", + "body": "expect(${1:subject}).to include(${2:element})$0", + "description": [ + "Use the include matcher to specify", + "that a collection includes one or", + "more expected objects.", + "This works on any object that ", + "responds to #include? ", + "Scenarios: Array, String, Hash" + ] + }, + + "rspec_expect_match": { + "prefix": "expmatch", + "body": "expect(${1:subject}).to match(/${2:regexp}/)$0", + "description": [ + "The match matcher calls #match on", + "the object, passing if #match", + "returns a truthy (not false or nil)", + "value.", + "Scenarios: String, Regexp" + ] + }, + + "rspec_expect_contain_exactly": { + "prefix": "expcte", + "body": "expect(${1:array}).to contain_exactly(${2:elements})$0", + "description": [ + "Provides a way to test arrays", + "against each other in a way that", + "disregards differences in the", + "ordering between the actual and", + "expected array" + ] + }, + + "rspec_expect_exist": { + "prefix": "expexist", + "body": "expect(${1:subject}).to exist$0", + "description": [ + "The exist matcher is used to specify", + "that something exists", + "(#exist? or #exists?)" + ] + }, + + "rspec_expect_end_with": { + "prefix": "expenw", + "body": "expect(${1:subject}).to end_with(${2:value})$0", + "description": [ + "Used to specify that a string or", + "array ends with the expected", + "characters or elements", + "Scenarios: Array, String" + ] + }, + + "rspec_expect_start_with": { + "prefix": "expstw", + "body": "expect(${1:subject}).to start_with(${2:value})$0", + "description": [ + "Used to specify that a string or", + "array starts with the expected", + "characters or elements", + "Scenarios: Array, String" + ] + }, + + "rspec_expect_have_attributes": { + "prefix": "exphat", + "body": "expect(${1:subject}).to have_attributes(${2:hash})$0", + "description": [ + "Used to specify that an object's", + "attributes match the expected", + "attributes" + ] + }, + + "rspec_expect_raise": { + "prefix": "expraise", + "body": "expect { ${1:action} }.to raise_error(${2:Error})$0", + "description": [ + "Used to specify that a block of code", + "raises an error.", + "Scenarios", + "expect any error", + "expect specific error", + "match message with a string", + "match message with a regexp", + "matching message with `with_message`", + "match class + message with string", + "match class + message with regexp", + "set expectations on error object passed to block", + "expect no error at all" + ] + }, + + + "rspec_expect_satisfy": { + "prefix": "expsat", + "body": "expect(${1:subject}).to satisfy { |${2:obj}| ${3:expression} }$0", + "description": [ + "The satisfy matcher is extremely", + "flexible and can handle almost", + "anything you want to specify.", + "It passes if the block you provide", + "returns true" + ] + }, + + "rspec_expect_be_a_kind_of": { + "prefix": "expbko", + "body": "expect(${1:subject}).to be_a_kind_of(${2:klass})$0", + "description": [ + "Type matcher", + "Returns true if type is in obj's", + "class hierarchy or is a module and", + "is included in a class in obj's ", + "class hierarchy." + ] + }, + + "rspec_expect_be_an_instance_of": { + "prefix": "expbio", + "body": "expect(${1:subject}).to be_an_instance_of(${2:klass})$0", + "description": [ + "Type matcher", + "Returns true if and only if type if obj's class" + ] + }, + + "rspec_expect_respond_to": { + "prefix": "exprt", + "body": "expect(${1:subject}).to respond_to(:${2:method})$0", + "description": [ + "Use the respond_to matcher to", + "specify details of an object's", + "interface. ", + "Scenarios:", + "basic usage", + "specify arguments", + "specify arguments range", + "specify unlimited arguments", + "specify keywords", + "specify any keywords", + "specify required keywords" + ] + }, + + "rspec_before": { + "prefix": "bef", + "body": "before(${1|:all,:each,:suite,:context,:example|}) do\n ${2:}$0\nend\n", + "description": [ + "Before hook", + "Runs once before all of the examples", + "in a group" + ] + }, + + "rspec_after": { + "prefix": "aft", + "body": "after(${1|:all,:each,:suite,:context,:example|}) do\n ${2:}$0\nend\n", + "description": [ + "After hook", + "Runs once after all of the examples", + "in a group" + ] + }, + + "rspec_around": { + "prefix": "aro", + "body": "around(:${1:example}) do\n ${2:}$0\nend\n", + "description": [ + "Around hook", + "Lets you define code that should be", + "executed before and after the", + "example", + "Context hooks are NOT wrapped by", + "the `around` hook" + ] + }, + + "rspec_is_expected": { + "prefix": "itie", + "body": "it { is_expected.to ${1:matcher} }$0", + "description": [ + "RSpec supports a one-liner syntax", + "for setting an expectation on the", + "subject" + ] + }, + + "rspec_subject": { + "prefix": "subject", + "body": "subject(:${1:subject}) { ${2:} }$0", + "description": [ + "Explicit subject", + "Defines a memoized helper method" + ] + }, + + "rspec_described_class": { + "prefix": "subjectcls", + "body": "subject(:${1:subject}) { ${2:${TM_DIRECTORY/(?:(?:\\~?\\/.*\\/)|_)([A-Za-z0-9]+)?/${1:/capitalize}/g}}::${3:${TM_FILENAME_BASE/(?:^|_)([A-Za-z0-9]+)(?:_spec)?/${1:/capitalize}/g}}.new }$0", + "description": "subject(:subject) { described_class.new }" + }, + + "rspec_allow": { + "prefix": "allrec", + "body": "allow(${1:collaborator}).to receive(:${2:message})${3:.with(${4:args})}${5:.and_return(${6:result})}$0", + "description": "Method stub that returns values" + }, + + "rspec_expect_receive": { + "prefix": "exprecw", + "body": "expect(${1:collaborator}).to receive(:${2:message})${3:.with(${4:args})}$0", + "description": [ + "Expecting messages", + "Use to expect a message on a test", + "double. Unfulfilled message ", + "expectations trigger failures when", + "the example completes." + ] + } +} From 4875d859c94255a6a1e339678409e004885666b0 Mon Sep 17 00:00:00 2001 From: ai4bing <76109691+ai4bing@users.noreply.github.com> Date: Sun, 20 Apr 2025 23:43:07 +0200 Subject: [PATCH 18/27] copyright snippet fix (#553) --- snippets/global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/global.json b/snippets/global.json index c7303eb9..3c238c0b 100644 --- a/snippets/global.json +++ b/snippets/global.json @@ -1,6 +1,6 @@ { "copyright": { - "prefix": "c)", + "prefix": "copyright", "body": [ "Copyright (c) ${CURRENT_YEAR} ${0:Author}. All Rights Reserved." ], From 535ee51e84ba4ab08645705f48c4f2641208717c Mon Sep 17 00:00:00 2001 From: Joshua Ryan Velasquez Date: Mon, 21 Apr 2025 05:50:47 +0800 Subject: [PATCH 19/27] feat(erb): add link_to & comment block snippet (#549) --- snippets/erb.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/snippets/erb.json b/snippets/erb.json index e7112ced..4d40d752 100644 --- a/snippets/erb.json +++ b/snippets/erb.json @@ -56,9 +56,19 @@ "body": ["<%= $1 %>"], "description": "render block pe" }, + "comment": { + "prefix": ["pc"], + "body": ["<%# $1 %>"], + "description": "erb print comment" + }, "exec": { "prefix": ["er", "%"], "body": ["<% $1 %>"], "description": "erb exec block" + }, + "link_to": { + "prefix": ["lt"], + "body": ["<%= link_to $1, $2 %>"], + "description": "link_to helper" } } From 16833311a0c51e7ee9a1ce939000f5b20a5d9d2b Mon Sep 17 00:00:00 2001 From: "Xu, Shuo" <100334393+ATMxsp01@users.noreply.github.com> Date: Mon, 21 Apr 2025 05:57:36 +0800 Subject: [PATCH 20/27] fix haskell's lambda snippet (#554) Properly escape the first argument by adding additional `\\` to the snippet body definition. --- snippets/haskell.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/haskell.json b/snippets/haskell.json index 1bc33ece..62e89997 100644 --- a/snippets/haskell.json +++ b/snippets/haskell.json @@ -106,7 +106,7 @@ }, "lambda": { "prefix": ["\\", "lambda"], - "body": ["\\${1:x} -> ${2:undefined}$0"], + "body": ["\\\\${1:x} -> ${2:undefined}$0"], "description": "lambda function" }, "pragma": { From 33c58dc86e48a81f91ae79b9a661964f8f2339f1 Mon Sep 17 00:00:00 2001 From: David Sanchez <84427300+davidsanchez222@users.noreply.github.com> Date: Sun, 20 Apr 2025 21:47:31 -0400 Subject: [PATCH 21/27] added semicolons at the end of statements from "puts" to "reallocarray" down the file chronologically (#568) --- snippets/c/c.json | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/snippets/c/c.json b/snippets/c/c.json index b67b5d79..5028a840 100644 --- a/snippets/c/c.json +++ b/snippets/c/c.json @@ -274,67 +274,67 @@ }, "puts": { "prefix": "puts", - "body": ["puts(\"${1:This function doesn't need newline.}\")$0"], + "body": ["puts(\"${1:This function doesn't need newline.}\");$0"], "description": "puts() snippet" }, "fputs": { "prefix": "fputs", - "body": ["fputs(\"${2:This is a simpler printf.\\n}\", ${1:stdout})$0"], + "body": ["fputs(\"${2:This is a simpler printf.\\n}\", ${1:stdout});$0"], "description": "puts() snippet" }, "printf": { "prefix": "printf", - "body": ["printf(\"${1:%s}\\n\"$2)$0"], + "body": ["printf(\"${1:%s}\\n\"$2);$0"], "description": "printf() snippet" }, "fprintf": { "prefix": "fprintf", - "body": ["fprintf(${1:stderr}, \"${2:%s}\\n\"$3)$0"], + "body": ["fprintf(${1:stderr}, \"${2:%s}\\n\"$3);$0"], "description": "fprintf() snippet" }, "sprintf": { "prefix": "sprintf", - "body": ["sprintf(${1:buf}, \"${2:%s}\\n\"$3)$0"], + "body": ["sprintf(${1:buf}, \"${2:%s}\\n\"$3);$0"], "description": "sprintf() snippet" }, "snprintf": { "prefix": "snprintf", - "body": ["snprintf(${1:buf}, ${2:max}, \"${3:%s}\\n\"$3)$0"], + "body": ["snprintf(${1:buf}, ${2:max}, \"${3:%s}\\n\"$3);$0"], "description": "snprintf() snippet" }, "scanf": { "prefix": "scanf", - "body": ["scanf(\"${1:%d}\"$2)$0"], + "body": ["scanf(\"${1:%d}\"$2);$0"], "description": "scanf() snippet" }, "fscanf": { "prefix": "fscanf", - "body": ["fscanf(${1:stdin}, \"${2:%d}\"$3)$0"], + "body": ["fscanf(${1:stdin}, \"${2:%d}\"$3);$0"], "description": "fscanf() snippet" }, "sscanf": { "prefix": "sscanf", - "body": ["sscanf(${1:buf}, \"${2:%d}\"$3)$0"], + "body": ["sscanf(${1:buf}, \"${2:%d}\"$3);$0"], "description": "sscanf() snippet" }, "malloc": { "prefix": "malloc", - "body": ["malloc(sizeof(${1:int[69]})$2)$0"], + "body": ["malloc(sizeof(${1:int[69]})$2);$0"], "description": "malloc() snippet" }, "calloc": { "prefix": "calloc", - "body": ["calloc(${1:1}, sizeof(${2:int})$3)$0"], + "body": ["calloc(${1:1}, sizeof(${2:int})$3);$0"], "description": "calloc() snippet" }, "realloc": { "prefix": "realloc", - "body": ["realloc(${1:ptr}, sizeof(${2:int[69]})$3)$0"], + "body": ["realloc(${1:ptr}, sizeof(${2:int[69]})$3);$0"], "description": "realloc() snippet" }, "reallocarray": { "prefix": "reallocarray", - "body": ["reallocarray(${1:ptr}, ${2:69}, sizeof(${3:int})$4)$0"], + "body": ["reallocarray(${1:ptr}, ${2:69}, sizeof(${3:int})$4);$0"], "description": "reallocarray() snippet" }, "free": { From cba1b7152964866d19f5d0b076338197cfc4a447 Mon Sep 17 00:00:00 2001 From: Marian Date: Mon, 21 Apr 2025 04:48:05 +0300 Subject: [PATCH 22/27] Add ruby benchmark (#561) --- snippets/ruby/ruby.json | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/snippets/ruby/ruby.json b/snippets/ruby/ruby.json index 84d7a69d..b8d69c79 100644 --- a/snippets/ruby/ruby.json +++ b/snippets/ruby/ruby.json @@ -29,6 +29,26 @@ "end" ] }, + "Ruby Benchmark Measure": { + "prefix": "benchm", + "body": [ + "require 'benchmark'", + "", + "puts Benchmark.measure { ${1:# benchmark code} }" + ] + }, + "Ruby Benchmark BM": { + "prefix": "benchbm", + "body": [ + "require 'benchmark'", + "", + "n = ${1:50000}", + "Benchmark.bm do |x|", + " x.report(\"${2:Task 1}\") { n.times { ${3:\"task 1\"} } }", + " x.report(\"${4:Task 2}\") { n.times { ${5:\"task 2\"} } }", + "end" + ] + }, "Class definition with initialize": { "prefix": "class init", "body": [ From fbf1a2705f8bc86cc67dc260605242078bf9d506 Mon Sep 17 00:00:00 2001 From: Jost Alemann <58050402+ddogfoodd@users.noreply.github.com> Date: Mon, 21 Apr 2025 03:48:23 +0200 Subject: [PATCH 23/27] zig: add missing semicolons (#562) --- snippets/zig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/zig.json b/snippets/zig.json index 19a72c4b..ddf7041e 100644 --- a/snippets/zig.json +++ b/snippets/zig.json @@ -1,12 +1,12 @@ { "Import": { "prefix": "import", - "body": ["const ${1} = @import(\"${1}\")"], + "body": ["const ${1} = @import(\"${1}\");"], "description": "Importing Libraries" }, "CImport": { "prefix": "cimport", - "body": ["const c = @cImport({", " @cDefine(\"${1}\")", "});"], + "body": ["const c = @cImport({", " @cDefine(\"${1}\");", "});"], "description": "Importing C Header Files" }, "buildExe": { From ed8d368c48e15c516c9f68d9e27d95860b51128a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9D=90=8D=F0=9D=90=86=F0=9D=90=8F=F0=9D=90=8E?= =?UTF-8?q?=F0=9D=90=8D=F0=9D=90=86?= Date: Mon, 21 Apr 2025 09:53:04 +0800 Subject: [PATCH 24/27] fix: `while` snippet in cpp should end within the logical scope (#560) --- snippets/cpp/cpp.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/cpp/cpp.json b/snippets/cpp/cpp.json index fc5d60e8..3ff98ffe 100644 --- a/snippets/cpp/cpp.json +++ b/snippets/cpp/cpp.json @@ -37,8 +37,8 @@ }, "while": { "prefix": "while", - "body": ["while ($1) {", "\t$2", "}"], - "description": "" + "body": ["while ($1) {", "\t$0", "}"], + "description": "'while' loop snippet" }, "foreach": { "prefix": "foreach", From e381a9c3fa01c3a7b75ff336e77ce3a6a8e34b69 Mon Sep 17 00:00:00 2001 From: Noustaa <69060343+Noustaa@users.noreply.github.com> Date: Mon, 21 Apr 2025 03:54:12 +0200 Subject: [PATCH 25/27] Fix typo in cmake cxx standard snippet (#569) --- snippets/cmake.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/cmake.json b/snippets/cmake.json index 5de528de..ef82a815 100644 --- a/snippets/cmake.json +++ b/snippets/cmake.json @@ -229,8 +229,8 @@ "Set c++ standard": { "prefix": "cxx", "body": [ - "set(CMAKE_CXX_STANDDARD ${1:14})", - "set(CMAKE_CXX_STANDDARD_REQUIRED ON)" + "set(CMAKE_CXX_STANDARD ${1:14})", + "set(CMAKE_CXX_STANDARD_REQUIRED ON)" ], "description": "Add the snippet to set c++ standard" }, From bedf8a06104a657678adec524b67be6806d2fead Mon Sep 17 00:00:00 2001 From: Richard Garber Date: Sun, 20 Apr 2025 22:03:57 -0400 Subject: [PATCH 26/27] Changed cpp include guard path symbol matching to make it work on unix and windows (#552) --- snippets/cpp/cpp.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/snippets/cpp/cpp.json b/snippets/cpp/cpp.json index 3ff98ffe..168f10d5 100644 --- a/snippets/cpp/cpp.json +++ b/snippets/cpp/cpp.json @@ -269,12 +269,12 @@ "#guard": { "prefix": "#guard", "body": [ - "#ifndef INCLUDE${TM_DIRECTORY/.*[\\\/](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", - "#define INCLUDE${TM_DIRECTORY/.*[\\\/](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", + "#ifndef INCLUDE${TM_DIRECTORY/.*[\\/\\\\](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", + "#define INCLUDE${TM_DIRECTORY/.*[\\/\\\\](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_", "", "$0", "", - "#endif // INCLUDE${TM_DIRECTORY/.*[\\\/](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_" + "#endif // INCLUDE${TM_DIRECTORY/.*[\\/\\\\](.*)/_${1:/upcase}/}${TM_FILENAME_BASE/(.*)/_${1:/upcase}/}${TM_FILENAME/.*\\.(.*)/_${1:/upcase}/}_" ], "description": "header guard. format :\n\tINCLUDE____" }, From fc8f183479a472df60aa86f00e295462f2308178 Mon Sep 17 00:00:00 2001 From: Volodymyr But Date: Mon, 21 Apr 2025 04:26:27 +0200 Subject: [PATCH 27/27] fix html5 snippet to auto-select placeholders (#570) --- snippets/html.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/html.json b/snippets/html.json index 258d2493..02456166 100644 --- a/snippets/html.json +++ b/snippets/html.json @@ -327,12 +327,12 @@ "prefix": "html5", "body": [ "", - "", + "", "\t", "\t\t", "\t\t", "\t\t$2", - "\t\t", + "\t\t", "\t", "\t", "\t$0",