n/prefer-node-protocol
eslint-plugin-n
Safe autofix
eslint.config.js
Enforce using the node: protocol when importing Node.js builtin modules.
import fs from "fs"
export { promises } from "fs"
const fs = require("fs")
const fs = process.getBuiltinModule("fs")import fs from "node:fs"
export { promises } from "node:fs"
const fs = require("node:fs")
const fs = process.getBuiltinModule("node:fs")Examples from the ESLint documentation.
No tracked preset enables this rule, so it has no reach yet.
None of the tracked presets enable this rule. Turn it on with the config below.
Prefer using the node: protocol when importing Node.js builtin modules.
Disallow specified modules when loaded by import declarations
n/prefer-node-protocol
eslint-plugin-n
Oxlint does not have this rule.
style/useNodejsImportProtocol
style · since 1.5.0
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-node-protocol": "error",
},
},
];{
"linter": {
"rules": {
"style": {
"useNodejsImportProtocol": "error"
}
}
}
}