For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/import/no-deprecated.md.
close

no-deprecated

Unreleased

Configuration

rslint.config.ts
import { defineConfig, importPlugin } from '@rslint/core';

export default defineConfig([
  importPlugin.configs.recommended,
  {
    rules: {
      'import/no-deprecated': 'error',
    },
  },
]);

Reports imports and uses of exported names marked with a JSDoc @deprecated tag. It also checks namespace members, including namespaces re-exported by other modules. A block with both @module and @deprecated marks the entire module deprecated, so even an import with no specifiers is reported.

Rule Details

Given answer.js:

/** @deprecated use the new experiment */
export function multiply(six, nine) {
  return 42;
}

export function experiment() {
  return 54;
}

Examples of incorrect code:

import { multiply } from './answer.js';
multiply(6, 9);

import * as answer from './answer.js';
answer.multiply(6, 9);

Examples of correct code:

import { experiment } from './answer.js';
experiment();

Deprecated named and default imports are reported on the import specifier and again when used. Namespace imports are reported on deprecated member names. Local shadowing prevents reports for the shadowed binding. Computed namespace access and destructuring are not checked, matching upstream behavior.

Options

This rule has no options. JSDoc is enabled by default. Enable TomDoc comments with the shared import/docstyle setting:

{
  settings: {
    'import/docstyle': ['jsdoc', 'tomdoc'],
  },
  rules: {
    'import/no-deprecated': 'error',
  },
}

TomDoc marks an export with a leading // Deprecated: reason comment. Its first paragraph supplies the reason. Module-level JSDoc is checked independently of this setting.

Autofix

This rule has no autofix or suggestions.

Differences from upstream

  • Dependency parser errors are handled by Rslint's compiler rather than emitted as import/no-deprecated rule reports. Upstream's malformed-dependency test is retained as an explained skip.
  • A malformed unrelated documentation tag does not suppress a later @deprecated. For example, @param {broken before @deprecated use newAPI stops upstream's documentation parser before it sees the deprecation; Rslint still reports the deprecated export. Correct the malformed tag to obtain the same result in both tools.
  • Each identifier is checked against its own binding. Upstream decides from the first same-name reference in the current scope, so it also reports a local that shadows the import, uses of that local, and object property keys such as { old: 1 } whenever that scope references the import elsewhere. Rslint reports only references that resolve to the deprecated import.

References