@@ -21,7 +21,7 @@ class GraphQLStatementsFormatter {
2121 return this . prettify ( this . formatJS ( statements ) ) ;
2222 case 'typescript' :
2323 this . headerComments . push ( CODEGEN_WARNING ) ;
24- this . lintOverrides . push ( [
24+ this . lintOverrides . push ( ... [
2525 '/* tslint:disable */' ,
2626 '/* eslint-disable */'
2727 ] ) ;
@@ -38,20 +38,23 @@ class GraphQLStatementsFormatter {
3838
3939 formatGraphQL ( statements ) {
4040 const headerBuffer = this . headerComments . map ( comment => `# ${ comment } ` ) . join ( LINE_DELIMITOR ) ;
41- const statementsBuffer = [ ...statements ? .values ( ) ] . join ( LINE_DELIMITOR ) ;
42- const formattedOutput = [ headerBuffer , statementsBuffer ] . join ( LINE_DELIMITOR ) ;
41+ const statementsBuffer = statements ? [ ...statements . values ( ) ] . join ( LINE_DELIMITOR ) : '' ;
42+ const formattedOutput = [ headerBuffer , LINE_DELIMITOR , statementsBuffer ] . join ( LINE_DELIMITOR ) ;
4343 return formattedOutput ;
4444 }
4545
4646 formatJS ( statements ) {
47+ const lintOverridesBuffer = this . lintOverrides . join ( LINE_DELIMITOR ) ;
4748 const headerBuffer = this . headerComments . map ( comment => `// ${ comment } ` ) . join ( LINE_DELIMITOR ) ;
4849 const formattedStatements = [ ] ;
49- for ( const [ key , value ] of statements ) {
50- formattedStatements . push (
51- `export const ${ key } = /* GraphQL */ \`${ value } \``
52- ) ;
50+ if ( statements ) {
51+ for ( const [ key , value ] of statements ) {
52+ formattedStatements . push (
53+ `export const ${ key } = /* GraphQL */ \`${ value } \``
54+ ) ;
55+ }
5356 }
54- const formattedOutput = [ headerBuffer , ...formattedStatements ] . join ( LINE_DELIMITOR ) ;
57+ const formattedOutput = [ lintOverridesBuffer , headerBuffer , LINE_DELIMITOR , ...formattedStatements ] . join ( LINE_DELIMITOR ) ;
5558 return formattedOutput ;
5659 }
5760
0 commit comments