-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Rule proposal: Warn when deprecated APIs are used (eslint-plugin-deprecation) #8988
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Josh, I see that back in June, you reiterated that you wanted a core TSESLint member to work on this. However, in the meantime, TSESLint 8 was released, and In order to try and help, I implemented a short and sweet version of the rule, coming in at only 63 lines: My short version probably doesn't cover as many cases as the 298 line version created by luca-script, but it might be easier to maintain. Ultimately, I would just like some version the rule to exist in TSESLint sooner than later. Any thoughts? |
Yeah this is really painful 😬 I've had to disable the rule in my own projects and know a lot of other folks have had to choose between sticking with typescript-eslint 7 / ESLint 8 or losing the rule too, as you're saying. Edit: or, as @ST-DDT notes, using I actually started prototyping a reimplementation of the rule myself last week, but haven't had the time to get it to completion. The v8 release and other ESLint v9 compatibility work did a number on our schedules. #9783 has the work so far. It's on my todolist for this week to try to clean it up and get it in review. |
You can enable the rule using the eslint compatibility package. import { fixupPluginRules } from '@eslint/compat';
import eslintPluginDeprecation from 'eslint-plugin-deprecation';
...
{
plugins: {
deprecation:
// https://github.com/gund/eslint-plugin-deprecation/issues/78
// @ts-expect-error: Types aren't matching, but it works
fixupPluginRules(eslintPluginDeprecation),
},
rules: {
'deprecation/deprecation': 'error',
},
}, I would prefer a solution that works out of the box though. |
@JoshuaKGoldberg thanks for Feels quite a bit slower than |
I'm a bit late to the party, but would it be possible to add an option to differentiate between libraries and user code? I find it very useful to flag and address deprecated APIs during the dependency upgrade cycle, but if it flags deprecated APIs from my own code base the moment I annotate them as such, I'd effectively need to go ahead and remove the API entirely. Should I open a feature request for this? |
@BurningEnlightenment Yes, please open a new issue for a feature request. |
As per our contributing guidelines please open new issues for feature requests or bug reports. Or if you'd like to chat with us please visit our discord. |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
Description
Re-opening #1223: being able to lint against usage of an API marked as
@deprecated
is a common request for TypeScript developers. It was a TSLint rule back in those days, and now is provided primarily by https://github.com/gund/eslint-plugin-deprecation.eslint-plugin-deprecation
existing is why #1223 was closed by a docs change pointing folks externally.But! Since then:
eslint-plugin-deprecation
isn't 100% actively maintained, and has an issue template notice indicating its maintainer doesn't have the bandwidth to ramp up on it & actively fix issuesProposal: let's write a new implementation of a
deprecation
rule in this repo?Fail Cases
Pass Cases
Additional Info
Note that the licensing here is tricky. https://github.com/gund/eslint-plugin-deprecation includes the following README.md note:
...and is licensed under the GNU Lesser General Public License.
We need to be very sure that if this issue is accepted, any code added to our project is not based on the GNU license, and is at most licensed under MIT. If this is accepted, I think a member of the typescript-eslint team should work on it.
Other references of related licensed rules are:
cc @gund - you've done a great job for a while of keeping
eslint-plugin-deprecation
afloat ❤️. If you have any thoughts here, that'd be great.The text was updated successfully, but these errors were encountered: