{"id":19726,"library":"eslint-plugin-deprecation","title":"eslint-plugin-deprecation","description":"An ESLint plugin that reports usage of deprecated code by leveraging TypeScript type checking. Version 3.0.0 supports ESLint v8+ and TypeScript 4.2+ / 5.x. It automatically detects any code annotated with the JSDoc `@deprecated` tag, including APIs from your own code, libraries, Node.js, and browsers. Key differentiators: unlike simple regex-based checks, it uses the TypeScript compiler to accurately resolve deprecated symbols, avoiding false positives. The plugin ships with a recommended config and is maintained with frequent releases following semver. It requires a TypeScript parser with type information enabled.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/gund/eslint-plugin-deprecation","tags":["javascript","typescript"],"install":[{"cmd":"npm install eslint-plugin-deprecation","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-deprecation","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-deprecation","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides shared utilities for TypeScript-aware ESLint rules; used internally for rule creation and parser services.","package":"@typescript-eslint/utils","optional":false},{"reason":"Peer dependency; required to run the plugin. Versions 8+ supported as of v3.0.0.","package":"eslint","optional":false},{"reason":"Peer dependency; the plugin uses TypeScript's type system to detect deprecated symbols. Versions 4.2+ or 5.x supported.","package":"typescript","optional":false}],"imports":[{"note":"ESLint plugins are not imported as objects; they are specified as strings in the plugins array. The plugin registers the rule automatically.","wrong":"const { deprecation } = require('eslint-plugin-deprecation')","symbol":"plugin","correct":"module.exports = { plugins: ['deprecation'], rules: { 'deprecation/deprecation': 'error' } }"},{"note":"The recommended config must be prefixed with 'plugin:' in the extends array. Omitting 'plugin:' will not resolve the config.","wrong":"extends: ['deprecation/recommended']","symbol":"Recommended Config","correct":"extends: ['plugin:deprecation/recommended']"},{"note":"The rule is namespaced under the plugin name. Use 'deprecation/deprecation' or 'deprecation/deprecation' in the rules object.","wrong":"rules: { 'deprecation': 'error' }","symbol":"Rule 'deprecation/deprecation'","correct":"rules: { 'deprecation/deprecation': 'error' }"}],"quickstart":{"code":"// Install dependencies:\n// npm install --save-dev eslint @typescript-eslint/parser typescript eslint-plugin-deprecation\n\n// .eslintrc.json\n{\n  \"parser\": \"@typescript-eslint/parser\",\n  \"parserOptions\": {\n    \"ecmaVersion\": 2020,\n    \"sourceType\": \"module\",\n    \"project\": \"./tsconfig.json\"\n  },\n  \"plugins\": [\"deprecation\"],\n  \"rules\": {\n    \"deprecation/deprecation\": \"error\"\n  }\n}\n\n// Example .ts file with a deprecated function:\n/** @deprecated Use newFunction instead. */\nfunction oldFunction() {}\n\noldFunction(); // ESLint will report: 'oldFunction' is deprecated. Use newFunction instead.","lang":"typescript","description":"Basic setup of ESLint with TypeScript parser and deprecation rule in .eslintrc.json, plus a TS file example showing the rule in action."},"warnings":[{"fix":"Upgrade to ESLint v8+ or downgrade eslint-plugin-deprecation to v2.0.0.","message":"Version 3.0.0 dropped support for ESLint v7. Projects still on ESLint v7 must stay on v2.x.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade ESLint to v7+ and TypeScript to v4.2+ or lock peer dependencies to v1.x.","message":"Version 2.0.0 dropped support for ESLint v6 and TypeScript <4.2. Users on older ESLint/TS must use v1.x.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use import or switch to ESM: `import deprecation from 'eslint-plugin-deprecation'`","message":"Using require() to load the plugin in CommonJS projects is still supported but will be removed in future major versions. Migrate to ESM or dynamic import().","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Set `'project': './tsconfig.json'` in parserOptions and ensure the tsconfig includes the files being linted.","message":"The rule requires TypeScript type information to work. If your ESLint config does not set 'project' in parserOptions, the rule will silently fail (not report anything).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Include declarations in tsconfig or use a declaration file that is part of the project.","message":"JSDoc @deprecated tags on ambient declarations (e.g., in .d.ts files) may not be detected if the type information is not loaded correctly. Ensure tsconfig includes ambient declarations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Avoid dynamic access to deprecated APIs or use a separate lint rule for dynamic cases.","message":"The rule does not check for deprecated usage in template literals or dynamic calls (e.g., `obj[deprecatedMethod]()`). Only static references are detected.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Ensure you have installed @typescript-eslint/utils >=6.0.0 (for v2+) or >=7.0.0 (for v3+). Run: npm install @typescript-eslint/utils --save-dev","cause":"Missing @typescript-eslint/utils dependency or incompatible version.","error":"TypeError: Cannot read properties of undefined (reading 'meta')"},{"fix":"Install the plugin: npm install eslint-plugin-deprecation --save-dev","cause":"Plugin not installed or not in node_modules.","error":"ESLint: Failed to load plugin 'deprecation' declared in '.eslintrc.json': Cannot find module 'eslint-plugin-deprecation'"},{"fix":"Add in .eslintrc.json: \"parserOptions\": { \"project\": \"./tsconfig.json\" }","cause":"Missing parserOptions.project required for TypeScript type-aware linting.","error":"Parsing error: The 'project' option in 'parserOptions' is not set. You must set it to a tsconfig.json path."},{"fix":"Set parserOptions.project as described above.","cause":"User did not configure TypeScript project path, causing the rule to be disabled.","error":"Warning: The 'deprecation/deprecation' rule requires type information, but you have not set 'parserOptions.project'. The rule will be skipped."},{"fix":"Add \"deprecation\" to the \"plugins\" array in your ESLint config.","cause":"The plugin is not listed in the 'plugins' array.","error":"Rule 'deprecation/deprecation' is not defined (ESLint configuration error)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}