3.11.x crashes when using config without `default` project
See original GitHub issueIssue workflow progress
Progress of the issue based on the Contributor Workflow
- 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox
Please make sure the graphql-eslint version under
package.json
matches yours. - 2. A failing test has been provided
- 3. A local solution has been provided
- 4. A pull request is pending review
Describe the bug
Upgrading from 3.10.7
to 3.11.0
and 3.11.1
causes a crash on startup in our project, as we do not have a default
project configured.
To Reproduce
Our schema does not contain a default
projects - each of our projects are explicitly named.
#1156 introduced a call to graphQLConfig().getDefault()
which will throw.
For example, running yarn lint
throws an error on initialisation:
ESLint: 8.23.1
[ProjectNotFoundError: Failed to load plugin '@graphql-eslint' declared in '.eslintrc.json#overrides[2]': Project 'default' not found
Referenced from: /path/to/.eslintrc.json] {
name: 'ProjectNotFoundError',
message: "Failed to load plugin '@graphql-eslint' declared in '.eslintrc.json#overrides[2]': Project 'default' not found\n" +
'Referenced from: /path/to/.eslintrc.json'
}
error Command failed with exit code 2.
It looks like the code expects to gracefully handle this as an optional, but getDefault()
will never return an optional.
I believe the fix should use getProjectForFile()
, to ensure the configuration is associated with the correct project.
Expected behavior
Running yarn lint
should work as 3.10.7 did.
Environment:
- OS: macOS 12.6
@graphql-eslint/eslint-plugin
: 3.11.1- Node.js: v16.14.2
Additional context
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
Amazing! thank you for the quick feedback, will be released now 😜
@notjosh
3.11.2-alpha-20220926144959-f269795
should be good 😃)