graphql-eslint icon indicating copy to clipboard operation
graphql-eslint copied to clipboard

`require-import-fragment` quick fix is not compatible w/ Webpack loader + Jest transform

Open grxy opened this issue 1 year ago • 1 comments

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • [x] 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

Example

  • [ ] 2. A failing test has been provided
  • [ ] 3. A local solution has been provided
  • [ ] 4. A pull request is pending review

Describe the bug

The quick fix for require-import-fragment creates an import that doesn't work w/ graphql-tag/loader or jest-transform-graphql out of the box.

To Reproduce Steps to reproduce the behavior:

  1. Reference a fragment in a .graphql file.
  2. Run the eslint quick fix on that .graphql file.

Expected behavior

The following import is added:

#import './0-file-with-fragment.graphql'
  1. No MyFragment import
  2. No space after the # character
  3. Path includes ./ when in same directory

Actual behavior

The following import is added:

# import MyFragment from '0-file-with-fragment.graphql'

Environment:

  • OS: macOS 13.5.1
  • @graphql-eslint/eslint-plugin: 3.20.1
  • Node.js: v18.12.1

Additional context

N/A

grxy avatar Aug 24 '23 21:08 grxy

++

frimmy avatar Apr 09 '24 14:04 frimmy