Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
22 commits
Select commitHold shift + click to select a range
ddfc6bb
WIP: no-deprecation
JoshuaKGoldbergAug 5, 2024
b1aa8d6
I think it's mostly there
JoshuaKGoldbergAug 15, 2024
1a320a4
A couple small issues
JoshuaKGoldbergAug 15, 2024
1faf836
Merge branch 'main' into josh-wip-deprecation
JoshuaKGoldbergAug 15, 2024
b94a7f1
Start on docs
JoshuaKGoldbergAug 15, 2024
7bd2242
Generated configs and ran tests
JoshuaKGoldbergAug 15, 2024
18d6490
Remove deprecation/deprecation and disable ours as needed
JoshuaKGoldbergAug 15, 2024
fcc6579
Remove deprecation/deprecation and disable ours as needed
JoshuaKGoldbergAug 15, 2024
58904a2
updated inline comments
JoshuaKGoldbergAug 15, 2024
cf34241
Fixed up call likes
JoshuaKGoldbergAug 15, 2024
84817a6
Fixed up exports
JoshuaKGoldbergAug 15, 2024
3b89fd4
The repo is passing now
JoshuaKGoldbergAug 16, 2024
4bdbc1d
lil comment
JoshuaKGoldbergAug 16, 2024
653ddd3
Merge branch 'main' into josh-wip-deprecation
JoshuaKGoldbergAug 19, 2024
580860c
Apply suggestions from code review
JoshuaKGoldbergAug 19, 2024
570b900
Update comments and Related To
JoshuaKGoldbergAug 19, 2024
de9d81e
Merge branch 'main'
JoshuaKGoldbergAug 20, 2024
d07bac6
yarn test -u
JoshuaKGoldbergAug 20, 2024
0f4e484
Explicitly mention deprecated/deprecated
JoshuaKGoldbergAug 20, 2024
80e116a
Merge branch 'main'
JoshuaKGoldbergAug 20, 2024
8ec542b
no more see
JoshuaKGoldbergAug 21, 2024
5cd8b82
Throw error for jsDocParsingMode
JoshuaKGoldbergAug 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletionsdocs/packages/TypeScript_ESLint.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -254,8 +254,7 @@ export default tseslint.config({
extends: [tseslint.configs.disableTypeChecked],
rules: {
// turn off other type-aware rules
'deprecation/deprecation': 'off',
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',
'other-plugin/typed-rule': 'off',

// turn off rules that don't apply to JS code
'@typescript-eslint/explicit-function-return-type': 'off',
Expand Down
8 changes: 0 additions & 8 deletionseslint.config.mjs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,6 @@ import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import eslint from '@eslint/js';
import tseslintInternalPlugin from '@typescript-eslint/eslint-plugin-internal';
import deprecationPlugin from 'eslint-plugin-deprecation';
import eslintCommentsPlugin from 'eslint-plugin-eslint-comments';
import eslintPluginPlugin from 'eslint-plugin-eslint-plugin';
import importPlugin from 'eslint-plugin-import';
Expand All@@ -32,9 +31,6 @@ export default tseslint.config(
plugins: {
['@typescript-eslint']: tseslint.plugin,
['@typescript-eslint/internal']: tseslintInternalPlugin,
// https://github.com/gund/eslint-plugin-deprecation/issues/78
// https://github.com/typescript-eslint/typescript-eslint/issues/8988
['deprecation']: fixupPluginRules(deprecationPlugin),
['eslint-comments']: eslintCommentsPlugin,
['eslint-plugin']: eslintPluginPlugin,
// https://github.com/import-js/eslint-plugin-import/issues/2948
Expand DownExpand Up@@ -96,9 +92,6 @@ export default tseslint.config(
},
linterOptions: { reportUnusedDisableDirectives: 'error' },
rules: {
// make sure we're not leveraging any deprecated APIs
'deprecation/deprecation': 'error',

// TODO: https://github.com/typescript-eslint/typescript-eslint/issues/8538
'@typescript-eslint/no-confusing-void-expression': 'off',

Expand DownExpand Up@@ -335,7 +328,6 @@ export default tseslint.config(
extends: [tseslint.configs.disableTypeChecked],
rules: {
// turn off other type-aware rules
'deprecation/deprecation': 'off',
'@typescript-eslint/internal/no-poorly-typed-ts-props': 'off',

// turn off rules that don't apply to JS code
Expand Down
1 change: 0 additions & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,7 +93,6 @@
"cspell": "^8.6.1",
"downlevel-dts": ">=0.11.0",
"eslint": "^9.3.0",
"eslint-plugin-deprecation": "^2.0.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-eslint-plugin": "^6.2.0",
"eslint-plugin-import": "^2.29.1",
Expand Down
3 changes: 1 addition & 2 deletionspackages/eslint-plugin/TSLINT_RULE_ALTERNATIVES.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -122,7 +122,7 @@ It lists all TSLint rules along side rules from the ESLint ecosystem that are th
| TSLint rule | | ESLint rule |
| ---------------------------- | :-: | -------------------------------------------------- |
| [`cyclomatic-complexity`] | 🌟 | [`complexity`][complexity] |
| [`deprecation`] |🔌 | [`deprecation/deprecation`] |
| [`deprecation`] | | [`@typescript-eslint/no-deprecated`] |
| [`eofline`] | 🌟 | [`eol-last`][eol-last] |
| [`indent`] | ✅ | [`@typescript-eslint/indent`] or [Prettier] |
| [`linebreak-style`] | 🌟 | [`linebreak-style`][linebreak-style] or [Prettier] |
Expand DownExpand Up@@ -724,5 +724,4 @@ Relevant plugins: [`chai-expect-keywords`](https://github.com/gavinaiken/eslint-
[`jest/no-focused-tests`]: https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/no-focused-tests.md
[`jsx-a11y/heading-has-content`]: https://github.com/evcohen/eslint-plugin-jsx-a11y/blob/master/docs/rules/heading-has-content.md
[`lodash/chaining`]: https://github.com/wix/eslint-plugin-lodash/blob/master/docs/rules/chaining.md
[`deprecation/deprecation`]: https://github.com/gund/eslint-plugin-deprecation
[`desktop/insecure-random`]: https://github.com/desktop/desktop/blob/development/eslint-rules/insecure-random.js
69 changes: 69 additions & 0 deletionspackages/eslint-plugin/docs/rules/no-deprecated.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -46,6 +46,7 @@ export = {
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-non-null-assertion': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-deprecated': 'error',
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,6 +18,7 @@ export = {
'@typescript-eslint/no-array-delete': 'off',
'@typescript-eslint/no-base-to-string': 'off',
'@typescript-eslint/no-confusing-void-expression': 'off',
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/no-duplicate-type-constituents': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-for-in-array': 'off',
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -14,6 +14,7 @@ export = {
'@typescript-eslint/no-array-delete': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-deprecated': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-for-in-array': 'error',
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -20,6 +20,7 @@ export = {
'@typescript-eslint/no-array-delete': 'error',
'@typescript-eslint/no-base-to-string': 'error',
'@typescript-eslint/no-confusing-void-expression': 'error',
'@typescript-eslint/no-deprecated': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-duplicate-type-constituents': 'error',
'@typescript-eslint/no-dynamic-delete': 'error',
Expand Down
2 changes: 2 additions & 0 deletionspackages/eslint-plugin/src/rules/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,7 @@ import noArrayDelete from './no-array-delete';
import noBaseToString from './no-base-to-string';
import confusingNonNullAssertionLikeNotEqual from './no-confusing-non-null-assertion';
import noConfusingVoidExpression from './no-confusing-void-expression';
import noDeprecated from './no-deprecated';
import noDupeClassMembers from './no-dupe-class-members';
import noDuplicateEnumValues from './no-duplicate-enum-values';
import noDuplicateTypeConstituents from './no-duplicate-type-constituents';
Expand DownExpand Up@@ -157,6 +158,7 @@ export default {
'no-base-to-string': noBaseToString,
'no-confusing-non-null-assertion': confusingNonNullAssertionLikeNotEqual,
'no-confusing-void-expression': noConfusingVoidExpression,
'no-deprecated': noDeprecated,
'no-dupe-class-members': noDupeClassMembers,
'no-duplicate-enum-values': noDuplicateEnumValues,
'no-duplicate-type-constituents': noDuplicateTypeConstituents,
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp