-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Support "Flat Config" (ESLint 9) #2178
Comments
While this plugin mentions it has support for Flat Config, it does work OK, until you run
|
Is there any update on this? Even I am getting the same error as the above |
I'm also trying to setup the GraphQL eslint but noticing some issues as well... From the examples repo I e.g. tried:
but that gives:
although and when I try instead:
but that gives:
Note my
|
if you set parser as the following, it seems to work as a workaround:
|
I also can't get this working, despite claimed flat config support. Any attempt by me to set
I also couldn't find any examples or documentation on |
For those interested here is an example of a config that ended up working for our project. We are only using schema linting at the moment, so no idea how well this works for query linting. // eslint.config.mjs
import { fixupPluginRules } from "@eslint/compat"
import * as graphqlEslint from "@graphql-eslint/eslint-plugin"
export default [
// other configs here
{
files: ["**/*.gqls"],
languageOptions: {
ecmaVersion: 5,
sourceType: "script",
parser: { ...graphqlEslint, meta: { name: "@graphql-eslint" } },
parserOptions: { schema: "./path/to/schema/**/*.gqls" },
},
plugins: { "@graphql-eslint": fixupPluginRules(graphqlEslint) },
rules: {
...graphqlEslint.flatConfigs["schema-recommended"].rules,
// other rule overrides here
},
},
] |
And ESLint's use examples https://github.com/dimaMachina/graphql-eslint/tree/master/examples as reference v4 will be released once I polish documentation to include new changes |
I couldn't find an example of using a set of rules from this plugin, so in case anyone is looking too: it goes in the (HOWEVER, note that I wasn't able to get this working. When I add graphql-eslint, eslint seems to get stuck in an infinite loop or something. Or at least, it goes from taking <10s to over a couple minutes. Something like:
|
@dimaMachina I notice this was re-opened. Is there still more work to do on this? Happy to help. |
@dimaMachina I dug in a bit more. I got past the compiler-sfc issue using the latest alpha (not sure if I didn't have that installed before?). However, I'm now seeing a bug with the alpha: it's not correctly loading my graphql-config, so it throws e.g. no-deprecated requires a schema. Specifically, this line seems to pass in the current file's path as the root of the project; graphql-config seems to therefore only look in the subdir the file is in, not the root. If I change the rootDir line to be my project's root dir, the config is correctly picked up. I could be wrong in my exact diagnosis here, but something's off for sure. Note that the graphql-config example in examples dir probably works because all files are in the root. ALSO, it wasn't apparent from the Vue instructions that it was critical for the GraphQL Vue parsing to happen before other Vue parsers. Without that, all my lint errors in Vue files turned into a message simply saying "clear." I'd call that out specifically, both in the instructions and in the example. |
@bmulholland I think the bug with graphql-config is related to this PR merge kamilkisiela/graphql-config#1480 ,can you try to pin graphql-config to this version ? And try if it helps? |
@dimaMachina Good guess! My above testing was on graphql-config 5.1.2. 5.1.0 works fine; 5.1.1 is the first broken version. This means:
And so we're back to your last statement :)
As I've just gone through this, I'm happy to share any parts of my setup process if it would help you with the docs. Let me know if there's a particular blind spot or question you might have. For starters, as I mentioned, including the importance of ordering -- probably in the form of recommending the graphql parsing of code files to go VERY FIRST in graphql.config.js -- would save others time. |
Amazing, would be awesome if you create a PR to point into this base branch https://github.com/dimaMachina/graphql-eslint/tree/more-new-docs with updates your Vue setup 🙏 here is the file to update
|
👋 Coming over from eslint/eslint#18093: ESLint is migrating to a new "flat config" format that will be the default in ESLint v9.
It doesn't look like
@graphql-eslint/eslint-plugin
has support yet. I'm posting this issue here as a reference & cross-linking it to the table in eslint/eslint#18093. If there's anything technical blocking the extension from supporting flat configs, please let us know - we'd be happy to try to help! 💜Additional resources:
The text was updated successfully, but these errors were encountered: