Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove dead code #25009

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
node_modules
lib/internal/v8.js
lib/internal/v8_prof_polyfill.js
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what this file does. Do we have to ignore the file here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My vague recollection: I think the file was originally copied from either V8 source or a V8 change proposal that may have been rejected by V8. Since we were copying the file, we didn't apply our lint style to it since we would just copy changes from upstream at a later date, presumably. This is similar, I think, to how we handle punycode.js. It looks like we may now basically own v8_prof_polyfill.js, though. I'm not sure. @matthewloring may know,.

lib/punycode.js
test/addons/??_*
test/es-module/test-esm-dynamic-import.js
test/fixtures
test/message/esm_display_syntax_error.mjs
tools/icu
Expand Down
37 changes: 10 additions & 27 deletions test/es-module/test-esm-dynamic-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -12,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);
}));
}
Expand All @@ -21,34 +20,18 @@ 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 => {
.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');
}));
Expand All @@ -59,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'));
})();