Skip to content

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

Open

Description

@izumin5210

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

Activity

  1. izumin5210 commented on Sep 14, 2021

    @izumin5210
    ContributorAuthor
  2. qnighy commented on Sep 14, 2021

    @qnighy
    Contributor

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

  3. prsdta commented on Sep 14, 2021

    @prsdta
    Contributor

    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 🤔

  4. prsdta commented on Sep 14, 2021

    @prsdta
    Contributor

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions