Closed TimoWilhelm closed 1 year ago
Hi @TimoWilhelm, can you provide a reproduction repo of your problem? This will be helpful 🙏
Hi @B2o5T, I created an MRE at https://github.com/TimoWilhelm/mre-graphql-eslint-vscode.
To reproduce:
npm install
.dbaeumer.vscode-eslint
extension is installed.sample.graphql
file.Otherwise you can check the ESLint output window for errors.
Please let me you know if you were able to reproduce the issue or if you need anything else.
Thanks in advance!
parserOptions.operations
or graphql-config
file but not a both in same time, remove parserOptions.operations
from eslint config and add documents: ./**/*.graphql
in your graphql-config.plugin:@graphql-eslint/schema-recommended
if your schema is remote? Actually for your project is make sense to lint operations
but not schema typesgraphql-config
- https://countries.trevorblades.com
. And replaced your eslint config with
{
"root": true,
"overrides": [
{
"files": "*.graphql",
"extends": "plugin:@graphql-eslint/operations-recommended"
}
]
}
and received expected output
/Users/dimitri/Desktop/mre-graphql-eslint-vscode/sample.graphql
2:3 error Cannot query field "sample_item" on type "Query" @graphql-eslint/fields-on-correct-type
✖ 1 problem (1 error, 0 warnings)
## ❗️So everything works as expected in terminal but not in VSCode-ESLint extension and you pointed a right line
Because `process.execPath` equals `/Users/dimitri/.nvm/versions/node/v16.14.2/bin/node` via terminal but via VSCode - `/Applications/Visual Studio Code - Insiders.app/Contents/Frameworks/Code - Insiders Helper.app/Contents/MacOS/Code - Insiders Helper`
And when I replaced `process.execPath` with `/Users/dimitri/.nvm/versions/node/v16.14.2/bin/node` (for debugging), I got errors in my VSCode also
<img width="764" alt="image" src="https://user-images.githubusercontent.com/7361780/174688705-fbee99a8-adfa-4601-9ab3-1050ce7213cc.png">
In my repo I actually have a mix between a remote schema and client-only schema, so the linter setup in the example doesn't really make sense, I agree!
And I also didn't really check if the eslint
command works in the MRE, which I should have. In my main repo, invoking ESLint with the CLI works just fine.
There seems to be some activity about this issue @ https://github.com/larsgw/sync-fetch/issues/23.
to fix the incorrect process.execPath
, add .vscode/settings.json
file with the following content (node path you can get by which node
in terminal)
{
"eslint.runtime": "/Users/dmytro/.nvm/versions/node/v18.16.1/bin/node"
}
that I described in https://github.com/B2o5T/graphql-eslint/issues/1721#issuecomment-1616574376
Issue workflow progress
Progress of the issue based on the Contributor Workflow
Describe the bug
Rules that try to access the schema via url-loader are broken when invoked by the VSCode eslint extension.
It seems like this line in sync-fetch expects to be called by Node.js, but in my case it's the VSCode executable when invoked by the VSCode eslint extension (dbaeumer.vscode-eslint).
To Reproduce Steps to reproduce the behavior:
This is my settings.json (I have fixAll onSave enabled):
The section from my .eslintrc.json
Expected behavior
I would expect it to work with the VSCode extension.
Environment:
@graphql-eslint/eslint-plugin
: ^3.10.4Additional context
If I invoke it with
eslint .
in the command line it works without any issues.