forked from mysticatea/eslint-plugin-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support
node:
prefix (mysticatea#109)
- Loading branch information
Showing
13 changed files
with
258 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
"use strict" | ||
|
||
const isCoreModule = require("is-core-module") | ||
|
||
/** | ||
* Extend trackMap.modules with `node:` prefixed modules | ||
* @param {Object} modules Like `{assert: foo}` | ||
* @returns {Object} Like `{assert: foo}, "node:assert": foo}` | ||
*/ | ||
module.exports = function extendTrackMapWithNodePrefix(modules) { | ||
const ret = { | ||
...modules, | ||
...Object.fromEntries( | ||
Object.entries(modules) | ||
.map(([name, value]) => [`node:${name}`, value]) | ||
// Note: "999" arbitrary to check current/future Node.js version | ||
.filter(([name]) => isCoreModule(name, "999")) | ||
), | ||
} | ||
return ret | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict" | ||
|
||
/** | ||
* Remove `node:` prefix from module name | ||
* @param {string} name The module name such as `node:assert` or `assert`. | ||
* @returns {string} The unprefixed module name like `assert`. | ||
*/ | ||
module.exports = function unprefixNodeColon(name) { | ||
if (name.startsWith("node:")) { | ||
return name.slice(5) | ||
} | ||
return name | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.