CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-eslint-plugin-deprecation

ESLint rule that reports usage of deprecated code marked with JSDoc @deprecated tags

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

ESLint Plugin Deprecation

ESLint Plugin Deprecation provides rules that detect and report usage of deprecated code marked with JSDoc @deprecated tags. It works with TypeScript and JavaScript codebases to identify deprecated APIs from browsers, Node.js, libraries, and user-defined code.

Package Information

  • Package Name: eslint-plugin-deprecation
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install --save-dev eslint-plugin-deprecation

Core Imports

ESLint plugins are typically loaded automatically by ESLint when specified in configuration. For programmatic access:

import plugin from "eslint-plugin-deprecation";

CommonJS import:

const plugin = require("eslint-plugin-deprecation");

Access individual components:

import { rules, configs, meta } from "eslint-plugin-deprecation";

Basic Usage

Using Recommended Configuration

The simplest setup uses the recommended configuration:

{
  "extends": ["plugin:deprecation/recommended"]
}

Manual Configuration

{
  "plugins": ["deprecation"],
  "rules": {
    "deprecation/deprecation": "error"
  }
}

Prerequisites

This plugin requires TypeScript parser configuration:

{
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaVersion": 2020,
    "sourceType": "module",
    "project": "./tsconfig.json"
  }
}

Capabilities

Plugin Export

Main plugin export containing rules, configurations, and metadata.

interface PluginExport {
  rules: {
    deprecation: DeprecationRule;
  };
  configs: {
    recommended: RecommendedConfig;
  };
  meta: {
    name: string;
    version: string;
  };
}

Deprecation Rule

The core rule that detects usage of deprecated APIs.

interface DeprecationRule {
  meta: {
    type: "problem";
    docs: {
      description: "Do not use deprecated APIs.";
      requiresTypeChecking: true;
    };
    messages: {
      deprecated: "'{{name}}' is deprecated. {{reason}}";
    };
    schema: [];
  };
  defaultOptions: [];
  create: (context: ESLintRuleContext) => {
    Identifier: (node: ESLintNode) => void;
    JSXIdentifier: (node: ESLintNode) => void;
  };
}

Rule Options: This rule takes no options.

What it detects:

  • Variables, functions, classes, and methods marked with @deprecated JSDoc tags
  • Browser APIs marked as deprecated
  • Node.js APIs marked as deprecated
  • Library APIs marked as deprecated

What it ignores:

  • JSX closing elements (only flags opening elements)
  • Declaration sites where deprecated items are defined
  • Import statements themselves

Recommended Configuration

Pre-configured ESLint configuration for immediate use.

interface RecommendedConfig {
  plugins: string[];
  rules: {
    "deprecation/deprecation": "error";
  };
}

Types

type ESLintRuleContext = {
  getAncestors: () => ESLintNode[];
  getParserServices: () => ParserServices;
  report: (descriptor: {
    node: ESLintNode;
    messageId: string;
    data: Record<string, string>;
  }) => void;
};

type ESLintNode = {
  type: string;
  name?: string;
  parent?: ESLintNode;
};

type ParserServices = {
  program: TypeScriptProgram;
  esTreeNodeToTSNodeMap: WeakMap<ESLintNode, TypeScriptNode>;
};

type TypeScriptProgram = {
  getTypeChecker: () => TypeScriptTypeChecker;
};

type TypeScriptNode = unknown;
type TypeScriptTypeChecker = unknown;

type MessageIds = "deprecated";
type Options = unknown[];

Error Messages

When the rule detects deprecated usage, it reports:

'{{name}}' is deprecated. {{reason}}

Where:

  • {{name}} is the name of the deprecated API
  • {{reason}} is the deprecation message from the @deprecated JSDoc tag

Configuration Error: If TypeScript services are not properly configured, the rule throws:

TypeScript is required for this rule: https://github.com/gund/eslint-plugin-deprecation#prerequisites

Dependencies

Peer Dependencies:

  • eslint: ^8.0.0
  • typescript: ^4.2.4 || ^5.0.0

Runtime Dependencies:

  • @typescript-eslint/utils: ^7.0.0
  • tslib: ^2.3.1
  • ts-api-utils: ^1.3.0

Install with Tessl CLI

npx tessl i tessl/npm-eslint-plugin-deprecation
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/eslint-plugin-deprecation@3.0.x
Publish Source
CLI
Badge
tessl/npm-eslint-plugin-deprecation badge