n/prefer-node-protocol
eslint-plugin-n
Safe autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-node-protocol": "error",
},
},
];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.
n/prefer-node-protocol
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/prefer-node-protocol": "error",
},
},
];Oxlint does not have this rule.
style/useNodejsImportProtocol
style · since 1.5.0
{
"linter": {
"rules": {
"style": {
"useNodejsImportProtocol": "error"
}
}
}
}Prefer using the node: protocol when importing Node.js builtin modules.
Disallow specified modules when loaded by import declarations