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/tall-keys-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-eslint/eslint-plugin': patch
---

Fix issues with Windows paths
6 changes: 4 additions & 2 deletions packages/plugin/src/rules/unique-fragment-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLESLintRule } from '../types';
import { requireSiblingsOperations } from '../utils';
import { normalizePath, requireSiblingsOperations } from '../utils';

const UNIQUE_FRAGMENT_NAME = 'UNIQUE_FRAGMENT_NAME';

Expand Down Expand Up @@ -61,7 +61,9 @@ const rule: GraphQLESLintRule<[], false> = {
const siblingFragments = siblings.getFragment(fragmentName);

const conflictingFragments = siblingFragments.filter(
f => f.document.name?.value === fragmentName && f.filePath !== context.getFilename()
f =>
f.document.name?.value === fragmentName &&
normalizePath(f.filePath) !== normalizePath(context.getFilename())
);

if (conflictingFragments.length > 0) {
Expand Down
6 changes: 4 additions & 2 deletions packages/plugin/src/rules/unique-operation-name.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GraphQLESLintRule } from '../types';
import { requireSiblingsOperations } from '../utils';
import { normalizePath, requireSiblingsOperations } from '../utils';

const UNIQUE_OPERATION_NAME = 'UNIQUE_OPERATION_NAME';

Expand Down Expand Up @@ -65,7 +65,9 @@ const rule: GraphQLESLintRule<[], false> = {
const siblingOperations = siblings.getOperation(operationName);

const conflictingOperations = siblingOperations.filter(
f => f.document.name?.value === operationName && f.filePath !== context.getFilename()
f =>
f.document.name?.value === operationName &&
normalizePath(f.filePath) !== normalizePath(context.getFilename())
);

if (conflictingOperations.length > 0) {
Expand Down
4 changes: 3 additions & 1 deletion packages/plugin/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ export function checkForEslint(token: Token, rawNode: DocumentNode): boolean {
if (token.kind !== 'Comment') {
return false;
}
const string = rawNode.loc?.source.body.substring(token.start+1, token.start+8);
const string = rawNode.loc?.source.body.substring(token.start + 1, token.start + 8);
if (string.toLocaleLowerCase().includes('eslint')) {
return true;
}
return false;
}

export const normalizePath = (path: string): string => (path || '').replace(/\\/g, '/');