From 3b4799fe10c95c15771d2e53ece5a2b865fae007 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 13 Dec 2018 08:13:47 +0100 Subject: [PATCH 1/2] test: remove dead code This is not used by the test anymore. --- test/es-module/test-esm-dynamic-import.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 6cbbd0ac67dd66..0023b5f2d80808 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -3,7 +3,6 @@ const common = require('../common'); const assert = require('assert'); const { URL } = require('url'); -const vm = require('vm'); const relativePath = '../fixtures/es-modules/test-esm-ok.mjs'; const absolutePath = require.resolve('../fixtures/es-modules/test-esm-ok.mjs'); @@ -21,23 +20,6 @@ function expectMissingModuleError(result) { expectErrorProperty(result, 'code', 'MODULE_NOT_FOUND'); } -function expectInvalidUrlError(result) { - expectErrorProperty(result, 'code', 'ERR_INVALID_URL'); -} - -function expectInvalidReferrerError(result) { - expectErrorProperty(result, 'code', 'ERR_INVALID_URL'); -} - -function expectInvalidProtocolError(result) { - expectErrorProperty(result, 'code', 'ERR_INVALID_PROTOCOL'); -} - -function expectInvalidContextError(result) { - expectErrorProperty(result, - 'message', 'import() called outside of main context'); -} - function expectOkNamespace(result) { Promise.resolve(result) .then(common.mustCall(ns => { From aa48e323de325e659abda00f9e3171d0161a85a3 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 13 Dec 2018 09:35:55 +0100 Subject: [PATCH 2/2] test: run eslint on test file and fix errors This removes two entries from the eslint ignore file. One file does not exist anymore and the other one could easily be fixed. --- .eslintignore | 2 -- test/es-module/test-esm-dynamic-import.js | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/.eslintignore b/.eslintignore index 80959ce611ee58..bdfdfaeab2388d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,9 +1,7 @@ node_modules -lib/internal/v8.js lib/internal/v8_prof_polyfill.js lib/punycode.js test/addons/??_* -test/es-module/test-esm-dynamic-import.js test/fixtures test/message/esm_display_syntax_error.mjs tools/icu diff --git a/test/es-module/test-esm-dynamic-import.js b/test/es-module/test-esm-dynamic-import.js index 0023b5f2d80808..887339977669ea 100644 --- a/test/es-module/test-esm-dynamic-import.js +++ b/test/es-module/test-esm-dynamic-import.js @@ -11,7 +11,7 @@ targetURL.pathname = absolutePath; function expectErrorProperty(result, propertyKey, value) { Promise.resolve(result) - .catch(common.mustCall(error => { + .catch(common.mustCall((error) => { assert.strictEqual(error[propertyKey], value); })); } @@ -22,15 +22,16 @@ function expectMissingModuleError(result) { function expectOkNamespace(result) { Promise.resolve(result) - .then(common.mustCall(ns => { + .then(common.mustCall((ns) => { // Can't deepStrictEqual because ns isn't a normal object + // eslint-disable-next-line no-restricted-properties assert.deepEqual(ns, { default: true }); })); } function expectFsNamespace(result) { Promise.resolve(result) - .then(common.mustCall(ns => { + .then(common.mustCall((ns) => { assert.strictEqual(typeof ns.default.writeFile, 'function'); assert.strictEqual(typeof ns.writeFile, 'function'); })); @@ -41,19 +42,19 @@ function expectFsNamespace(result) { (function testScriptOrModuleImport() { // Importing another file, both direct & via eval // expectOkNamespace(import(relativePath)); - expectOkNamespace(eval.call(null, `import("${relativePath}")`)); expectOkNamespace(eval(`import("${relativePath}")`)); - expectOkNamespace(eval.call(null, `import("${targetURL}")`)); + expectOkNamespace(eval(`import("${relativePath}")`)); + expectOkNamespace(eval(`import("${targetURL}")`)); // Importing a built-in, both direct & via eval - expectFsNamespace(import("fs")); + expectFsNamespace(import('fs')); + expectFsNamespace(eval('import("fs")')); expectFsNamespace(eval('import("fs")')); - expectFsNamespace(eval.call(null, 'import("fs")')); - expectMissingModuleError(import("./not-an-existing-module.mjs")); + expectMissingModuleError(import('./not-an-existing-module.mjs')); // TODO(jkrems): Right now this doesn't hit a protocol error because the // module resolution step already rejects it. These arguably should be // protocol errors. - expectMissingModuleError(import("node:fs")); + expectMissingModuleError(import('node:fs')); expectMissingModuleError(import('http://example.com/foo.js')); })();