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

@graphql-eslint/eslint-plugin does not work with frolint cli #926

Open
izumin5210 opened this issue Aug 10, 2021 · 4 comments
Open

@graphql-eslint/eslint-plugin does not work with frolint cli #926

izumin5210 opened this issue Aug 10, 2021 · 4 comments

Comments

@izumin5210
Copy link
Contributor

izumin5210 commented Aug 10, 2021

Why

In the following .eslintrc, use yarn eslint . /src will work, but yarn frolint -branch master -bail will raise an error.

.eslintrc
{
  "overrides": [
    {
      "files": [
        "*.tsx",
        "*.ts"
      ],
      "extends": "wantedly-typescript",
      "parserOptions": {
        "project": [
          "./tsconfig.json",
          "./tsconfig.eslint.json"
        ]
      }
    },
    {
      "files": [
        "*.tsx",
        "*.ts"
      ],
      "processor": "@graphql-eslint/graphql"
    },
    {
      "files": [
        "./src/profile/components/profile/Sidebar/RelatedUsers/**/*.graphql"
      ],
      "parser": "@graphql-eslint/eslint-plugin",
      "parserOptions": {
        "schema": "./graphql-gateway-schema.json"
      },
      "plugins": [
        "@graphql-eslint"
      ],
      "rules": {
        "@graphql-eslint/fields-on-correct-type": [
          "error"
        ]
      }
    }
  ]
}
Internal Error: Error while loading rule '@typescript-eslint/no-floating-promises': You have used a rule which requires parserServices to be generated. You must therefore provide a value for the "parserOptions.project" property for @typescript-eslint/parser.
Occurred while linting /path/to/project/src/path/to/Component.tsx/0_document.graphql

What

@izumin5210
Copy link
Contributor Author

cc @prsdta @tkeiyama

@qnighy
Copy link
Contributor

qnighy commented Sep 14, 2021

So we may need an option to turn off rules that require type-aware linting?

@prsdta
Copy link
Contributor

prsdta commented Sep 14, 2021

So we may need an option to turn off rules that require type-aware linting?

Indeed, just changing the rules to

      "rules": {
        "@graphql-eslint/fields-on-correct-type": ["error"],
        "@typescript-eslint/no-floating-promises": "off"
      }

seems to fix the error. But I would like something more future-proof that does not require to disable manually all rules 🤔

@prsdta
Copy link
Contributor

prsdta commented Sep 14, 2021

@graphql-eslint also seems to use typescript-eslint internally, so we shouldn't need to disable it all.
It seems to be more an issue with applying our default rules with the graphql-eslint parser.
See this comment in a related issue: https://github.com/dotansimha /graphql-eslint/issues/544#issuecomment-891948697

Nope, it's important that you don't have any rules configured at top level config, and to move all configurations into overrides section. Since JavaScript rules can't run on GraphQL files and vice versa, if you have rules configured at the top level, they will try to also execute for all overrides, as ESLint's configs cascade.

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

No branches or pull requests

3 participants