Skip to content

Commit 17a8f0c

Browse files
committed
refactor: re-arrange snippets
1 parent 2778014 commit 17a8f0c

File tree

3 files changed

+165
-155
lines changed

3 files changed

+165
-155
lines changed

snippets/javascript.json

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -495,82 +495,6 @@
495495
"description": "React create custom hook",
496496
"scope": "javascript,javascriptreact"
497497
},
498-
"🟨 reactNativeFnComp": {
499-
"prefix": "rnFC.$rnFC",
500-
"body": [
501-
"import React from 'react'",
502-
"import { View, Text } from 'react-native'",
503-
"",
504-
"export default function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
505-
"\treturn (",
506-
"\t\t<View>",
507-
"\t\t\t<Text>${2:$1}</Text>",
508-
"\t\t</View>",
509-
"\t)",
510-
"}",
511-
""
512-
],
513-
"description": "React Native Functional Component",
514-
"scope": "javascript,javascriptreact"
515-
},
516-
"🟨 reactNativeFnCompExport": {
517-
"prefix": "rnFCe.$rnFCe",
518-
"body": [
519-
"import React from 'react'",
520-
"import { View, Text } from 'react-native'",
521-
"",
522-
"function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
523-
"\treturn (",
524-
"\t\t<View>",
525-
"\t\t\t<Text>${2:$1}</Text>",
526-
"\t\t</View>",
527-
"\t)",
528-
"}",
529-
"",
530-
"export default $1",
531-
""
532-
],
533-
"description": "React Native Functional Component",
534-
"scope": "javascript,javascriptreact"
535-
},
536-
"🟨 reactNativeArrowFnComp": {
537-
"prefix": "rnAFC.$rnAFC",
538-
"body": [
539-
"import React from 'react'",
540-
"import { View, Text } from 'react-native'",
541-
"",
542-
"export const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
543-
"\treturn (",
544-
"\t\t<View>",
545-
"\t\t\t<Text>${2:$1}</Text>",
546-
"\t\t</View>",
547-
"\t)",
548-
"}",
549-
""
550-
],
551-
"description": "React Native Arrow Function Component",
552-
"scope": "javascript,javascriptreact"
553-
},
554-
"🟨 reactNativeArrowFnCompExport": {
555-
"prefix": "rnAFCe.$rnAFCe",
556-
"body": [
557-
"import React from 'react'",
558-
"import { View, Text } from 'react-native'",
559-
"",
560-
"const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
561-
"\treturn (",
562-
"\t\t<View>",
563-
"\t\t\t<Text>${2:$1}</Text>",
564-
"\t\t</View>",
565-
"\t)",
566-
"}",
567-
"",
568-
"export default $1",
569-
""
570-
],
571-
"description": "React Native Arrow Function Component",
572-
"scope": "javascript,javascriptreact"
573-
},
574498
"🟨 nextSSR": {
575499
"prefix": "nSSR.$nSSR.getServerSideProps",
576500
"body": [
@@ -718,6 +642,82 @@
718642
"description": "Convert import to Next.js dynamic import",
719643
"scope": "javascript,javascriptreact"
720644
},
645+
"🟨 reactNativeFnComp": {
646+
"prefix": "rnFC.$rnFC",
647+
"body": [
648+
"import React from 'react'",
649+
"import { View, Text } from 'react-native'",
650+
"",
651+
"export default function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
652+
"\treturn (",
653+
"\t\t<View>",
654+
"\t\t\t<Text>${2:$1}</Text>",
655+
"\t\t</View>",
656+
"\t)",
657+
"}",
658+
""
659+
],
660+
"description": "React Native Functional Component",
661+
"scope": "javascript,javascriptreact"
662+
},
663+
"🟨 reactNativeFnCompExport": {
664+
"prefix": "rnFCe.$rnFCe",
665+
"body": [
666+
"import React from 'react'",
667+
"import { View, Text } from 'react-native'",
668+
"",
669+
"function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
670+
"\treturn (",
671+
"\t\t<View>",
672+
"\t\t\t<Text>${2:$1}</Text>",
673+
"\t\t</View>",
674+
"\t)",
675+
"}",
676+
"",
677+
"export default $1",
678+
""
679+
],
680+
"description": "React Native Functional Component",
681+
"scope": "javascript,javascriptreact"
682+
},
683+
"🟨 reactNativeArrowFnComp": {
684+
"prefix": "rnAFC.$rnAFC",
685+
"body": [
686+
"import React from 'react'",
687+
"import { View, Text } from 'react-native'",
688+
"",
689+
"export const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
690+
"\treturn (",
691+
"\t\t<View>",
692+
"\t\t\t<Text>${2:$1}</Text>",
693+
"\t\t</View>",
694+
"\t)",
695+
"}",
696+
""
697+
],
698+
"description": "React Native Arrow Function Component",
699+
"scope": "javascript,javascriptreact"
700+
},
701+
"🟨 reactNativeArrowFnCompExport": {
702+
"prefix": "rnAFCe.$rnAFCe",
703+
"body": [
704+
"import React from 'react'",
705+
"import { View, Text } from 'react-native'",
706+
"",
707+
"const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
708+
"\treturn (",
709+
"\t\t<View>",
710+
"\t\t\t<Text>${2:$1}</Text>",
711+
"\t\t</View>",
712+
"\t)",
713+
"}",
714+
"",
715+
"export default $1",
716+
""
717+
],
718+
"description": "React Native Arrow Function Component",
719+
"scope": "javascript,javascriptreact"
720+
},
721721
"🟨 reactRouterUseParams": {
722722
"prefix": "rou.$rou.useParams",
723723
"body": [

snippets/typescript.json

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -674,82 +674,6 @@
674674
"description": "React useCallback",
675675
"scope": "javascript,typescript,javascriptreact,typescriptreact"
676676
},
677-
"🟨 reactNativeFnComp": {
678-
"prefix": "rnFC.$rnFC",
679-
"body": [
680-
"import React from 'react'",
681-
"import { View, Text } from 'react-native'",
682-
"",
683-
"export default function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
684-
"\treturn (",
685-
"\t\t<View>",
686-
"\t\t\t<Text>${2:$1}</Text>",
687-
"\t\t</View>",
688-
"\t)",
689-
"}",
690-
""
691-
],
692-
"description": "React Native Functional Component",
693-
"scope": "javascript,typescript,javascriptreact,typescriptreact"
694-
},
695-
"🟨 reactNativeFnCompExport": {
696-
"prefix": "rnFCe.$rnFCe",
697-
"body": [
698-
"import React from 'react'",
699-
"import { View, Text } from 'react-native'",
700-
"",
701-
"function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
702-
"\treturn (",
703-
"\t\t<View>",
704-
"\t\t\t<Text>${2:$1}</Text>",
705-
"\t\t</View>",
706-
"\t)",
707-
"}",
708-
"",
709-
"export default $1",
710-
""
711-
],
712-
"description": "React Native Functional Component",
713-
"scope": "javascript,typescript,javascriptreact,typescriptreact"
714-
},
715-
"🟨 reactNativeArrowFnComp": {
716-
"prefix": "rnAFC.$rnAFC",
717-
"body": [
718-
"import React from 'react'",
719-
"import { View, Text } from 'react-native'",
720-
"",
721-
"export const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
722-
"\treturn (",
723-
"\t\t<View>",
724-
"\t\t\t<Text>${2:$1}</Text>",
725-
"\t\t</View>",
726-
"\t)",
727-
"}",
728-
""
729-
],
730-
"description": "React Native Arrow Function Component",
731-
"scope": "javascript,typescript,javascriptreact,typescriptreact"
732-
},
733-
"🟨 reactNativeArrowFnCompExport": {
734-
"prefix": "rnAFCe.$rnAFCe",
735-
"body": [
736-
"import React from 'react'",
737-
"import { View, Text } from 'react-native'",
738-
"",
739-
"const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
740-
"\treturn (",
741-
"\t\t<View>",
742-
"\t\t\t<Text>${2:$1}</Text>",
743-
"\t\t</View>",
744-
"\t)",
745-
"}",
746-
"",
747-
"export default $1",
748-
""
749-
],
750-
"description": "React Native Arrow Function Component",
751-
"scope": "javascript,typescript,javascriptreact,typescriptreact"
752-
},
753677
"🟨 nextSSR": {
754678
"prefix": "nSSR.$nSSR.getServerSideProps",
755679
"body": [
@@ -1015,6 +939,82 @@
1015939
"description": "Next.js getStaticPaths arrow function",
1016940
"scope": "javascript,typescript,javascriptreact,typescriptreact"
1017941
},
942+
"🟨 reactNativeFnComp": {
943+
"prefix": "rnFC.$rnFC",
944+
"body": [
945+
"import React from 'react'",
946+
"import { View, Text } from 'react-native'",
947+
"",
948+
"export default function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
949+
"\treturn (",
950+
"\t\t<View>",
951+
"\t\t\t<Text>${2:$1}</Text>",
952+
"\t\t</View>",
953+
"\t)",
954+
"}",
955+
""
956+
],
957+
"description": "React Native Functional Component",
958+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
959+
},
960+
"🟨 reactNativeFnCompExport": {
961+
"prefix": "rnFCe.$rnFCe",
962+
"body": [
963+
"import React from 'react'",
964+
"import { View, Text } from 'react-native'",
965+
"",
966+
"function ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}}() {$0",
967+
"\treturn (",
968+
"\t\t<View>",
969+
"\t\t\t<Text>${2:$1}</Text>",
970+
"\t\t</View>",
971+
"\t)",
972+
"}",
973+
"",
974+
"export default $1",
975+
""
976+
],
977+
"description": "React Native Functional Component",
978+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
979+
},
980+
"🟨 reactNativeArrowFnComp": {
981+
"prefix": "rnAFC.$rnAFC",
982+
"body": [
983+
"import React from 'react'",
984+
"import { View, Text } from 'react-native'",
985+
"",
986+
"export const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
987+
"\treturn (",
988+
"\t\t<View>",
989+
"\t\t\t<Text>${2:$1}</Text>",
990+
"\t\t</View>",
991+
"\t)",
992+
"}",
993+
""
994+
],
995+
"description": "React Native Arrow Function Component",
996+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
997+
},
998+
"🟨 reactNativeArrowFnCompExport": {
999+
"prefix": "rnAFCe.$rnAFCe",
1000+
"body": [
1001+
"import React from 'react'",
1002+
"import { View, Text } from 'react-native'",
1003+
"",
1004+
"const ${1:${RELATIVE_FILEPATH/(^.+?(?=[\\/\\\\][^\\/\\\\]+[\\/\\\\][^\\/\\\\]+\\.[jt]sx?))|(\\.[jt]sx?$|[\\/\\\\](?:index|\\[).*|.+[\\/\\\\](?!(?:index|\\[))|[.\\-_\\/\\\\])|(\\w+)/${3:/capitalize}/g}} = () => {$0",
1005+
"\treturn (",
1006+
"\t\t<View>",
1007+
"\t\t\t<Text>${2:$1}</Text>",
1008+
"\t\t</View>",
1009+
"\t)",
1010+
"}",
1011+
"",
1012+
"export default $1",
1013+
""
1014+
],
1015+
"description": "React Native Arrow Function Component",
1016+
"scope": "javascript,typescript,javascriptreact,typescriptreact"
1017+
},
10181018
"🟨 reactRouterUseParams": {
10191019
"prefix": "rou.$rou.useParams",
10201020
"body": [

src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,26 @@ import * as fs from 'node:fs';
33

44
import { normalizeSnippets } from './utilities';
55

6+
/* ============================================================================================== */
7+
8+
// Vanilla JS
69
const vanilla = normalizeSnippets(require('./snippets/vanilla'));
710

11+
// React
812
const react = normalizeSnippets(require('./snippets/react'));
913
const reactTS = normalizeSnippets(require('./snippets/react-ts'), true);
1014
const reactHook = normalizeSnippets(require('./snippets/react-hook'));
1115
const reactHookTS = normalizeSnippets(require('./snippets/react-hook-ts'), true);
12-
const reactNative = normalizeSnippets(require('./snippets/react-native'));
1316

17+
// Popular React Libraries/Frameworks
1418
const next = normalizeSnippets(require('./snippets/next'));
1519
const nextTS = normalizeSnippets(require('./snippets/next-ts'), true);
20+
const reactNative = normalizeSnippets(require('./snippets/react-native'));
1621
const reactRouter = normalizeSnippets(require('./snippets/react-router'));
1722
const reactRouterV6 = normalizeSnippets(require('./snippets/react-router-v6'));
1823
const reactRouterV5 = normalizeSnippets(require('./snippets/react-router-v5'));
24+
25+
// Other React Libraries
1926
const reactQuery = normalizeSnippets(require('./snippets/react-query'));
2027
const swr = normalizeSnippets(require('./snippets/swr'));
2128
const reactHookForm = normalizeSnippets(require('./snippets/react-hook-form'));
@@ -24,12 +31,15 @@ const redux = normalizeSnippets(require('./snippets/redux'));
2431
const reduxTS = normalizeSnippets(require('./snippets/redux-ts'), true);
2532
const emotion = normalizeSnippets(require('./snippets/emotion'));
2633

34+
// Not related to React
2735
const testing = normalizeSnippets(require('./snippets/testing'));
2836
const wrapper = normalizeSnippets(require('./snippets/wrapper'));
2937
const htmlJsx = normalizeSnippets(require('./snippets/html-jsx'));
3038
const misc = normalizeSnippets(require('./snippets/misc'));
3139
const miscTS = normalizeSnippets(require('./snippets/misc-ts'), true);
3240

41+
/* ============================================================================================== */
42+
3343
// Add line break at the end
3444
Object.keys(react).forEach((key) => react[key].body.push(''));
3545
Object.keys(reactTS).forEach((key) => reactTS[key].body.push(''));
@@ -40,8 +50,8 @@ const javascriptSnippets = {
4050
...vanilla,
4151
...react,
4252
...reactHook,
43-
...reactNative,
4453
...next,
54+
...reactNative,
4555
...reactRouter,
4656
...reactRouterV6,
4757
...reactRouterV5,
@@ -63,9 +73,9 @@ const typescriptSnippets = {
6373
...reactTS,
6474
...reactHook,
6575
...reactHookTS,
66-
...reactNative,
6776
...next,
6877
...nextTS,
78+
...reactNative,
6979
...reactRouter,
7080
...reactRouterV6,
7181
...reactRouterV5,

0 commit comments

Comments
 (0)