From 6c224203723e901db7518c35f679409a9f9a76af Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sat, 29 Nov 2025 15:10:12 +0100 Subject: [PATCH] tools: enforce trailing commas in `test/es-module` --- ...t-disable-require-module-with-detection.js | 2 +- .../test-dynamic-import-script-lifetime.js | 2 +- test/es-module/test-esm-cjs-named-error.mjs | 12 +++++------ test/es-module/test-esm-data-urls.js | 2 +- test/es-module/test-esm-dns-promises.mjs | 2 +- test/es-module/test-esm-dynamic-import.js | 2 +- test/es-module/test-esm-import-meta.mjs | 2 +- .../test-esm-loader-invalid-format.mjs | 2 +- test/es-module/test-esm-loader-mock.mjs | 16 +++++++-------- test/es-module/test-esm-loader-modulemap.js | 6 +++--- test/es-module/test-esm-loader-search.js | 4 ++-- test/es-module/test-esm-resolve-type.mjs | 16 +++++++-------- test/es-module/test-esm-symlink-type.js | 12 +++++------ .../es-module/test-esm-type-field-errors-2.js | 2 +- ...test-esm-wasm-module-instances-warning.mjs | 2 +- ...m-wasm-source-phase-not-defined-static.mjs | 2 +- .../test-esm-wasm-top-level-execution.mjs | 2 +- .../test-import-require-tla-twice.js | 2 +- .../test-loaders-hidden-from-users.js | 4 ++-- .../test-loaders-unknown-builtin-module.mjs | 2 +- .../es-module/test-require-as-esm-interop.mjs | 2 +- .../test-require-esm-from-imported-cjs.js | 4 ++-- ...test-require-module-conditional-exports.js | 2 +- ...st-require-module-cycle-esm-esm-cjs-esm.js | 2 +- .../test-require-module-dont-detect-cjs.js | 2 +- .../test-require-module-error-catching.js | 4 ++-- .../es-module/test-require-module-implicit.js | 2 +- test/es-module/test-require-module-preload.js | 10 +++++----- ...est-require-module-retry-import-errored.js | 2 +- ...-require-module-retry-import-evaluating.js | 2 +- .../test-require-module-tla-execution.js | 2 +- ...test-require-module-tla-print-execution.js | 2 +- .../test-require-module-tla-retry-import-2.js | 2 +- .../test-require-module-tla-retry-import.js | 2 +- .../test-require-module-tla-retry-require.js | 4 ++-- test/es-module/test-require-module-warning.js | 4 ++-- test/es-module/test-require-module.js | 2 +- .../test-vm-main-context-default-loader.js | 8 ++++---- test/es-module/test-wasm-web-api.js | 20 +++++++++---------- test/eslint.config_partial.mjs | 18 ++++++++++++++++- 40 files changed, 104 insertions(+), 88 deletions(-) diff --git a/test/es-module/test-disable-require-module-with-detection.js b/test/es-module/test-disable-require-module-with-detection.js index 3ac5ec82171587..7823dd03121118 100644 --- a/test/es-module/test-disable-require-module-with-detection.js +++ b/test/es-module/test-disable-require-module-with-detection.js @@ -15,5 +15,5 @@ assert.throws( () => require('../fixtures/es-modules/loose.js'), { name: 'SyntaxError', - message: /Unexpected token 'export'/ + message: /Unexpected token 'export'/, }); diff --git a/test/es-module/test-dynamic-import-script-lifetime.js b/test/es-module/test-dynamic-import-script-lifetime.js index 7ccea887109e05..fc0e35d29f649c 100644 --- a/test/es-module/test-dynamic-import-script-lifetime.js +++ b/test/es-module/test-dynamic-import-script-lifetime.js @@ -28,5 +28,5 @@ vm.runInThisContext(code, { await m.link(() => {}); await m.evaluate(); return m; - } + }, }); diff --git a/test/es-module/test-esm-cjs-named-error.mjs b/test/es-module/test-esm-cjs-named-error.mjs index 6ece31ed3adc8a..98dedbf065f321 100644 --- a/test/es-module/test-esm-cjs-named-error.mjs +++ b/test/es-module/test-esm-cjs-named-error.mjs @@ -27,21 +27,21 @@ await assert.rejects(async () => { await import(`${fixtureBase}/single-quote.mjs`); }, { name: 'SyntaxError', - message: expectedRelative + message: expectedRelative, }, 'should support relative specifiers with single quotes'); await assert.rejects(async () => { await import(`${fixtureBase}/double-quote.mjs`); }, { name: 'SyntaxError', - message: expectedRelative + message: expectedRelative, }, 'should support relative specifiers with double quotes'); await assert.rejects(async () => { await import(`${fixtureBase}/renamed-import.mjs`); }, { name: 'SyntaxError', - message: expectedRenamed + message: expectedRenamed, }, 'should correctly format named imports with renames'); await assert.rejects(async () => { @@ -55,21 +55,21 @@ await assert.rejects(async () => { await import(`${fixtureBase}/json-hack.mjs`); }, { name: 'SyntaxError', - message: expectedPackageHack + message: expectedPackageHack, }, 'should respect recursive package.json for module type'); await assert.rejects(async () => { await import(`${fixtureBase}/bare-import-single.mjs`); }, { name: 'SyntaxError', - message: expectedBare + message: expectedBare, }, 'should support bare specifiers with single quotes'); await assert.rejects(async () => { await import(`${fixtureBase}/bare-import-double.mjs`); }, { name: 'SyntaxError', - message: expectedBare + message: expectedBare, }, 'should support bare specifiers with double quotes'); await assert.rejects(async () => { diff --git a/test/es-module/test-esm-data-urls.js b/test/es-module/test-esm-data-urls.js index 21f4e94930b1cc..ddf4a3655da97e 100644 --- a/test/es-module/test-esm-data-urls.js +++ b/test/es-module/test-esm-data-urls.js @@ -76,7 +76,7 @@ function createBase64URL(mime, body) { import('data:application/json;foo="test,",0', { with: { type: 'json' } }), { name: 'SyntaxError', - message: /Unterminated string in JSON at position 3/ + message: /Unterminated string in JSON at position 3/, }); } { diff --git a/test/es-module/test-esm-dns-promises.mjs b/test/es-module/test-esm-dns-promises.mjs index 149682db02d042..1256bb75a2b83c 100644 --- a/test/es-module/test-esm-dns-promises.mjs +++ b/test/es-module/test-esm-dns-promises.mjs @@ -10,5 +10,5 @@ assert.throws(() => { }, { code: 'ERR_INVALID_ARG_VALUE', name: 'TypeError', - message: `The argument 'address' is invalid. Received '${invalidAddress}'` + message: `The argument 'address' is invalid. Received '${invalidAddress}'`, }); diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 47995d50d9cd7a..4cf7b769a00cfa 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -19,7 +19,7 @@ function expectOkNamespace(result) { .then(common.mustCall((ns) => { const expected = { default: true }; Object.defineProperty(expected, Symbol.toStringTag, { - value: 'Module' + value: 'Module', }); Object.setPrototypeOf(expected, Object.getPrototypeOf(ns)); assert.deepStrictEqual(ns, expected); diff --git a/test/es-module/test-esm-import-meta.mjs b/test/es-module/test-esm-import-meta.mjs index a2575c4d108cc1..638989724bbfd4 100644 --- a/test/es-module/test-esm-import-meta.mjs +++ b/test/es-module/test-esm-import-meta.mjs @@ -12,7 +12,7 @@ for (const descriptor of Object.values(descriptors)) { assert.deepStrictEqual(descriptor, { enumerable: true, writable: true, - configurable: true + configurable: true, }); } diff --git a/test/es-module/test-esm-loader-invalid-format.mjs b/test/es-module/test-esm-loader-invalid-format.mjs index 64237f7af243af..5a16381e58897f 100644 --- a/test/es-module/test-esm-loader-invalid-format.mjs +++ b/test/es-module/test-esm-loader-invalid-format.mjs @@ -5,6 +5,6 @@ import assert from 'assert'; import('../fixtures/es-modules/test-esm-ok.mjs') .then(assert.fail, expectsError({ code: 'ERR_UNKNOWN_MODULE_FORMAT', - message: /Unknown module format: esm/ + message: /Unknown module format: esm/, })) .then(mustCall()); diff --git a/test/es-module/test-esm-loader-mock.mjs b/test/es-module/test-esm-loader-mock.mjs index 164d0ac3775039..cdf56d85415b74 100644 --- a/test/es-module/test-esm-loader-mock.mjs +++ b/test/es-module/test-esm-loader-mock.mjs @@ -3,21 +3,21 @@ import assert from 'node:assert/strict'; import { mock } from '../fixtures/es-module-loaders/mock.mjs'; mock('node:events', { - EventEmitter: 'This is mocked!' + EventEmitter: 'This is mocked!', }); // This resolves to node:events // It is intercepted by mock-loader and doesn't return the normal value assert.deepStrictEqual(await import('events'), Object.defineProperty({ __proto__: null, - EventEmitter: 'This is mocked!' + EventEmitter: 'This is mocked!', }, Symbol.toStringTag, { enumerable: false, - value: 'Module' + value: 'Module', })); const mutator = mock('node:events', { - EventEmitter: 'This is mocked v2!' + EventEmitter: 'This is mocked v2!', }); // It is intercepted by mock-loader and doesn't return the normal value. @@ -26,17 +26,17 @@ const mutator = mock('node:events', { const mockedV2 = await import('node:events'); assert.deepStrictEqual(mockedV2, Object.defineProperty({ __proto__: null, - EventEmitter: 'This is mocked v2!' + EventEmitter: 'This is mocked v2!', }, Symbol.toStringTag, { enumerable: false, - value: 'Module' + value: 'Module', })); mutator.EventEmitter = 'This is mocked v3!'; assert.deepStrictEqual(mockedV2, Object.defineProperty({ __proto__: null, - EventEmitter: 'This is mocked v3!' + EventEmitter: 'This is mocked v3!', }, Symbol.toStringTag, { enumerable: false, - value: 'Module' + value: 'Module', })); diff --git a/test/es-module/test-esm-loader-modulemap.js b/test/es-module/test-esm-loader-modulemap.js index c725f093fa3bda..ba0358368ec167 100644 --- a/test/es-module/test-esm-loader-modulemap.js +++ b/test/es-module/test-esm-loader-modulemap.js @@ -55,7 +55,7 @@ const jsonModuleJob = new ModuleJob(loader, jsonModuleDataUrl, const errorObj = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: /^The "url" argument must be of type string/ + message: /^The "url" argument must be of type string/, }; [{}, [], true, 1].forEach((value) => { @@ -73,7 +73,7 @@ const jsonModuleJob = new ModuleJob(loader, jsonModuleDataUrl, const errorObj = { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: /^The "type" argument must be of type string/ + message: /^The "type" argument must be of type string/, }; [{}, [], true, 1].forEach((value) => { @@ -91,7 +91,7 @@ const jsonModuleJob = new ModuleJob(loader, jsonModuleDataUrl, assert.throws(() => moduleMap.set('', undefined, value), { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError', - message: /^The "job" argument must be an instance of ModuleJob/ + message: /^The "job" argument must be an instance of ModuleJob/, }); }); } diff --git a/test/es-module/test-esm-loader-search.js b/test/es-module/test-esm-loader-search.js index 3c451409b356db..5f25edadb7cbb1 100644 --- a/test/es-module/test-esm-loader-search.js +++ b/test/es-module/test-esm-loader-search.js @@ -7,7 +7,7 @@ require('../common'); const assert = require('assert'); const { - defaultResolve: resolve + defaultResolve: resolve, } = require('internal/modules/esm/resolve'); assert.throws( @@ -15,6 +15,6 @@ assert.throws( { code: 'ERR_MODULE_NOT_FOUND', name: 'Error', - message: /Cannot find package 'target'/ + message: /Cannot find package 'target'/, } ); diff --git a/test/es-module/test-esm-resolve-type.mjs b/test/es-module/test-esm-resolve-type.mjs index fbd75d98a8da8e..f6e519f320cd6d 100644 --- a/test/es-module/test-esm-resolve-type.mjs +++ b/test/es-module/test-esm-resolve-type.mjs @@ -25,7 +25,7 @@ if (!isMainThread) { import assert from 'assert'; import internalResolve from 'node:internal/modules/esm/resolve'; const { - defaultResolve: resolve + defaultResolve: resolve, } = internalResolve; const rel = (file) => tmpdir.resolve(file); @@ -82,7 +82,7 @@ try { createDir(subDir); const pkgJsonContent = { ...(moduleType !== undefined) && { type: moduleType }, - main: `subdir/mainfile.${moduleExtension}` + main: `subdir/mainfile.${moduleExtension}`, }; fs.writeFileSync(pkg, JSON.stringify(pkgJsonContent)); fs.writeFileSync(script, @@ -150,13 +150,13 @@ try { '.': { 'require': './lib/index.js', 'import': './es/index.js', - 'default': './lib/index.js' + 'default': './lib/index.js', }, './package.json': './package.json', - } + }, }; const esmPkgJsonContent = { - type: 'module' + type: 'module', }; fs.writeFileSync(pkg, JSON.stringify(mainPkgJsonContent)); @@ -220,13 +220,13 @@ try { '.': { 'require': `./subdir/${mainRequireScript}${mainSuffix}`, 'import': `./subdir/${mainImportScript}${mainSuffix}`, - 'default': `./subdir/${mainRequireScript}${mainSuffix}` + 'default': `./subdir/${mainRequireScript}${mainSuffix}`, }, './package.json': './package.json', - } + }, }; const subdirPkgJsonContent = { - type: `${subdirPackageType}` + type: `${subdirPackageType}`, }; fs.writeFileSync(pkg, JSON.stringify(mainPkgJsonContent)); diff --git a/test/es-module/test-esm-symlink-type.js b/test/es-module/test-esm-symlink-type.js index 2537881f46c0e2..76f03d4f46d457 100644 --- a/test/es-module/test-esm-symlink-type.js +++ b/test/es-module/test-esm-symlink-type.js @@ -16,12 +16,12 @@ const symlinks = [ source: 'extensionless-symlink-to-mjs-file', target: fixtures.path('es-modules/mjs-file.mjs'), prints: '.mjs file', - errorsWithPreserveSymlinksMain: false + errorsWithPreserveSymlinksMain: false, }, { source: 'extensionless-symlink-to-cjs-file', target: fixtures.path('es-modules/cjs-file.cjs'), prints: '.cjs file', - errorsWithPreserveSymlinksMain: false + errorsWithPreserveSymlinksMain: false, }, { source: 'extensionless-symlink-to-file-in-module-scope', target: fixtures.path('es-modules/package-type-module/index.js'), @@ -29,17 +29,17 @@ const symlinks = [ // The package scope of the symlinks' sources is commonjs, and this // symlink's target is a .js file in a module scope, so when the scope // is evaluated based on the source (commonjs) this esm file should error - errorsWithPreserveSymlinksMain: true + errorsWithPreserveSymlinksMain: true, }, { source: 'extensionless-symlink-to-file-in-explicit-commonjs-scope', target: fixtures.path('es-modules/package-type-commonjs/index.js'), prints: 'package-type-commonjs', - errorsWithPreserveSymlinksMain: false + errorsWithPreserveSymlinksMain: false, }, { source: 'extensionless-symlink-to-file-in-implicit-commonjs-scope', target: fixtures.path('es-modules/package-without-type/index.js'), prints: 'package-without-type', - errorsWithPreserveSymlinksMain: false + errorsWithPreserveSymlinksMain: false, }, ]; @@ -53,7 +53,7 @@ symlinks.forEach((symlink) => { ]; flags.forEach((nodeOptions) => { const opts = { - env: Object.assign({}, process.env, { NODE_OPTIONS: nodeOptions }) + env: Object.assign({}, process.env, { NODE_OPTIONS: nodeOptions }), }; exec(process.execPath, [mainPath], opts, common.mustCall( (err, stdout) => { diff --git a/test/es-module/test-esm-type-field-errors-2.js b/test/es-module/test-esm-type-field-errors-2.js index 3ea259446c7fb2..73f581badb9159 100644 --- a/test/es-module/test-esm-type-field-errors-2.js +++ b/test/es-module/test-esm-type-field-errors-2.js @@ -11,7 +11,7 @@ const { describe, it } = require('node:test'); describe('Errors related to ESM type field', () => { it('Should throw an error when loading CJS from a `type: "module"` package.', () => { assert.throws(() => require('../fixtures/es-modules/package-type-module/index.js'), { - code: 'ERR_REQUIRE_ESM' + code: 'ERR_REQUIRE_ESM', }); }); }); diff --git a/test/es-module/test-esm-wasm-module-instances-warning.mjs b/test/es-module/test-esm-wasm-module-instances-warning.mjs index e8ca55258131d6..e2cc5a73121abd 100644 --- a/test/es-module/test-esm-wasm-module-instances-warning.mjs +++ b/test/es-module/test-esm-wasm-module-instances-warning.mjs @@ -12,6 +12,6 @@ spawnSyncAndAssert( stderr(output) { assert.match(output, /ExperimentalWarning/); assert.match(output, /Importing WebAssembly module instances/); - } + }, } ); diff --git a/test/es-module/test-esm-wasm-source-phase-not-defined-static.mjs b/test/es-module/test-esm-wasm-source-phase-not-defined-static.mjs index a53ea04194f149..73c519a37f68cb 100644 --- a/test/es-module/test-esm-wasm-source-phase-not-defined-static.mjs +++ b/test/es-module/test-esm-wasm-source-phase-not-defined-static.mjs @@ -14,6 +14,6 @@ spawnSyncAndAssert( stderr(output) { assert.match(output, /Source phase import object is not defined for module/); assert(output.includes(fileUrl)); - } + }, } ); diff --git a/test/es-module/test-esm-wasm-top-level-execution.mjs b/test/es-module/test-esm-wasm-top-level-execution.mjs index 99ce94e00c5350..cc52ec3e908cff 100644 --- a/test/es-module/test-esm-wasm-top-level-execution.mjs +++ b/test/es-module/test-esm-wasm-top-level-execution.mjs @@ -9,6 +9,6 @@ spawnSyncAndAssert( { stdout: '[Object: null prototype] { prop: \'hello world\' }', stderr: '', - trim: true + trim: true, } ); diff --git a/test/es-module/test-import-require-tla-twice.js b/test/es-module/test-import-require-tla-twice.js index a7cb32a983e3c1..7dc8e2d6448b26 100644 --- a/test/es-module/test-import-require-tla-twice.js +++ b/test/es-module/test-import-require-tla-twice.js @@ -16,6 +16,6 @@ spawnSyncAndAssert( stdout(output) { const matches = output.matchAll(/e\.code === ERR_REQUIRE_ASYNC_MODULE true/g); assert.strictEqual([...matches].length, 2); - } + }, } ); diff --git a/test/es-module/test-loaders-hidden-from-users.js b/test/es-module/test-loaders-hidden-from-users.js index e1b5518e90cbfe..53f48da6e2381f 100644 --- a/test/es-module/test-loaders-hidden-from-users.js +++ b/test/es-module/test-loaders-hidden-from-users.js @@ -10,7 +10,7 @@ assert.throws( require('internal/bootstrap/realm'); }, { code: 'MODULE_NOT_FOUND', - message: /Cannot find module 'internal\/bootstrap\/realm'/ + message: /Cannot find module 'internal\/bootstrap\/realm'/, } ); @@ -23,6 +23,6 @@ assert.throws( require('owo'); }, { code: 'MODULE_NOT_FOUND', - message: /Cannot find module 'owo'/ + message: /Cannot find module 'owo'/, } ); diff --git a/test/es-module/test-loaders-unknown-builtin-module.mjs b/test/es-module/test-loaders-unknown-builtin-module.mjs index 85181a2b73b54c..c97e52d1e63d50 100644 --- a/test/es-module/test-loaders-unknown-builtin-module.mjs +++ b/test/es-module/test-loaders-unknown-builtin-module.mjs @@ -7,6 +7,6 @@ const unknownBuiltinModule = 'node:unknown-builtin-module'; import(unknownBuiltinModule) .then(assert.fail, expectsError({ code: 'ERR_UNKNOWN_BUILTIN_MODULE', - message: `No such built-in module: ${unknownBuiltinModule}` + message: `No such built-in module: ${unknownBuiltinModule}`, })) .then(mustCall()); diff --git a/test/es-module/test-require-as-esm-interop.mjs b/test/es-module/test-require-as-esm-interop.mjs index 8364fd6c2fceca..dd709452df8fe9 100644 --- a/test/es-module/test-require-as-esm-interop.mjs +++ b/test/es-module/test-require-as-esm-interop.mjs @@ -9,7 +9,7 @@ const tests = { 'object': { a: 'cjs a', b: 'cjs b' }, 'fauxesmdefault': { default: 'faux esm default' }, 'fauxesmmixed': { default: 'faux esm default', a: 'faux esm a', b: 'faux esm b' }, - 'fauxesmnamed': { a: 'faux esm a', b: 'faux esm b' } + 'fauxesmnamed': { a: 'faux esm a', b: 'faux esm b' }, }; // This test demonstrates interop between CJS and CJS represented as ESM diff --git a/test/es-module/test-require-esm-from-imported-cjs.js b/test/es-module/test-require-esm-from-imported-cjs.js index b03b41beb1208e..bbce967a4b7e0b 100644 --- a/test/es-module/test-require-esm-from-imported-cjs.js +++ b/test/es-module/test-require-esm-from-imported-cjs.js @@ -17,7 +17,7 @@ spawnSyncAndAssert( ], { trim: true, - stdout: / default: { hello: 'world' }/ + stdout: / default: { hello: 'world' }/, } ); @@ -31,6 +31,6 @@ spawnSyncAndAssert( ], { trim: true, - stdout: / default: { hello: 'world' }/ + stdout: / default: { hello: 'world' }/, } ); diff --git a/test/es-module/test-require-module-conditional-exports.js b/test/es-module/test-require-module-conditional-exports.js index 354c8b72abc7a1..60b7a3ba8b73af 100644 --- a/test/es-module/test-require-module-conditional-exports.js +++ b/test/es-module/test-require-module-conditional-exports.js @@ -17,7 +17,7 @@ const { isModuleNamespaceObject } = require('util/types'); assert.throws(() => { require('../fixtures/es-modules/exports-import-only/load.cjs'); }, { - code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' + code: 'ERR_PACKAGE_PATH_NOT_EXPORTED', }); // If both are defined, "require" is used. diff --git a/test/es-module/test-require-module-cycle-esm-esm-cjs-esm.js b/test/es-module/test-require-module-cycle-esm-esm-cjs-esm.js index edec79e276d21c..3af049baa9a281 100644 --- a/test/es-module/test-require-module-cycle-esm-esm-cjs-esm.js +++ b/test/es-module/test-require-module-cycle-esm-esm-cjs-esm.js @@ -21,7 +21,7 @@ const assert = require('assert'); assert.match(output, /Start c/); assert.match(output, /dynamic import b\.mjs failed.*ERR_REQUIRE_CYCLE_MODULE/); assert.match(output, /dynamic import d\.mjs failed.*ERR_REQUIRE_CYCLE_MODULE/); - } + }, } ); } diff --git a/test/es-module/test-require-module-dont-detect-cjs.js b/test/es-module/test-require-module-dont-detect-cjs.js index 99f49bc59d17c4..8d0c3291af73c8 100644 --- a/test/es-module/test-require-module-dont-detect-cjs.js +++ b/test/es-module/test-require-module-dont-detect-cjs.js @@ -7,5 +7,5 @@ const assert = require('assert'); assert.throws(() => { require('../fixtures/es-modules/es-note-unexpected-export-1.cjs'); }, { - message: /Unexpected token 'export'/ + message: /Unexpected token 'export'/, }); diff --git a/test/es-module/test-require-module-error-catching.js b/test/es-module/test-require-module-error-catching.js index 5400564b3182c6..411ac511a341e3 100644 --- a/test/es-module/test-require-module-error-catching.js +++ b/test/es-module/test-require-module-error-catching.js @@ -9,7 +9,7 @@ const assert = require('assert'); assert.throws(() => { require('../fixtures/es-modules/runtime-error-esm.js'); }, { - message: 'hello' + message: 'hello', }); // References errors should be caught too. @@ -17,5 +17,5 @@ assert.throws(() => { require('../fixtures/es-modules/reference-error-esm.js'); }, { name: 'ReferenceError', - message: 'exports is not defined in ES module scope' + message: 'exports is not defined in ES module scope', }); diff --git a/test/es-module/test-require-module-implicit.js b/test/es-module/test-require-module-implicit.js index e9483ba4da1192..c1bbf3f64561e2 100644 --- a/test/es-module/test-require-module-implicit.js +++ b/test/es-module/test-require-module-implicit.js @@ -12,7 +12,7 @@ const assert = require('assert'); assert.throws(() => { require(id); }, { - code: 'MODULE_NOT_FOUND' + code: 'MODULE_NOT_FOUND', }); const mod = require(`${id}.mjs`); common.expectRequiredModule(mod, { hello: 'world' }); diff --git a/test/es-module/test-require-module-preload.js b/test/es-module/test-require-module-preload.js index 0b8b79118ee8e6..629601c4fc26de 100644 --- a/test/es-module/test-require-module-preload.js +++ b/test/es-module/test-require-module-preload.js @@ -16,7 +16,7 @@ function testPreload(preloadFlag) { './printA.js', ], { - cwd: fixturesDir + cwd: fixturesDir, }, { stdout: 'A', @@ -36,7 +36,7 @@ function testPreload(preloadFlag) { './printA.js', ], { - cwd: fixturesDir + cwd: fixturesDir, }, { stdout: /^world\s+A$/, @@ -56,7 +56,7 @@ function testPreload(preloadFlag) { './printA.js', ], { - cwd: fixturesDir + cwd: fixturesDir, }, { stdout: /^ok\s+A$/, @@ -78,7 +78,7 @@ function testPreload(preloadFlag) { './printA.js', ], { - cwd: fixturesDir + cwd: fixturesDir, }, { stdout: /^world\s+A$/, @@ -103,7 +103,7 @@ testPreload('--import'); './printA.js', ], { - cwd: fixturesDir + cwd: fixturesDir, }, { stdout: /^package-type-module\s+A$/, diff --git a/test/es-module/test-require-module-retry-import-errored.js b/test/es-module/test-require-module-retry-import-errored.js index 4736087d2624a5..8b72adc76a26fe 100644 --- a/test/es-module/test-require-module-retry-import-errored.js +++ b/test/es-module/test-require-module-retry-import-errored.js @@ -9,7 +9,7 @@ const { exportedReject } = require('../fixtures/es-modules/tla/export-promise.mj assert.throws(() => { require('../fixtures/es-modules/tla/await-export-promise.mjs'); }, { - code: 'ERR_REQUIRE_ASYNC_MODULE' + code: 'ERR_REQUIRE_ASYNC_MODULE', }); const interval = setInterval(() => {}, 1000); // Keep the test running, because await alone doesn't. diff --git a/test/es-module/test-require-module-retry-import-evaluating.js b/test/es-module/test-require-module-retry-import-evaluating.js index df70432f1136e4..e9178db75a6eb6 100644 --- a/test/es-module/test-require-module-retry-import-evaluating.js +++ b/test/es-module/test-require-module-retry-import-evaluating.js @@ -9,7 +9,7 @@ const { exportedResolve } = require('../fixtures/es-modules/tla/export-promise.m assert.throws(() => { require('../fixtures/es-modules/tla/await-export-promise.mjs'); }, { - code: 'ERR_REQUIRE_ASYNC_MODULE' + code: 'ERR_REQUIRE_ASYNC_MODULE', }); const interval = setInterval(() => {}, 1000); // Keep the test running, because await alone doesn't. diff --git a/test/es-module/test-require-module-tla-execution.js b/test/es-module/test-require-module-tla-execution.js index bdd222d1f8fa0b..cd9f1b972c63e5 100644 --- a/test/es-module/test-require-module-tla-execution.js +++ b/test/es-module/test-require-module-tla-execution.js @@ -21,6 +21,6 @@ const fixtures = require('../common/fixtures'); assert.match(output, /Requiring .*execution\.mjs/); return true; }, - stdout: '' + stdout: '', }); } diff --git a/test/es-module/test-require-module-tla-print-execution.js b/test/es-module/test-require-module-tla-print-execution.js index 40992ae32e0905..d831856fe676dd 100644 --- a/test/es-module/test-require-module-tla-print-execution.js +++ b/test/es-module/test-require-module-tla-print-execution.js @@ -24,6 +24,6 @@ const fixtures = require('../common/fixtures'); assert.match(output, /Requiring .*execution\.mjs/); return true; }, - stdout: '' + stdout: '', }); } diff --git a/test/es-module/test-require-module-tla-retry-import-2.js b/test/es-module/test-require-module-tla-retry-import-2.js index 2ca8e07449c2fa..afbdf349047837 100644 --- a/test/es-module/test-require-module-tla-retry-import-2.js +++ b/test/es-module/test-require-module-tla-retry-import-2.js @@ -18,7 +18,7 @@ async function test() { assert.throws(() => { require('../fixtures/es-modules/tla/export-async.mjs'); }, { - code: 'ERR_REQUIRE_ASYNC_MODULE' + code: 'ERR_REQUIRE_ASYNC_MODULE', }); } diff --git a/test/es-module/test-require-module-tla-retry-import.js b/test/es-module/test-require-module-tla-retry-import.js index 80b289fdfc8c43..e1d72e7ea6f80d 100644 --- a/test/es-module/test-require-module-tla-retry-import.js +++ b/test/es-module/test-require-module-tla-retry-import.js @@ -9,7 +9,7 @@ async function test() { assert.throws(() => { require('../fixtures/es-modules/tla/export-async.mjs'); }, { - code: 'ERR_REQUIRE_ASYNC_MODULE' + code: 'ERR_REQUIRE_ASYNC_MODULE', }); const newNs = await import('../fixtures/es-modules/tla/export-async.mjs'); if (ns === undefined) { diff --git a/test/es-module/test-require-module-tla-retry-require.js b/test/es-module/test-require-module-tla-retry-require.js index d440698fc22b52..f198e618dbab4c 100644 --- a/test/es-module/test-require-module-tla-retry-require.js +++ b/test/es-module/test-require-module-tla-retry-require.js @@ -7,10 +7,10 @@ const assert = require('assert'); assert.throws(() => { require('../fixtures/es-modules/tla/resolved.mjs'); }, { - code: 'ERR_REQUIRE_ASYNC_MODULE' + code: 'ERR_REQUIRE_ASYNC_MODULE', }); assert.throws(() => { require('../fixtures/es-modules/tla/resolved.mjs'); }, { - code: 'ERR_REQUIRE_ASYNC_MODULE' + code: 'ERR_REQUIRE_ASYNC_MODULE', }); diff --git a/test/es-module/test-require-module-warning.js b/test/es-module/test-require-module-warning.js index 4c651efd5c0cc7..08a0e8d75d8c76 100644 --- a/test/es-module/test-require-module-warning.js +++ b/test/es-module/test-require-module-warning.js @@ -30,7 +30,7 @@ spawnSyncAndAssert(process.execPath, [ lines[3], /at Object\. \(.*require-module\.js:1:1\)/ ); - } + }, }); spawnSyncAndAssert(process.execPath, [ @@ -39,5 +39,5 @@ spawnSyncAndAssert(process.execPath, [ ], { status: 9, trim: true, - stderr: /invalid value for --trace-require-module/ + stderr: /invalid value for --trace-require-module/, }); diff --git a/test/es-module/test-require-module.js b/test/es-module/test-require-module.js index 7e05fbd4a5bf88..4a675bc116c6eb 100644 --- a/test/es-module/test-require-module.js +++ b/test/es-module/test-require-module.js @@ -43,6 +43,6 @@ const assert = require('assert'); const mod = require('../fixtures/es-modules/data-import.mjs'); common.expectRequiredModule(mod, { data: { hello: 'world' }, - id: 'data:text/javascript,export default %7B%20hello%3A%20%22world%22%20%7D' + id: 'data:text/javascript,export default %7B%20hello%3A%20%22world%22%20%7D', }); } diff --git a/test/es-module/test-vm-main-context-default-loader.js b/test/es-module/test-vm-main-context-default-loader.js index d2ac6021df3837..a46cbd1d486b0c 100644 --- a/test/es-module/test-vm-main-context-default-loader.js +++ b/test/es-module/test-vm-main-context-default-loader.js @@ -77,7 +77,7 @@ async function main() { const filename = tmpdir.resolve('index.js'); const options = { filename, - importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER + importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, }; await testNotFoundErrors(options); await testLoader(options); @@ -90,7 +90,7 @@ async function main() { const filename = url.pathToFileURL(tmpdir.resolve('index.js')).href + '?t=1'; const options = { filename, - importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER + importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, }; await testNotFoundErrors(options); await testLoader(options); @@ -101,11 +101,11 @@ async function main() { tmpdir.refresh(); process.chdir(tmpdir.path); const undefinedOptions = { - importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER + importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, }; const nonPathOptions = { filename: 'non-path', - importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER + importModuleDynamically: USE_MAIN_CONTEXT_DEFAULT_LOADER, }; // Run the error tests first to avoid caching. await testNotFoundErrors(undefinedOptions); diff --git a/test/es-module/test-wasm-web-api.js b/test/es-module/test-wasm-web-api.js index a6943254d88d83..ee1971133be5ea 100644 --- a/test/es-module/test-wasm-web-api.js +++ b/test/es-module/test-wasm-web-api.js @@ -74,7 +74,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { return assert.rejects(() => WebAssembly.compileStreaming(arg), { name: 'TypeError', code: 'ERR_INVALID_ARG_TYPE', - message: /^The "source" argument .*$/ + message: /^The "source" argument .*$/, }); }, 2)); } @@ -98,7 +98,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { await testCompileStreamingSuccess(() => { return Promise.resolve(new Response(simpleWasmBytes, { status: 200, - headers: { 'Content-Type': 'application/wasm' } + headers: { 'Content-Type': 'application/wasm' }, })); }); @@ -111,7 +111,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { const stream = handle.readableWebStream({ autoClose: true }); return Promise.resolve(new Response(stream, { status: 200, - headers: { 'Content-Type': 'application/wasm' } + headers: { 'Content-Type': 'application/wasm' }, })); }); @@ -161,7 +161,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { name: 'TypeError', code: 'ERR_WEBASSEMBLY_RESPONSE', message: 'WebAssembly response has unsupported MIME type ' + - "'application/wasm;'" + "'application/wasm;'", }); // A valid WebAssembly file with an invalid MIME type. @@ -172,7 +172,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { name: 'TypeError', code: 'ERR_WEBASSEMBLY_RESPONSE', message: 'WebAssembly response has unsupported MIME type ' + - "'application/octet-stream'" + "'application/octet-stream'", }); // HTTP status code indicating an error. @@ -183,7 +183,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { }, { name: 'TypeError', code: 'ERR_WEBASSEMBLY_RESPONSE', - message: /^WebAssembly response has status code 418$/ + message: /^WebAssembly response has status code 418$/, }); // HTTP status code indicating an error, but using a Response whose body is @@ -191,7 +191,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { await testCompileStreamingSuccess(() => { return Promise.resolve(new Response(simpleWasmBytes, { status: 200, - headers: { 'Content-Type': 'application/wasm' } + headers: { 'Content-Type': 'application/wasm' }, })); }); @@ -201,7 +201,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { res.end(Buffer.concat([simpleWasmBytes, Buffer.from('foo')])); }, { name: 'CompileError', - message: /^WebAssembly\.compileStreaming\(\): .*$/ + message: /^WebAssembly\.compileStreaming\(\): .*$/, }); // Missing bytes at the end of the WebAssembly file. @@ -210,7 +210,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { res.end(simpleWasmBytes.subarray(0, simpleWasmBytes.length - 3)); }, { name: 'CompileError', - message: /^WebAssembly\.compileStreaming\(\): .*$/ + message: /^WebAssembly\.compileStreaming\(\): .*$/, }); // Incomplete HTTP response body. The TypeError might come as a surprise, but @@ -223,7 +223,7 @@ function testCompileStreamingRejectionUsingFetch(responseCallback, rejection) { })); }, { name: 'TypeError', - message: /terminated/ + message: /terminated/, }); // Test "Developer-Facing Display Conventions" described in the WebAssembly diff --git a/test/eslint.config_partial.mjs b/test/eslint.config_partial.mjs index 6ecb2405547889..1fbc2e498226b9 100644 --- a/test/eslint.config_partial.mjs +++ b/test/eslint.config_partial.mjs @@ -146,7 +146,6 @@ export default [ }, { files: [ - 'test/es-module/**/*.{js,mjs}', 'test/parallel/**/*.{js,mjs}', 'test/sequential/**/*.{js,mjs}', ], @@ -163,6 +162,23 @@ export default [ ], }, }, + { + files: [ + 'test/es-module/**/*.{js,mjs}', + ], + rules: { + '@stylistic/js/comma-dangle': [ + 'error', + { + arrays: 'always-multiline', + exports: 'always-multiline', + functions: 'only-multiline', + imports: 'always-multiline', + objects: 'always-multiline', + }, + ], + }, + }, { files: [ 'test/{common,fixtures,wpt}/**/*.{js,mjs,cjs}',