Skip to content

Commit a2a3a5a

Browse files
committed
use always forward for suggested import path
1 parent d91fc7b commit a2a3a5a

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

packages/plugin/src/rules/require-import-fragment/index.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ function withMocks({
1919
code: ruleTester.fromMockFile(filename.split('mocks')[1]),
2020
parserOptions: {
2121
graphQLConfig: {
22-
documents: [
23-
filename,
24-
'./__tests__/mocks/import-fragments/fragments/**/*.gql',
25-
],
22+
documents: [filename, './__tests__/mocks/import-fragments/fragments/**/*.gql'],
2623
},
2724
} satisfies ParserOptionsForTests,
2825
errors,

packages/plugin/src/rules/require-import-fragment/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'node:path';
22
import { NameNode } from 'graphql';
33
import { GraphQLESTreeNode } from '../../estree-converter/index.js';
44
import { GraphQLESLintRule } from '../../types.js';
5-
import { requireSiblingsOperations } from '../../utils.js';
5+
import { requireSiblingsOperations, slash } from '../../utils.js';
66

77
const RULE_ID = 'require-import-fragment';
88
const SUGGESTION_ID = 'add-import-expression';
@@ -99,9 +99,9 @@ export const rule: GraphQLESLintRule = {
9999
source => source.filePath === filePath,
100100
);
101101
if (fragmentInSameFile) return;
102-
console.log(fragmentsFromSiblings)
102+
console.log(fragmentsFromSiblings);
103103
const suggestedFilePaths = fragmentsFromSiblings.length
104-
? fragmentsFromSiblings.map(o => path.relative(path.dirname(filePath), o.filePath))
104+
? fragmentsFromSiblings.map(o => slash(path.relative(path.dirname(filePath), o.filePath)))
105105
: ['CHANGE_ME.graphql'];
106106

107107
context.report({

0 commit comments

Comments
 (0)