-
Notifications
You must be signed in to change notification settings - Fork 49
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
Rule proposal: prefer-t-throws
#156
Comments
Sounds like a good idea to me 👍. Not sure when/why try/catch makes sense in tests when t.throws is available. The second example is better, but FYI, using try {
await request(requestOptions);
t.fail();
} catch (error) {
t.true(error.statusCode === 500);
} |
Another idea for a lint rule. :-) |
👍 Sounds good. PR welcome :) I think |
Agreed |
no-try-catch
prefer-t-throws
What would be a valid use case for |
I think that |
@gajus Maybe something that might throw, but that you don't care about in the test, so you'd like to silence it. I'm sure there are other cases we can't think of too. But the main point is that the intent is clearer with |
The immediate valid use case for app.use(function * (next) {
try {
yield* next;
} catch (err) {
// handle error
}
}); |
Definitely agree with this. |
@IssueHunt has funded $80.00 to this issue.
|
I was reviewing some codes using ava and found this pattern repeating often:
This can be written instead as:
I think the latter should be preferred.
IssueHunt Summary
Backers (Total: $80.00)
Submitted pull Requests
prefer-t-throws
ruleBecome a backer now!
Or submit a pull request to get the deposits!
Tips
The text was updated successfully, but these errors were encountered: