Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shaggy-planets-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-eslint/eslint-plugin': patch
---

Fix processor compatibility with other plugins
10 changes: 8 additions & 2 deletions packages/plugin/src/processors/code-files.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseCode } from '@graphql-tools/graphql-tag-pluck';
import { basename } from 'path';

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

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

// WORKAROUND: This restores the original filename for the block representing original code.
// This allows to be compatible with other eslint plugins relying on filesystem
// This is temporary, waiting for https://github.com/eslint/eslint/issues/11989
const originalFileBlock = { text, filename: `/../../${basename(filename)}` }

if (filename && text && RELEVANT_KEYWORDS.some(keyword => text.includes(keyword))) {
const extractedDocuments = parseCode({
code: text,
Expand All @@ -39,13 +45,13 @@ export function createGraphqlProcessor() {
});
}

blocks.push({ text, filename });
blocks.push(originalFileBlock);

return blocks;
}
}

return [{ text, filename }];
return [originalFileBlock];
},
postprocess: (messageLists: any[], filename: string): any[] => {
const blocks = blocksMap.get(filename);
Expand Down