no-deprecated-api
UnreleasedConfiguration
Disallow deprecated static Node.js APIs.
Rule details
The rule checks configured Node globals, CommonJS imports, ESM imports and re-exports, and process.getBuiltinModule(). It follows aliases and object destructuring, including node: module names.
Examples of incorrect code:
Examples of correct code:
The rule reports deprecated APIs even when the configured Node version predates their deprecation. The version range controls which replacement APIs appear in the message. This rule does not provide automatic fixes or suggestions.
Options
version: a Node version range. Resolution checks this option,settings.n.version,settings.node.version, the nearestpackage.json'sengines.node, then itsdevEngines.runtimeentry namednode. Invalid ranges fall through. The fallback is>=16.0.0.ignoreModuleItems: exact module API names to ignore, such asfs.exists,buffer.Buffer()ornew buffer.Buffer(). Use names withoutnode:for both import spellings.ignoreGlobalItems: exact global API names to ignore, such asBuffer(),new Buffer()orprocess.binding. Global and module ignore lists are independent.ignoreIndirectDependencies: accepted for compatibility with the upstream deprecated option; it has no effect.
For example, ignoreModuleItems: ['new buffer.Buffer()'] allows new (require('buffer').Buffer)(10) while still reporting calls without new.
Limitations
Only static APIs are checked. The rule does not infer instance types, dynamic property names, values passed as arguments, or aliases stored on object properties. Reassigning a local alias does not cancel its earlier tracked origin. A user-installed package does not hide a Node builtin: use require('punycode/') to select that package rather than require('punycode').