Skip to content

Commit c656e4b

Browse files
committed
Remove many default values, strategically place semicolons where it fixes tabstops jumps
1 parent 64afae1 commit c656e4b

File tree

10 files changed

+174
-153
lines changed

10 files changed

+174
-153
lines changed

README.md

Lines changed: 112 additions & 96 deletions
Large diffs are not rendered by default.

src/snippets/js/assignments.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export const assignments: XSnippetDefinition = {
1515
},
1616
ca: {
1717
name: "const assignment",
18-
body: "const $1 = $0",
18+
body: "const $1 = $2;",
1919
},
2020
la: {
2121
name: "let assignment",
22-
body: "let $1 = $0",
22+
body: "let $1 = $2;",
2323
},
2424
cas: {
2525
name: "const string assignment",
26-
body: "const $1 = '$0'",
26+
body: "const $1 = '$2';",
2727
},
2828
car: {
2929
name: "const array assignment",

src/snippets/js/functions.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const functions: XSnippetDefinition = {
1515
},
1616
nfn: {
1717
name: "named arrow function",
18-
body: "const ${1:name} = ($2) => {$0}",
18+
body: "const ${1} = ($2) => {$0}",
1919
},
2020
nfna: {
2121
name: "async named arrow function",
@@ -37,25 +37,9 @@ export const functions: XSnippetDefinition = {
3737
name: "async arrow function with body",
3838
body: "async ($1) => {\n\t$0\n}",
3939
},
40-
efn: {
41-
name: "export function",
42-
body: [
43-
"export function ${1:name}($2) {",
44-
"\t$0",
45-
"}",
46-
],
47-
},
48-
edfn: {
49-
name: "export default function",
50-
body: "export default function ${1:name}($2) {\n\t$0\n}",
51-
},
52-
enfn: {
53-
name: "export named arrow function",
54-
body: "export const ${1:name} = ($2) => {$0}",
55-
},
5640
iife: {
5741
name: "immediately-invoked function expression",
58-
body: "((${1:arguments}) => {\n\t$0\n})($2)",
42+
body: "(($1) => {\n\t$0\n})($2)",
5943
},
6044
},
6145
};

src/snippets/js/misc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { XSnippetDefinition } from "../../models/app.ts";
22

3-
export const misc: XSnippetDefinitionk = {
3+
export const misc: XSnippetDefinition = {
44
meta: {
55
title: "Misc",
66
},

src/snippets/js/modules.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,28 @@ export const modules: XSnippetDefinition = {
77
snippets: {
88
im: {
99
name: "import from module",
10-
body: "import { $2 } from '$1'",
10+
body: "import { $2 } from '${1:module}';",
11+
},
12+
imd: {
13+
name: "import default",
14+
body: "import $2 from '${1:module}';",
15+
},
16+
ima: {
17+
name: "import as",
18+
body: "import ${2:*} as ${3:name} from '${1:module}';",
1119
},
1220
imf: {
1321
name: "import file",
14-
body: "import '$1'",
22+
body: "import '$1';",
1523
},
24+
// TODO: decide on snippet prefix
1625
imp: {
1726
name: "import dynamic",
18-
body: "import($0)",
19-
},
20-
imd: {
21-
name: "import default",
22-
body: "import $2 from '$1'$3;",
27+
body: "import('$0')",
2328
},
24-
ima: {
25-
name: "import as",
26-
body: "import ${2:*} as {3:name} from '$1'",
29+
impa: {
30+
name: "await import dynamic",
31+
body: "await import('$0')",
2732
},
2833
ime: {
2934
name: "import meta env",
@@ -39,15 +44,31 @@ export const modules: XSnippetDefinition = {
3944
},
4045
exf: {
4146
name: "export from",
42-
body: "export { $2 } from '$1'",
47+
body: "export { $0 } from '${1:module}';",
4348
},
4449
exa: {
4550
name: "export all from",
46-
body: "export * from '$1'",
51+
body: "export * from '${1:module}';",
4752
},
4853
exo: {
4954
name: "export object",
5055
body: "export const ${1:name} = { $0 }",
5156
},
57+
efn: {
58+
name: "export function",
59+
body: [
60+
"export function ${1:name}($2) {",
61+
"\t$0",
62+
"}",
63+
],
64+
},
65+
edfn: {
66+
name: "export default function",
67+
body: "export default function ${1:name}($2) {\n\t$0\n}",
68+
},
69+
enfn: {
70+
name: "export named arrow function",
71+
body: "export const ${1:name} = ($2) => {$0}",
72+
},
5273
},
5374
};

src/snippets/js/operators-expressions-literals.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,27 @@ export const operatorsExpressionsLiterals = {
2323
},
2424
ore: {
2525
name: "logical OR expression",
26-
body: "${1:value} || ${0:value}",
26+
body: "$1 || $0",
2727
},
2828
ande: {
2929
name: "logical AND expression",
30-
body: "${1:value} && ${0:value}",
30+
body: "$1 && $0",
3131
},
3232
nce: {
3333
name: "nullish coalescing expression (??)",
34-
body: "${1:item} ?? ${0:default}",
34+
body: "$1 ?? $0",
3535
},
3636
eqe: {
3737
name: "strict equality expression",
38-
body: "${1:value} === ${2:value}",
38+
body: "$1 === $0",
3939
},
4040
ora: {
4141
name: "logical OR assignment (||=)",
42-
body: "${1:name} ||= ${0:default}",
42+
body: "$1 ||= $0",
4343
},
4444
nca: {
4545
name: "nullish coalescing assignment (??=)",
46-
body: "${1:name} ??= ${0:default}",
46+
body: "$1 ??= $0",
4747
},
4848
inc: {
4949
name: "addition assignment",

src/snippets/js/promises.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export const promises: XSnippetDefinition = {
77
snippets: {
88
fet: {
99
name: "fetch",
10-
body: "fetch('$1').then(res => res.json())",
10+
body: "fetch('$1'$2).then(res => res.json())",
1111
},
1212
feta: {
1313
name: "fetch assignment",
1414
body:
15-
"const ${2|data,{ data }|} = await fetch('$1').then(res => res.json())",
15+
"const ${1|data,{ data }|} = await fetch('$2'$3).then(res => res.json())",
1616
},
1717
pr: {
1818
name: "promise",
@@ -27,15 +27,15 @@ export const promises: XSnippetDefinition = {
2727
body: "Promise.reject($1)",
2828
},
2929
then: {
30-
name: "promise .then",
30+
name: "promise then()",
3131
body: "$1.then((${2:value}) => $0)",
3232
},
3333
catch: {
34-
name: "promise .catch",
34+
name: "promise catch()",
3535
body: "$1.catch((${2:err}) => $0)",
3636
},
3737
thenc: {
38-
name: "promise .then.catch",
38+
name: "promise then().catch()",
3939
body: "$1.then((${2:value}) => $3).catch((${4:err}) => $5)",
4040
},
4141
pra: {

src/snippets/js/uncategorized.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ export const uncategorized: XSnippetDefinition = {
88
snippets: {
99
uniq: {
1010
name: "array of unique values",
11-
body: "[...new Set(${0:array})]",
11+
body: "[...new Set($0)]",
1212
},
1313
pi: {
1414
name: "parse int",
15-
body: "parseInt(${1:value}, ${2|10,2,8,16|})",
15+
body: "parseInt($1, ${2|10,2,8,16|})",
1616
},
1717
pf: {
1818
name: "parse float",
19-
body: "parseFloat(${1:value})",
19+
body: "parseFloat($1)",
2020
},
2121
am: {
2222
name: "array merge",
23-
body: "[...${1:arr}$2]",
23+
body: "[...$1]",
2424
},
2525
om: {
2626
name: "object merge",
27-
body: "{ ...${1:object}$2 }",
27+
body: "{ ...$1 }",
2828
},
2929
aat: {
3030
name: "array.at",
31-
body: "${1:items}.at(${2:0})",
31+
body: "$1.at(${2:0})",
3232
},
3333
seq: {
3434
name: "sequence of 0..n",

src/snippets/ts/declarations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ export const declarations: XSnippetDefinition = {
77
snippets: {
88
cat: {
99
name: "const assignment (typed)",
10-
body: "const ${1:name}: ${2:string} = ${3:value}",
10+
body: "const $1: ${2:string} = $3",
1111
},
1212
lat: {
1313
name: "let assignment (typed)",
14-
body: "let ${1:name}: ${2:string} = ${3:value}",
14+
body: "let $1: ${2:string} = $3",
1515
},
1616
caat: {
1717
name: "array assignment (typed)",
18-
body: "const ${1:items}: ${2:string}[] = [$0]",
18+
body: "const $1: ${2:string}[] = [$0]",
1919
},
2020
caot: {
2121
name: "object assignment (typed)",
22-
body: "const ${1:name}: ${2:object} = { $0 }",
22+
body: "const $1: ${2:object} = { $0 }",
2323
},
2424
},
2525
};

src/snippets/ts/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ export const types: XSnippetDefinition = {
1919
},
2020
tpu: {
2121
name: "type union",
22-
body: "type ${1:Model} = ${2:first} | ${3:second}",
22+
body: "type ${1:Model} = $2 | $3",
2323
},
2424
tpi: {
2525
name: "type intersection",
26-
body: "type ${1:Model} = ${2:first} & ${3:second}",
26+
body: "type ${1:Model} = $2 & $3",
2727
},
2828
},
2929
};

0 commit comments

Comments
 (0)