graphql-eslint: Getting ESLint errors about missing files
I’m trying to add this plugin to my project, I followed the standard configuration in the documentation:

But am getting the following error in VSCode’s ESLint output:
[Info - 9:40:12 AM] ESLint server is starting
[Info - 9:40:12 AM] ESLint server running in node v12.14.1
[Info - 9:40:12 AM] ESLint server is running.
[Info - 9:42:43 AM] ESLint library loaded from: /Users/peterp/x/redwoodjs/example-invoice/node_modules/eslint/lib/api.js
[Info - 9:42:56 AM] ENOTDIR: not a directory, stat '/Users/peterp/x/redwoodjs/example-invoice/web/src/index.js/0_/Users/peterp/x/redwoodjs/example-invoice/web/src/index.js' Occurred while linting /Users/peterp/x/redwoodjs/example-invoice/web/src/index.js/0_/Users/peterp/x/redwoodjs/example-invoice/web/src/index.js:1
[Info - 9:42:56 AM] ENOTDIR: not a directory, stat '/Users/peterp/x/redwoodjs/example-invoice/web/src/pages/InvoicePage/subcomponents/InvoiceCell/InvoiceCell.js/0_document.graphql' Occurred while linting /Users/peterp/x/redwoodjs/example-invoice/web/src/pages/InvoicePage/subcomponents/InvoiceCell/InvoiceCell.js/0_document.graphql:0
I’ve pushed up a branch here: https://github.com/redwoodjs/example-invoice/pull/39/files#diff-b9cfc7f2cdf78a7f4b91a753d10865a2
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 24 (7 by maintainers)
@therealgilles since the filename used for the generated chunks in this plugin always uses “document.graphql” (see https://github.com/dotansimha/graphql-eslint/blob/master/packages/plugin/src/processors/code-files.ts#L42), you can make a rule specific for these generated chunks without affecting your other “.graphql” files (assuming none of them are called “document.graphql”). I’ve done this in my eslint config which uses this parser to turn off the eol rule that was breaking for these generated chunks.
Here’s a snippet of what I have which seems to work:
I suspect if you adjusted your above config as follows it should work ok.
Fixed in https://github.com/dotansimha/graphql-eslint/pull/225 Thank you @peterp @ilyavolodin @EmrysMyrddin @lavigneer @jgoux @huw 😃
Available
@graphql-eslint/eslint-plugin@0.5.0.Ran into the same issue—interop with the Prettier plugin is really important to me so I’m keen to see this solved!
I was running into the same issue and did a little digging. Apparently eslint always forces a child sub-path to be used when a custom processor is defined. The prettier plugin tries to read the file with this sub-path but it doesn’t actually exist.
There’s an issue open to give rules the opportunity to fetch the real filename but it hasn’t been addressed: https://github.com/eslint/eslint/issues/11989
In https://github.com/eslint/eslint/issues/11989#issuecomment-511261819 you can see how it builds the path.
One workaround I tried with the processor defined in this repo was to force the resolved path from path.join to be the true filename for the full file block that’s returned:
This seems to work for my case but it feels pretty hacky. @dotansimha I’m not sure if this is something you’d want added? I can open a PR with the changes if you think it’s fine to go in here.
I should note, this still requires turning off the prettier/prettier rule for the extracted code blocks from these files, as was suggested in https://github.com/dotansimha/graphql-eslint/issues/88#issuecomment-706666698
On a side note, after doing all this I still had issues with the extracted code blocks failing on the “eol-last” rule in my config. This can be fixed by adding this to the overrides array:
UPDATE
I located the issue. It’s because the project has a root .eslintrc and several nested .eslintrc in various directories.
The override entry that disables the
eol-lastrule on*.graphqlfiles was being overridden by the nested configs.Moving the override into the nested config files solved the issue. Thanks @lavigneer
Original post:
@lavigneer unfortunately that didn’t work for me, I’m still seeing
eol-lasterrors even after many attempts to disable them, including disablingIt also does not disable when matching all
*.graphqlfilesI don’t understand what could be going wrong
If you are using plugins using file system, you should use
overridesto avoid using this plugins on.graphqland only on.jsfiles.Is this issue not fixed? I’m seeing
ENOTDIR: not a directoryerrors in the VS Code ESLint output, using@graphql-eslint/eslint-plugin@0.6.1-alpha-bbfee02.0:Not sure
eslint-plugin-htmlis working around the same problem here. It is complaining about the lack of access to eslint config from processor.Naming processed chunks with the original filename would work, however, there might be some issues with this if there are multiple chunks generated from a single file. That will mean that original file will be ran through prettier multiple times. The other option to deal with this would be to name processor chunks using some sort of convention and then modify prettier rule to look for that convention and instead of trying to resolve config/ignore based on the chunk name, restore original file name instead. I.e. for example, if original file was named
index.tsyou could change processor to name chunksindex|ts-chunk1.graphql, then prettier rule could be modified to restoreindex.tsfilename and run prettier config resolution and ignore checks based onindex.tsand not on thechunk.graphql.That solved it! Thanks!