Skip to content
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: find graphqlrc files relative to linted file #900

Merged

Conversation

lennyburdette
Copy link
Contributor

Description

Before this change, loadConfigSync from graphql-config would use process.cwd to find any .graphqlrc files.

With a project like this:

project/
- packages/
  - app/
    - schema.graphql
    - .eslintrc
    - .graphqlrc
    - documents/
      - operation.graphql

the VSCode Eslint plugin throws an error about not being able to find the schema.graphql file when linting the operation.graphql.

This change passes in the rootDir option to loadConfigSync using the directory of the linted file. This will allow the .graphqlrc file to live in subfolders of the open project.

Fixes #899

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots/Sandbox (if appropriate/relevant):

https://stackblitz.com/edit/node-6fhvcm?file=README.md

How Has This Been Tested?

Unit tests, but I also installed my local copy in a separate project using "file:" in package.json to verify that it works with the VSCode ESLint plugin.

Test Environment:

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation - not applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules - not applicable

Thank you for your review!

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2022

🦋 Changeset detected

Latest commit: eff8668

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@graphql-eslint/eslint-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Before this change, `loadConfigSync` from graphql-config would use `process.cwd` to find any .graphqlrc files.

With a project like this:
```
project/
- packages/
  - app/
    - schema.graphql
    - .eslintrc
    - .graphqlrc
    - documents/
      - operation.graphql
```

the VSCode Eslint plugin throws an error about not being able to find the schema.graphql file when linting the operation.graphql.

This change passes in the [`rootDir` option](https://graphql-config.com/load-config#rootdir) to `loadConfigSync` using the directory of the linted file. This will allow the .graphqlrc file to live in subfolders of the open project.
@dimaMachina
Copy link
Owner

LGTM, thank you!

@dotansimha dotansimha merged commit 6f8c3b6 into dimaMachina:master Jan 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

loadGraphQLConfig searches for graphqlrc files relative to CWD, not the linted files
3 participants