diff --git a/lib/rules/prefer-node-protocol.js b/lib/rules/prefer-node-protocol.js index cb012511..8e5ed23f 100644 --- a/lib/rules/prefer-node-protocol.js +++ b/lib/rules/prefer-node-protocol.js @@ -4,12 +4,22 @@ */ "use strict" -const { isBuiltin } = require("node:module") const getConfiguredNodeVersion = require("../util/get-configured-node-version") const getSemverRange = require("../util/get-semver-range") const visitImport = require("../util/visit-import") const visitRequire = require("../util/visit-require") const mergeVisitorsInPlace = require("../util/merge-visitors-in-place") +const { + NodeBuiltinModules, +} = require("../unsupported-features/node-builtins.js") + +/** + * @param {string} name The name of the node module + * @returns {boolean} + */ +function isBuiltin(name) { + return Object.hasOwn(NodeBuiltinModules, name) +} const messageId = "preferNodeProtocol" diff --git a/tests/lib/rules/prefer-node-protocol.js b/tests/lib/rules/prefer-node-protocol.js index e2796177..91c13f27 100644 --- a/tests/lib/rules/prefer-node-protocol.js +++ b/tests/lib/rules/prefer-node-protocol.js @@ -33,6 +33,8 @@ new RuleTester({ const fs = await import(\`fs\`); } `, + // punycode has no `node:` equivelent + 'import "punycode";', 'import "punycode/";', // https://bun.sh/docs/runtime/bun-apis 'import "bun";',