Skip to content

Commit 645a3ca

Browse files
committed
feat: add yup snippets
1 parent 288c696 commit 645a3ca

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

snippets/javascript.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,32 @@
13861386
"description": "Create `<button />` element",
13871387
"scope": "javascript,javascriptreact"
13881388
},
1389+
"🟨 yupV0Schema": {
1390+
"prefix": "yupSchema.$yupSchema",
1391+
"body": [
1392+
"export const ${1:user}Schema = yup.object({",
1393+
"\t${2:name}: ${3:yup.string().required()},",
1394+
"})",
1395+
"",
1396+
"export type ${1/(.*)/${1:/capitalize}/} = yup.Asserts<typeof ${1:user}Schema>",
1397+
""
1398+
],
1399+
"description": "Yup v0 schema",
1400+
"scope": "javascript,javascriptreact"
1401+
},
1402+
"🟨 yupV1Schema": {
1403+
"prefix": "yupSchema.$yupSchema",
1404+
"body": [
1405+
"export const ${1:user}Schema = yup.object({",
1406+
"\t${2:name}: ${3:yup.string().required()},",
1407+
"})",
1408+
"",
1409+
"export type ${1/(.*)/${1:/capitalize}/} = yup.InferType<typeof ${1:user}Schema>",
1410+
""
1411+
],
1412+
"description": "Yup v1 schema",
1413+
"scope": "javascript,javascriptreact"
1414+
},
13891415
"🟨 getFileNamePascalCase": {
13901416
"prefix": "fnpascalcase.$fnpascalcase",
13911417
"body": [

snippets/typescript.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,32 @@
17021702
"description": "Create `<button />` element",
17031703
"scope": "javascript,typescript,javascriptreact,typescriptreact"
17041704
},
1705+
"🟨 yupV0Schema": {
1706+
"prefix": "yupSchema.$yupSchema",
1707+
"body": [
1708+
"export const ${1:user}Schema = yup.object({",
1709+
"\t${2:name}: ${3:yup.string().required()},",
1710+
"})",
1711+
"",
1712+
"export type ${1/(.*)/${1:/capitalize}/} = yup.Asserts<typeof ${1:user}Schema>",
1713+
""
1714+
],
1715+
"description": "Yup v0 schema",
1716+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
1717+
},
1718+
"🟨 yupV1Schema": {
1719+
"prefix": "yupSchema.$yupSchema",
1720+
"body": [
1721+
"export const ${1:user}Schema = yup.object({",
1722+
"\t${2:name}: ${3:yup.string().required()},",
1723+
"})",
1724+
"",
1725+
"export type ${1/(.*)/${1:/capitalize}/} = yup.InferType<typeof ${1:user}Schema>",
1726+
""
1727+
],
1728+
"description": "Yup v1 schema",
1729+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
1730+
},
17051731
"🟨 getFileNamePascalCase": {
17061732
"prefix": "fnpascalcase.$fnpascalcase",
17071733
"body": [

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const emotion = normalizeSnippets(require('./snippets/emotion'));
3535
const testing = normalizeSnippets(require('./snippets/testing'));
3636
const wrapper = normalizeSnippets(require('./snippets/wrapper'));
3737
const htmlJsx = normalizeSnippets(require('./snippets/html-jsx'));
38+
const yup = normalizeSnippets(require('./snippets/yup'));
3839
const misc = normalizeSnippets(require('./snippets/misc'));
3940
const miscTS = normalizeSnippets(require('./snippets/misc-ts'), true);
4041

@@ -64,6 +65,7 @@ const javascriptSnippets = {
6465
...testing,
6566
...wrapper,
6667
...htmlJsx,
68+
...yup,
6769
...misc,
6870
};
6971

@@ -89,6 +91,7 @@ const typescriptSnippets = {
8991
...testing,
9092
...wrapper,
9193
...htmlJsx,
94+
...yup,
9295
...misc,
9396
...miscTS,
9497
};

src/snippets/yup.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Snippet } from '../types';
2+
3+
export const yupV0Schema: Snippet = {
4+
prefix: 'yupSchema',
5+
body: [
6+
'export const ${1:user}Schema = yup.object({',
7+
'\t${2:name}: ${3:yup.string().required()},',
8+
'})',
9+
'',
10+
'export type ${1/(.*)/${1:/capitalize}/} = yup.Asserts<typeof ${1:user}Schema>',
11+
'',
12+
],
13+
description: 'Yup v0 schema',
14+
};
15+
16+
export const yupV1Schema: Snippet = {
17+
prefix: 'yupSchema',
18+
body: [
19+
'export const ${1:user}Schema = yup.object({',
20+
'\t${2:name}: ${3:yup.string().required()},',
21+
'})',
22+
'',
23+
'export type ${1/(.*)/${1:/capitalize}/} = yup.InferType<typeof ${1:user}Schema>',
24+
'',
25+
],
26+
description: 'Yup v1 schema',
27+
};

0 commit comments

Comments
 (0)