# deprecation

Rule `sonarjs/deprecation`. Deprecated APIs should not be used

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: yes
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1201 by reach, #502 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/deprecation` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-1874/) |

## Code examples

### Incorrect: the rule reports this

```js
export interface LanguageService {
  /**
  * @deprecated Use getEncodedSyntacticClassifications instead.
  */
  getSyntacticClassifications(fileName: string, span: TextSpan): ClassifiedSpan[];
}

const syntacticClassifications = getLanguageService().getSyntacticClassifications(file, span); // Noncompliant
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/deprecation": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/csrf](https://lintradar.dev/rules/sonarjs/csrf.md): CSRF protections should not be disabled
- [sonarjs/different-types-comparison](https://lintradar.dev/rules/sonarjs/different-types-comparison.md): Strict equality operators should not be used with dissimilar types
- [sonarjs/cors](https://lintradar.dev/rules/sonarjs/cors.md): Cross-Origin Resource Sharing (CORS) policy should be restricted to trusted origins
- [sonarjs/disabled-auto-escaping](https://lintradar.dev/rules/sonarjs/disabled-auto-escaping.md): Auto-escaping in HTML template engines should not be disabled
- [sonarjs/cookie-no-httponly](https://lintradar.dev/rules/sonarjs/cookie-no-httponly.md): Cookies should have the "HttpOnly" flag
- [sonarjs/disabled-resource-integrity](https://lintradar.dev/rules/sonarjs/disabled-resource-integrity.md): Remote artifacts should not be used without integrity checks

---

Web page: https://lintradar.dev/rules/sonarjs/deprecation. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
