@@ -11,6 +11,7 @@ import componentsSnippets, {
1111import consoleSnippets , { ConsoleSnippet } from './sourceSnippets/console' ;
1212import hooksSnippets , { HooksSnippet } from './sourceSnippets/hooks' ;
1313import importsSnippets , { ImportsSnippet } from './sourceSnippets/imports' ;
14+ import othersSnippets , { OthersSnippet } from './sourceSnippets/others' ;
1415import propTypesSnippets , {
1516 PropTypesSnippet ,
1617} from './sourceSnippets/propTypes' ;
@@ -24,6 +25,7 @@ import typescriptSnippets, {
2425} from './sourceSnippets/typescript' ;
2526
2627export type SnippetKeys =
28+ | OthersSnippet [ 'key' ]
2729 | HooksSnippet [ 'key' ]
2830 | ImportsSnippet [ 'key' ]
2931 | ReactNativeSnippet [ 'key' ]
@@ -35,6 +37,7 @@ export type SnippetKeys =
3537 | TestsSnippet [ 'key' ] ;
3638
3739export type Snippet =
40+ | OthersSnippet
3841 | HooksSnippet
3942 | ImportsSnippet
4043 | ReactNativeSnippet
@@ -49,6 +52,19 @@ export type Snippets = {
4952 [ key in SnippetKeys ] : Snippet ;
5053} ;
5154
55+ // This is array of prefixes which are currently skipped because of syntax format issues
56+ const skippedSnippets = [
57+ 'pge' ,
58+ 'pse' ,
59+ 'gdsfp' ,
60+ 'gsbu' ,
61+ 'scu' ,
62+ 'cwun' ,
63+ 'cdm' ,
64+ 'cdup' ,
65+ 'rconst' ,
66+ ] ;
67+
5268const getSnippets = ( ) => {
5369 const { typescript, languageScopes } = extensionConfig ( ) ;
5470
@@ -62,13 +78,18 @@ const getSnippets = () => {
6278 ...reactNativeSnippets ,
6379 ...reduxSnippets ,
6480 ...testsSnippets ,
81+ ...othersSnippets ,
6582 ] . reduce ( ( acc , snippet ) => {
6683 const snippetBody =
6784 typeof snippet . body === 'string' ? snippet . body : snippet . body . join ( '\n' ) ;
68- acc [ snippet . key ] = Object . assign ( snippet , {
69- scope : languageScopes ,
70- body : formatSnippet ( snippetBody ) . split ( '\n' ) ,
71- } ) ;
85+ const formattedSnippet = skippedSnippets . includes ( snippet . prefix )
86+ ? snippetBody
87+ : formatSnippet ( snippetBody ) . split ( '\n' ) ;
88+
89+ const body =
90+ snippet . body . length === 1 ? formattedSnippet [ 0 ] : formattedSnippet ;
91+
92+ acc [ snippet . key ] = Object . assign ( snippet , { body, scope : languageScopes } ) ;
7293 return acc ;
7394 } , { } as Snippets ) ;
7495
0 commit comments