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
Add rule require-throws
#574
Conversation
|
||
const tagName = utils.getPreferredTagName({tagName: 'throws'}); | ||
if (!tagName) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to cover this case in a test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be enough to add a (passing) example which doesn't have @throws
at all (or where it has @throws
but settings.jsdoc.tagNamePreference
is set to map throws
to something else like throw
and if @throw
wasn't present).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only line that I can't figure out how to cover. I feel like it should be covered by this test, but it seems like I'm not understanding how utils.getPreferredTagName()
is working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, I've added the test (it was setting throws
to false
on tagNamePreference
settings, i.e., if someone had indicated they wished to block the throws
tag yet were still using this rule. :)
I think it looked good, but need a little more time to give it another look over before merging.
@brettz9 , does this look like I'm on the right track? |
Looks very good from a quick look! |
* master: fix(check-param-names, require-param): handle ts constructor as arg; fixes #576 fix(`check-param-names`): destructured parameters inclusion check (params containing other params as substrings); closes #575 Revert "Fix bug with destructured parameters in check-param-names" Fix bug with destructured parameters in check-param-names
@brettz9 , thanks for adding the missing test! I'll know for next time to add a case where the tag is given in the JSDoc but should not be. |
Great work, thanks! |
🎉 This PR is included in version 27.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This adds a new rule
require-throws
, that requires a@throws
statement in the JSDoc if the function body contains thethrow
keyword.I based this off of
require-returns
, as suggested in #566