Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/no-deprecated/
Description
I find it very useful to flag and address deprecated API usage during the dependency upgrade cycle. Whence I'd like to enforce the rule for the usage of my dependencies.
However, for my own code base I want to follow a gradual deprecation cycle, i.e. I want to introduce an updated API and inform users writing new code about the updated API via a @deprecated
JSDoc comment. Afterwards I'd phase the deprecated API out and remove it in the end.
The current rule is unsuited for the combined requirements, so I propose a boolean option ignoreUserDeprecations
.
Fail
/** @deprecated Use apiV2 instead. */
async function apiV1(): Promise<void> { /*…*/ }
async function apiV2(): Promise<void> { /*…*/ }
await apiV1();
/* >===================================< */
import { parse } from 'node:url';
// 'parse' is deprecated. Use the WHATWG URL API instead.
const url = parse('/foo');
Pass
/** @deprecated Use apiV2 instead. */
async function apiV1(): Promise<void> { /*…*/ }
async function apiV2(): Promise<void> { /*…*/ }
// apiV1 has been defined in the current code base and is therefore not flagged
await apiV1();
/* >===================================< */
// Modern Node.js API, uses `new URL()`
const url2 = new URL('/foo', 'http://www.example.com');
Additional Info
Originally proposed in the [no-deprecated] issue #8988 (comment)