Skip to content

Exported meta object uses experimental node feature which logs a warning everytime the libary is imported #2614

@fcortes

Description

@fcortes

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

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

    For example, you can start off by editng the
    'basic' example on Stackblitz.

    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

I was trying to use the v4.0.0-alpha.5 version for a project where I'm migrating a .eslintrc.js file to the new flat config format and I started getting the following warning when running eslint

$ yarn lint
(node:25625) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
    at emitExperimentalWarning (node:internal/util:268:11)
    at ModuleLoader.jsonStrategy (node:internal/modules/esm/translators:420:3)
    at callTranslator (node:internal/modules/esm/loader:439:14)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:445:30)

After looking around I found this PR where the meta.js file is added which includes the following statement

import packageJson from '../package.json' assert { type: 'json' };

This seems to use an experimental feature of node that seems stable enough but I don't think the current use justifies trying to bypass the warning.

To Reproduce Steps to reproduce the behavior:

FROM node:22

RUN npm init es6 && yarn add \
  "[email protected]" \
  "@graphql-eslint/[email protected]" \
  "[email protected]"

RUN cat <<'EOF' > eslint.config.js
import * as graphql from "@graphql-eslint/eslint-plugin"
export default [
  {
    files: ['*.graphql'],
    languageOptions: { parser: graphql.parser },
    plugins: { "@graphql-eslint": { rules: graphql.rules } },
    rules: { ...graphql.configs['flat/operations-recommended'].rules }
  },
]
EOF

RUN cat <<'EOF' > queries.graphql
query ShouldCelebrateFirstTransaction {
  shouldCelebrateFirstTransaction
}
EOF

CMD ["yarn", "run", "eslint", "queries.graphql"]
docker run --rm -it $(docker build -q .)
image

Expected behavior

No warnings when the library is used

Environment:

  • OS: macOS
  • @graphql-eslint/eslint-plugin: "4.0.0-alpha.5",
  • Node.js: 22.5.1

Additional context

Nothing relevant

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