-
Notifications
You must be signed in to change notification settings - Fork 108
Fix Issue #2276 #2277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Issue #2276 #2277
Changes from all commits
d336f33
fabf3c3
1a53e78
d1b9afc
a7f8a27
dbffdaf
5ef576b
9588849
a566032
8610bfb
7bc64cb
8536899
d9f5b4e
1e5a9a8
cacb48f
98a8290
1dc3773
f54e692
88cc91d
d91fc7b
a2a3a5a
ce8b610
25a6ecb
59d7783
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@graphql-eslint/eslint-plugin': patch | ||
| --- | ||
|
|
||
| fix false positive cases for `require-import-fragment` on Windows, when `graphql-config`'s `documents` key contained glob pattern => source file path of document contained always forward slashes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| #import 'bar-fragment.gql' | ||
| #import './fragments/bar-fragment.gql' | ||
| query { | ||
| foo { | ||
| ...FooFields | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import path from 'node:path'; | |
| import { NameNode } from 'graphql'; | ||
| import { GraphQLESTreeNode } from '../../estree-converter/index.js'; | ||
| import { GraphQLESLintRule } from '../../types.js'; | ||
| import { requireSiblingsOperations } from '../../utils.js'; | ||
| import { requireSiblingsOperations, slash } from '../../utils.js'; | ||
|
|
||
| const RULE_ID = 'require-import-fragment'; | ||
| const SUGGESTION_ID = 'add-import-expression'; | ||
|
|
@@ -89,21 +89,21 @@ export const rule: GraphQLESLintRule = { | |
|
|
||
| const extractedImportPath = comment.value.match(/(["'])((?:\1|.)*?)\1/)?.[2]; | ||
| if (!extractedImportPath) continue; | ||
|
|
||
| const importPath = path.join(path.dirname(filePath), extractedImportPath); | ||
| const importPath = path.join(filePath, '..', extractedImportPath); | ||
| const hasInSiblings = fragmentsFromSiblings.some( | ||
| source => source.filePath === importPath, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. previously you added
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought so too, but when I printed out the filePath in I saw this syntax. On Windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strange because I added console log on ci and get backslash on windows There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here I commented d9f5b4e and got There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder maybe it happens when you specify glob syntax for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ); | ||
| if (hasInSiblings) return; | ||
| } | ||
|
|
||
| const fragmentInSameFile = fragmentsFromSiblings.some( | ||
| source => source.filePath === filePath, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same, |
||
| ); | ||
| if (fragmentInSameFile) return; | ||
|
|
||
| const suggestedFilePaths = fragmentsFromSiblings.length | ||
| ? fragmentsFromSiblings.map(o => path.relative(path.dirname(filePath), o.filePath)) | ||
| ? fragmentsFromSiblings.map(o => | ||
| // Use always forward slash for suggested import path | ||
| slash(path.relative(path.dirname(filePath), o.filePath)), | ||
| ) | ||
| : ['CHANGE_ME.graphql']; | ||
|
|
||
| context.report({ | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yoavain-sundaysky this is better fix, so other rules will get always os specific slash