-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Enhancement: [no-deprecated] Add 'allow' option for specific types or values #9899
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
What is the difference between "user code" and "dependency code"? We can't use the import path and say "it has to have a You can't even really say "it's in The key to considering this feature request is understanding how we can generically make this distinction. |
My initial suggestion would have solely been: Everything in the purview of the current typescript project is user code. Whereas purview is defined as the However, as you noted this falls flat for yarn/pnpm monorepos. So maybe it makes sense to additionally define a package name exclusion list (perhaps as a regex). If a package matches the list, it won't be considered as a source for deprecation annotations. This should be enough for monorepo use cases as their packages usually live under a common few prefixes. My initial suggestion also needs some further thought wrt unit tests. They usually live in a different typescript project and usually don't refer to the code under test by its official package name. The exclusion mechanism also needs to be based on information readily available to the linter, otherwise this'll likely result in an unacceptable performance hit. Given that I've no experience with this codebase, I can't make this judgement and would need some feedback with regards to my suggestions. Thanks for considering it! |
Idea 💡 - what if we just create an allowlist like for no-floating-promises? This gives users control over what to consider internal (or whether to allow specific externally deprecated types if they so choose) rather than forcing us to infer it. (more detailed docs for specifier format are on their way in #9587) |
I think this can be at least partially addressed by specifying different configurations for the rule applying to different files (at the eslint config level, rather than within the rule), right? |
The spec we designed was for ignoring specific types - we would need to extend it for values I believe. |
That does sound rather tedious, I'd prefer something less granular.
I had the following case in mind: The tests have their own |
+1 from me on using the TypeOrValueSpecifier format as previously used in |
Marking as |
Strong +1. Enabled it for several projects and there are many reasons for disabling the rule on a per-API basis:
|
This would be super useful to me right now in #10496. I want to deprecate our API externally, and gradually replace it internally. |
I'm also +1 on this. So given that we have three team members in favor and an internal use case, marking as accepting PRs. 🚀 |
Before You File a Proposal Please Confirm You Have Done The Following...
My proposal is suitable for this project
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
Pass
Additional Info
Originally proposed in the [no-deprecated] issue #8988 (comment)
The text was updated successfully, but these errors were encountered: