eslint-plugin-ava icon indicating copy to clipboard operation
eslint-plugin-ava copied to clipboard

Prevent specifying error type in `t.notThrows()`

Open sindresorhus opened this issue 8 years ago • 4 comments

Issuehunt badges

It's an easy mistake to make if you have many t.throws() statements and then some t.notThrows() statements.

For example: https://github.com/sindresorhus/p-queue/commit/80e8e25926a6632d0429ebb526ee78a68f01d565

// Fail
t.notThrows(() => {
 t.pass();
}, TypeError);

// Ok
t.notThrows(() => {
 t.pass();
});

It should fail if it's a variable matching this regex: /^(?:[A-Z][a-z0-9]*)*Error$/


IssueHunt Summary

Backers (Total: $60.00)

Submitted pull Requests


Become a backer now!

Or submit a pull request to get the deposits!

Tips

sindresorhus avatar Sep 12 '17 05:09 sindresorhus

@novemberborn In AVA, I think we should assert it's a string or undefined at runtime. What do you think?

sindresorhus avatar Sep 12 '17 05:09 sindresorhus

@sindresorhus https://github.com/avajs/ava/issues/1125

novemberborn avatar Sep 17 '17 13:09 novemberborn

@issuehunt has funded $60.00 to this issue.


IssueHuntBot avatar May 02 '19 03:05 IssueHuntBot

@sindresorhus @novemberborn I tried to give it a shot please review and guide further. #240

rahgurung avatar May 03 '19 17:05 rahgurung