Skip to content

Commit 937b322

Browse files
Fix processor compatibility with other plugins (#225)
* Fix processor compatibility with other plugins * added changeset Co-authored-by: Dotan Simha <dotansimha@gmail.com>
1 parent 72e03b2 commit 937b322

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.changeset/shaggy-planets-travel.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
Fix processor compatibility with other plugins

packages/plugin/src/processors/code-files.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { parseCode } from '@graphql-tools/graphql-tag-pluck';
2+
import { basename } from 'path';
23

34
const RELEVANT_KEYWORDS = ['gql', 'graphql', '/* GraphQL */'];
45

@@ -19,6 +20,11 @@ export function createGraphqlProcessor() {
1920
const blocks: Block[] = [];
2021
blocksMap.set(filename, blocks);
2122

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+
2228
if (filename && text && RELEVANT_KEYWORDS.some(keyword => text.includes(keyword))) {
2329
const extractedDocuments = parseCode({
2430
code: text,
@@ -39,13 +45,13 @@ export function createGraphqlProcessor() {
3945
});
4046
}
4147

42-
blocks.push({ text, filename });
48+
blocks.push(originalFileBlock);
4349

4450
return blocks;
4551
}
4652
}
4753

48-
return [{ text, filename }];
54+
return [originalFileBlock];
4955
},
5056
postprocess: (messageLists: any[], filename: string): any[] => {
5157
const blocks = blocksMap.get(filename);

0 commit comments

Comments
 (0)