Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork2.8k
feat(eslint-plugin): [no-deprecated] add rule#9783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
JoshuaKGoldberg merged 22 commits intotypescript-eslint:mainfromJoshuaKGoldberg:josh-wip-deprecationAug 21, 2024
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
22 commits Select commitHold shift + click to select a range
ddfc6bb
WIP: no-deprecation
JoshuaKGoldbergb1aa8d6
I think it's mostly there
JoshuaKGoldberg1a320a4
A couple small issues
JoshuaKGoldberg1faf836
Merge branch 'main' into josh-wip-deprecation
JoshuaKGoldbergb94a7f1
Start on docs
JoshuaKGoldberg7bd2242
Generated configs and ran tests
JoshuaKGoldberg18d6490
Remove deprecation/deprecation and disable ours as needed
JoshuaKGoldbergfcc6579
Remove deprecation/deprecation and disable ours as needed
JoshuaKGoldberg58904a2
updated inline comments
JoshuaKGoldbergcf34241
Fixed up call likes
JoshuaKGoldberg84817a6
Fixed up exports
JoshuaKGoldberg3b89fd4
The repo is passing now
JoshuaKGoldberg4bdbc1d
lil comment
JoshuaKGoldberg653ddd3
Merge branch 'main' into josh-wip-deprecation
JoshuaKGoldberg580860c
Apply suggestions from code review
JoshuaKGoldberg570b900
Update comments and Related To
JoshuaKGoldbergde9d81e
Merge branch 'main'
JoshuaKGoldbergd07bac6
yarn test -u
JoshuaKGoldberg0f4e484
Explicitly mention deprecated/deprecated
JoshuaKGoldberg80e116a
Merge branch 'main'
JoshuaKGoldberg8ec542b
no more see
JoshuaKGoldberg5cd8b82
Throw error for jsDocParsingMode
JoshuaKGoldbergFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
3 changes: 1 addition & 2 deletionsdocs/packages/TypeScript_ESLint.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletionseslint.config.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletionpackage.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletionspackages/eslint-plugin/TSLINT_RULE_ALTERNATIVES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletionspackages/eslint-plugin/docs/rules/no-deprecated.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
description: 'Disallow using code marked as `@deprecated`.' | ||
--- | ||
import Tabs from '@theme/Tabs'; | ||
import TabItem from '@theme/TabItem'; | ||
> 🛑 This file is source code, not the primary documentation location! 🛑 | ||
> | ||
> See **https://typescript-eslint.io/rules/no-deprecated** for documentation. | ||
The [JSDoc `@deprecated` tag](https://jsdoc.app/tags-deprecated) can be used to document some piece of code being deprecated. | ||
It's best to avoid using code marked as deprecated. | ||
This rule reports on any references to code marked as `@deprecated`. | ||
:::note | ||
[TypeScript recognizes the `@deprecated` tag](https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#deprecated) and visualizes deprecated code with a ~strikethrough~. | ||
However, TypeScript doesn't report type errors for deprecated code on its own. | ||
::: | ||
## Examples | ||
<Tabs> | ||
<TabItem value="❌ Incorrect"> | ||
```ts | ||
/** @deprecated Use apiV2 instead. */ | ||
declare function apiV1(): Promise<string>; | ||
declare function apiV2(): Promise<string>; | ||
await apiV1(); | ||
``` | ||
```ts | ||
import { parse } from 'node:url'; | ||
// 'parse' is deprecated. Use the WHATWG URL API instead. | ||
const url = parse('/foo'); | ||
``` | ||
</TabItem> | ||
<TabItem value="✅ Correct"> | ||
```ts | ||
/** @deprecated Use apiV2 instead. */ | ||
declare function apiV1(): Promise<string>; | ||
declare function apiV2(): Promise<string>; | ||
await apiV2(); | ||
``` | ||
```ts | ||
// Modern Node.js API, uses `new URL()` | ||
const url2 = new URL('/foo', 'http://www.example.com'); | ||
``` | ||
</TabItem> | ||
</Tabs> | ||
## When Not To Use It | ||
If portions of your project heavily use deprecated APIs and have no plan for moving to non-deprecated ones, you might want to disable this rule in those portions. | ||
## Related To | ||
- [`import/no-deprecated`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-deprecated.md) and [`import-x/no-deprecated`](https://github.com/un-ts/eslint-plugin-import-x/blob/master/docs/rules/no-deprecated.md): Does not use type information, but does also support [TomDoc](http://tomdoc.org) | ||
- [`eslint-plugin-deprecation`](https://github.com/gund/eslint-plugin-deprecation) ([`deprecation/deprecation`](https://github.com/gund/eslint-plugin-deprecation?tab=readme-ov-file#rules)): Predecessor to this rule in a separate plugin |
1 change: 1 addition & 0 deletionspackages/eslint-plugin/src/configs/all.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionspackages/eslint-plugin/src/configs/disable-type-checked.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionspackages/eslint-plugin/src/configs/strict-type-checked-only.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionspackages/eslint-plugin/src/configs/strict-type-checked.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionspackages/eslint-plugin/src/rules/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.