dimaMachina / graphql-eslint

ESLint parser, plugin and set rules for GraphQL (for schema and operations). Easily customizable with custom rules. Integrates with IDEs and modern GraphQL tools.
https://the-guild.dev/graphql/eslint
MIT License
798 stars 104 forks source link

TypeError: [graphql-eslint] Error while preprocessing "packages/front-lib/schema/schema.graphql" file #1932

Open charleslai2000 opened 1 year ago

charleslai2000 commented 1 year ago

Issue workflow progress

Progress of the issue based on the Contributor Workflow


Describe the bug

Eslint report this error in a functional graphql-config configuraiton.


TypeError: [graphql-eslint] Error while preprocessing "packages/front-lib/schema/schema.graphql" file

Provided file type must be one of .js, .mjs, .cjs, .jsx, .ts, .mts, .cts, .tsx, .flow, .flow.js, .flow.jsx, .vue, .svelte 
    at extractExtension (file:///home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/@graphql-tools+graphql-tag-pluck@7.5.2_@babel+core@7.23.0_graphql@16.8.1/node_modules/@graphql-tools/graphql-tag-pluck/esm/index.js:98:19)
    at gqlPluckFromCodeStringSync (file:///home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/@graphql-tools+graphql-tag-pluck@7.5.2_@babel+core@7.23.0_graphql@16.8.1/node_modules/@graphql-tools/graphql-tag-pluck/esm/index.js:70:21)
    at preprocess (file:///home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/@graphql-eslint+eslint-plugin@3.20.1_@babel+core@7.23.0_@types+node@20.7.1_graphql@16.8.1/node_modules/@graphql-eslint/eslint-plugin/esm/processor.js:42:23)
    at Linter._verifyWithFlatConfigArrayAndProcessor (/home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/eslint@8.50.0/node_modules/eslint/lib/linter/linter.js:1494:22)
    at Linter._verifyWithFlatConfigArray (/home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/eslint@8.50.0/node_modules/eslint/lib/linter/linter.js:1863:25)
    at Linter.verify (/home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/eslint@8.50.0/node_modules/eslint/lib/linter/linter.js:1448:65)
    at Linter.verifyAndFix (/home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/eslint@8.50.0/node_modules/eslint/lib/linter/linter.js:2083:29)
    at verifyText (/home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/eslint@8.50.0/node_modules/eslint/lib/eslint/flat-eslint.js:475:48)
    at FlatESLint.lintText (/home/charles/Workspaces/fx-front-dev/node_modules/.pnpm/eslint@8.50.0/node_modules/eslint/lib/eslint/flat-eslint.js:954:26)
    at async /home/charles/.vscode-server/extensions/dbaeumer.vscode-eslint-2.4.2/server/out/eslintServer.js:1:24852

To Reproduce Steps to reproduce the behavior:

my configuration file like:

      "schemaPath": [
        "packages/data-api/schema/universe.schema.graphql",
        "packages/data-api/schema/platform.schema.graphql"
      ],
      "includes": [
        "packages/front-lib/src/**/*.{ts,tsx,js,jsx}",
        "packages/front-lib/schema/*.graphql"
      ],

When lint packages/front-lib/schema/schema.grapql, the error will be reported. But I have another project config, like:

 "schemaPath": [
        "packages/data-api/schema/universe.schema.graphql"
      ],
      "includes": [
        "packages/data-api/src/**/*.{ts,tsx,js,jsx}",
        "packages/data-api/schema/*.graphql"
      ],

when I edit and save all graphql file in packages/data-api/schema/ directory, there is no error reported. This is weird.

Expected behavior

Treat this file as graphql and lint it.

Environment:

Additional context

charleslai2000 commented 1 year ago

I found some hint, can not include *.graphql in graphql-config's includes entry. But this is not consistency with document provided by graphql-config.