feat: add ban-untagged-deprecation rule #1373
Open
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.
Fixes: #1266
Considerations
1. Warning Range
Using the
Comment#range
method would apply warnings to the entire block comment, which isn’t ideal. So instead, the implementation now focuses on issuing warnings only for the specific target range.For example, in the following file (example.ts):
The warning highlights only the
@deprecated
tag and the trailing whitespace:One concern is that while the starting position of the warning is checked in tests using
assert_lint_err
, the ending position isn’t explicitly covered. If you have ideas on improving this test coverage, or think this behavior could be better, I’d love to hear your thoughts!2. Valid JSDoc (TSDoc) Tags
Since the spec doesn’t seem to clearly define the syntax, I tried testing what the TSDoc Playground recognizes as valid tags. At least, the current behavior matches the following cases. If you think there’s room for improvement here, I’d love to hear your feedback!
Recognized as Valid Tags:
Not Recognized as Valid Tags:
3. Behavior with Multiple
@deprecated
TagsWhen multiple
@deprecated
tags are present, it seems that TSDoc only recognizes the last one as valid. However, designing the linter to appropriately check only the last tag would have made the logic unnecessarily complex, so the linter is implemented to check all@deprecated
tags instead.