Skip to content

v3.14.1 -> v3.14.2 causes type error about file type in CLI output #1348

@jaydenseric

Description

@jaydenseric

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

    Please make sure the graphql-eslint version under package.json matches yours.

  • 2. A failing test has been provided
  • 3. A local solution has been provided
  • 4. A pull request is pending review

Describe the bug

Updating @graphql-eslint/eslint-plugin from v3.14.1 to v3.14.2 in a real project causes a TypeError to be emitted (several times) in the ESLint CLI output:

TypeError: Provided file type must be one of .js, .jsx, .ts, .tsx, .flow, .flow.js, .flow.jsx, .vue, .svelte 
    at extractExtension (/[redacted]/node_modules/@graphql-tools/graphql-tag-pluck/cjs/index.js:91:19)
    at gqlPluckFromCodeStringSync (/[redacted]/node_modules/@graphql-tools/graphql-tag-pluck/cjs/index.js:61:21)
    at preprocess (/[redacted]/node_modules/@graphql-eslint/eslint-plugin/cjs/processor.js:35:80)
    at Linter._verifyWithProcessor (/[redacted]/node_modules/eslint/lib/linter/linter.js:1848:22)
    at Linter._verifyWithConfigArray (/[redacted]/node_modules/eslint/lib/linter/linter.js:1762:25)
    at Linter.verify (/[redacted]/node_modules/eslint/lib/linter/linter.js:1476:65)
    at Linter.verifyAndFix (/[redacted]/node_modules/eslint/lib/linter/linter.js:2028:29)
    at verifyText (/[redacted]/node_modules/eslint/lib/cli-engine/cli-engine.js:245:48)
    at CLIEngine.executeOnFiles (/[redacted]/node_modules/eslint/lib/cli-engine/cli-engine.js:823:28)
    at ESLint.lintFiles (/[redacted]/node_modules/eslint/lib/eslint/eslint.js:551:23)

This error message raises alarm bells:

Provided file type must be one of .js, .jsx, .ts, .tsx, .flow, .flow.js, .flow.jsx, .vue, .svelte

That list doesn't include these file extensions that are standard for Node.js and TypeScript:

  • .mjs
  • .mts
  • .cjs
  • .cts

My project has some .mjs and .cjs files. When I change the package ESLint script from eslint . to target specific files with these extensions, the .cjs one results in the error (eslint .eslintrc.cjs) but a .mjs one strangely does not (eslint next.config.mjs).

To Reproduce Steps to reproduce the behavior:

It seems, try to lint a .cjs file.

Expected behavior

There is no linter error.

Environment:

  • OS: macOS
  • @graphql-eslint/eslint-plugin: v3.14.2
  • Node.js: v19.3.0

Additional context

Here is where the error is thrown from:

https://github.com/ardatan/graphql-tools/blob/cd0994d8e354fae8ed19f0cc564904711a5d4237/packages/graphql-tag-pluck/src/index.ts#L216

Metadata

Metadata

Assignees

No one assigned

    Labels

    dependenciesPull requests that update a dependency filehelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions