upleveled / eslint-config-upleveled

UpLeveled ESLint defaults for programming in JavaScript, TypeScript, React, Next.js, Node.js, Postgres.js
https://www.npmjs.com/package/eslint-config-upleveled
42 stars 12 forks source link

Switch import assertions (`assert`) to import attributes (`with`) #423

Closed karlhorky closed 2 months ago

karlhorky commented 2 months ago

Linting on Node.js v22.8.0 led to the following ERR_IMPORT_ATTRIBUTE_MISSING error:

TypeError [ERR_IMPORT_ATTRIBUTE_MISSING]: Module "file:///home/runner/work/preflight/preflight/package.json" needs an import attribute of "type: json"
    at validateAttributes (node:internal/modules/esm/assert:88:15)
    at defaultLoad (node:internal/modules/esm/load:133:3)
    at async ModuleLoader.load (node:internal/modules/esm/loader:567:7)
    at async ModuleLoader.moduleProvider (node:internal/modules/esm/loader:442:45)
    at async ModuleJob._link (node:internal/modules/esm/module_job:106:19)
 ELIFECYCLE  Command failed with exit code 2.

I needed to switch from the assert keyword to the with keyword in the dynamic import, because the "import assertions" proposal (using the assert keyword) changed to the "import attributes" proposal (using the with keyword).

The old "import assertions" proposal has been renamed to "import attributes" with the following major changes:

  1. The keyword is now with instead of assert.
  2. Unknown assertions cause an error rather than being ignored.
codesandbox-ci[bot] commented 2 months ago

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.