From c0f1b077c8c7b8ee872bcee191f1acf5a8d5f62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Cort=C3=A9s?= Date: Thu, 17 Oct 2024 21:51:54 -0300 Subject: [PATCH] Stop using experimental syntax to load package version (#2616) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: stop using experimental syntax to load package version The import attribute syntax (`with { type: "json" }`) is still experimental so warnings showed up when using the library as it was being used to import the package.json file to extract the package version As an alternative, the current version will be injected on build time through tsup configuration. * Create healthy-moose-kneel.md * fix: failing test on node v22 after warning format change The test was failing because the line number in one of the warnings being suppressed changed from 5 characters to 7 on node v22. The other rule suppression was removed as a previous commit fixed the undelying issue. --------- Co-authored-by: Felipe Cortés Co-authored-by: Dimitri POSTOLOV --- .changeset/healthy-moose-kneel.md | 7 +++++++ packages/plugin/__tests__/examples.spec.ts | 8 ++------ packages/plugin/src/meta.ts | 4 +--- packages/plugin/tsup.config.ts | 1 + 4 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 .changeset/healthy-moose-kneel.md diff --git a/.changeset/healthy-moose-kneel.md b/.changeset/healthy-moose-kneel.md new file mode 100644 index 00000000000..125fd52c0f7 --- /dev/null +++ b/.changeset/healthy-moose-kneel.md @@ -0,0 +1,7 @@ +--- +"@graphql-eslint/eslint-plugin": patch +--- + +The import attribute syntax (with { type: "json" }) is still experimental so warnings showed up when using the library as it was being used to import the package.json file to extract the package version + +As an alternative, the current version will be injected on build time through tsup configuration. diff --git a/packages/plugin/__tests__/examples.spec.ts b/packages/plugin/__tests__/examples.spec.ts index f6990885db2..fa7ca770d59 100644 --- a/packages/plugin/__tests__/examples.spec.ts +++ b/packages/plugin/__tests__/examples.spec.ts @@ -22,14 +22,10 @@ function getESLintOutput(cwd: string): ESLint.LintResult[] { const errorOutput = stderr .toString() .replace( - /\(node:\d{4,5}\) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time/, + /\(node:\d{4,7}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./, '', ) - .replace( - /\(node:\d{4,5}\) \[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead./, - '', - ) - .replace('(Use `node --trace-warnings ...` to show where the warning was created)', '') + .replace('(Use `node --trace-deprecation ...` to show where the warning was created)', '') .trimEnd(); if (errorOutput) { throw new Error(errorOutput); diff --git a/packages/plugin/src/meta.ts b/packages/plugin/src/meta.ts index 50aebe6bca1..39a9cca11b7 100644 --- a/packages/plugin/src/meta.ts +++ b/packages/plugin/src/meta.ts @@ -1,3 +1 @@ -import packageJson from '../package.json' with { type: 'json' }; - -export const { version } = packageJson; +export const version = process.env.VERSION diff --git a/packages/plugin/tsup.config.ts b/packages/plugin/tsup.config.ts index d8c8e06479d..ec995dba8c6 100644 --- a/packages/plugin/tsup.config.ts +++ b/packages/plugin/tsup.config.ts @@ -10,6 +10,7 @@ const opts: Options = { dts: true, env: { ...(process.env.NODE_ENV && { NODE_ENV: process.env.NODE_ENV }), + VERSION: packageJson.version, }, format: 'esm', minifySyntax: true,