File tree 2 files changed +13
-2
lines changed
packages/plugin/src/processors
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @graphql-eslint/eslint-plugin ' : patch
3
+ ---
4
+
5
+ Fix processor compatibility with other plugins
Original file line number Diff line number Diff line change 1
1
import { parseCode } from '@graphql-tools/graphql-tag-pluck' ;
2
+ import { basename } from 'path' ;
2
3
3
4
const RELEVANT_KEYWORDS = [ 'gql' , 'graphql' , '/* GraphQL */' ] ;
4
5
@@ -19,6 +20,11 @@ export function createGraphqlProcessor() {
19
20
const blocks : Block [ ] = [ ] ;
20
21
blocksMap . set ( filename , blocks ) ;
21
22
23
+ // WORKAROUND: This restores the original filename for the block representing original code.
24
+ // This allows to be compatible with other eslint plugins relying on filesystem
25
+ // This is temporary, waiting for https://github.com/eslint/eslint/issues/11989
26
+ const originalFileBlock = { text, filename : `/../../${ basename ( filename ) } ` }
27
+
22
28
if ( filename && text && RELEVANT_KEYWORDS . some ( keyword => text . includes ( keyword ) ) ) {
23
29
const extractedDocuments = parseCode ( {
24
30
code : text ,
@@ -39,13 +45,13 @@ export function createGraphqlProcessor() {
39
45
} ) ;
40
46
}
41
47
42
- blocks . push ( { text , filename } ) ;
48
+ blocks . push ( originalFileBlock ) ;
43
49
44
50
return blocks ;
45
51
}
46
52
}
47
53
48
- return [ { text , filename } ] ;
54
+ return [ originalFileBlock ] ;
49
55
} ,
50
56
postprocess : ( messageLists : any [ ] , filename : string ) : any [ ] => {
51
57
const blocks = blocksMap . get ( filename ) ;
You can’t perform that action at this time.
0 commit comments