@@ -23,31 +23,36 @@ export function createGraphqlProcessor() {
23
23
// WORKAROUND: This restores the original filename for the block representing original code.
24
24
// This allows to be compatible with other eslint plugins relying on filesystem
25
25
// This is temporary, waiting for https://github.com/eslint/eslint/issues/11989
26
- const originalFileBlock = { text, filename : `/../../${ basename ( filename ) } ` }
26
+ const originalFileBlock = { text, filename : `/../../${ basename ( filename ) } ` } ;
27
27
28
28
if ( filename && text && RELEVANT_KEYWORDS . some ( keyword => text . includes ( keyword ) ) ) {
29
- const extractedDocuments = parseCode ( {
30
- code : text ,
31
- filePath : filename ,
32
- options : {
33
- globalGqlIdentifierName : [ 'gql' , 'graphql' ] ,
34
- skipIndent : true ,
35
- } ,
36
- } ) ;
29
+ try {
30
+ const extractedDocuments = parseCode ( {
31
+ code : text ,
32
+ filePath : filename ,
33
+ options : {
34
+ globalGqlIdentifierName : [ 'gql' , 'graphql' ] ,
35
+ skipIndent : true ,
36
+ } ,
37
+ } ) ;
37
38
38
- if ( extractedDocuments && extractedDocuments . length > 0 ) {
39
- for ( const item of extractedDocuments ) {
40
- blocks . push ( {
41
- filename : `document.graphql` ,
42
- text : item . content ,
43
- lineOffset : item . loc . start . line - 1 ,
44
- offset : item . start + 1 ,
45
- } ) ;
46
- }
39
+ if ( extractedDocuments && extractedDocuments . length > 0 ) {
40
+ for ( const item of extractedDocuments ) {
41
+ blocks . push ( {
42
+ filename : `document.graphql` ,
43
+ text : item . content ,
44
+ lineOffset : item . loc . start . line - 1 ,
45
+ offset : item . start + 1 ,
46
+ } ) ;
47
+ }
47
48
48
- blocks . push ( originalFileBlock ) ;
49
+ blocks . push ( originalFileBlock ) ;
49
50
50
- return blocks ;
51
+ return blocks ;
52
+ }
53
+ } catch ( e ) {
54
+ // eslint-disable-next-line no-console
55
+ console . warn ( `[graphql-eslint/processor]: Unable to process file "${ filename } ": ` , e ) ;
51
56
}
52
57
}
53
58
0 commit comments