Require Node Protocol
Require the node: protocol when importing a Node.js built-in module because the explicit prefix makes it unambiguous that the import is a built-in and never a userland package.
Summary
The require-node-protocol rule reports any static import, re-export, or dynamic import of a Node.js built-in module that omits the node: protocol. It checks the module specifier's base module (before any subpath), so fs/promises is treated the same as fs.
Relative imports, userland packages, and specifiers that already carry the node: prefix are left untouched.
Why Use This Rule?
- Makes built-in imports explicit —
import fs from 'node:fs'cannot be confused with a userland package namedfs. - Matches the Node.js recommendation for importing built-ins.
- Keeps every import consistent across the codebase — every built-in is prefixed, always.
Examples
Configuration
Options
warning
ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.
| Option | Type | Default | Description |
|---|---|---|---|
ignoreFiles | string[] | [] | File names to skip. Supports a leading-* suffix (*.test.ts), an exact path, or a trailing path segment; ** globs are not supported. |
Autofix
This rule provides automatic fixes. Run ESLint with the --fix flag:
npx eslint --fix . --rule '@cbnventures/nova/require-node-protocol: error'
The autofix inserts the node: prefix and preserves the original quote style.
Troubleshooting
- Userland packages are not checked — Only names that resolve to a Node.js built-in module are reported. A userland package that happens to share a name with a built-in is matched by the built-in list, so disable the rule for that line if you genuinely import such a package.
- Subpaths are matched by base module —
fs/promisesis reported because its base modulefsis a built-in, and is fixed tonode:fs/promises. require()calls are not checked — This rule targets ES moduleimport,export ... from, and dynamicimport()specifiers. CommonJSrequire()is not covered.