frolint icon indicating copy to clipboard operation
frolint copied to clipboard

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

Open izumin5210 opened this issue 4 years ago • 4 comments

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 avatar Aug 10 '21 14:08 izumin5210

cc @prsdta @tkeiyama

izumin5210 avatar Sep 14 '21 02:09 izumin5210

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

qnighy avatar Sep 14 '21 04:09 qnighy

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 avatar Sep 14 '21 05:09 prsdta

@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.

prsdta avatar Sep 14 '21 07:09 prsdta