no-deprecated-api
Configuration
rslint.config.ts
Rule Details
Disallow the use of deprecated Node.js APIs. The rule flags:
- Deprecated builtin modules (
require('sys'),import domain from 'domain'). - Deprecated members of builtin modules, reached through
require(), ESMimport, orprocess.getBuiltinModule()— including intermediate variables and destructuring (var b = require('buffer'); new b.Buffer()). - Deprecated Node.js globals (
new Buffer(),Intl.v8BreakIterator,process.binding).
node:-prefixed specifiers (require('node:buffer')) are treated the same as the bare form.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
version(string) — the target Node.js version range. Replacement suggestions in the message are filtered to APIs already available on that version. Defaults to>=16.0.0.ignoreModuleItems(string[]) — module-API names to allow, e.g.["buffer.Buffer()", "fs.exists"].ignoreGlobalItems(string[]) — global names to allow, e.g.["new Buffer()", "Buffer()"].
Examples of correct code with { "ignoreModuleItems": ["fs.exists"] }:
Differences from ESLint
- The target Node.js version comes from the
versionoption orsettings.n.version/settings.node.version, defaulting to>=16.0.0. Unlike eslint-plugin-n, it is not read frompackage.json(engines.node/devEngines.runtime) — set it explicitly when you need a non-default target.