Skip to content

Commit 4ea5673

Browse files
authored
fix(no-alias-methods): Align no-alias-methods rule with Vitest by aliasing toThrow to toThrowError (#832)
* fix: no-alias-methods mapping to treat toThrow as alias of toThrowError * test: update tests
1 parent fb2b134 commit 4ea5673

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/rules/no-alias-methods.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default createEslintRule<Options, MESSAGE_ID>({
3838
toReturnWith: 'toHaveReturnedWith',
3939
lastReturnedWith: 'toHaveLastReturnedWith',
4040
nthReturnedWith: 'toHaveNthReturnedWith',
41-
toThrowError: 'toThrow',
41+
toThrow: 'toThrowError',
4242
}
4343

4444
return {

tests/no-alias-methods.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ruleTester.run(RULE_NAME, rule, {
1313
'expect(a).toHaveReturnedWith()',
1414
'expect(a).toHaveLastReturnedWith()',
1515
'expect(a).toHaveNthReturnedWith()',
16-
'expect(a).toThrow()',
16+
'expect(a).toThrowError()',
1717
'expect(a).rejects;',
1818
'expect(a);',
1919
],
@@ -49,14 +49,14 @@ ruleTester.run(RULE_NAME, rule, {
4949
],
5050
},
5151
{
52-
code: 'expect(a).not["toThrowError"]()',
53-
output: "expect(a).not['toThrow']()",
52+
code: 'expect(a).not["toThrow"]()',
53+
output: "expect(a).not['toThrowError']()",
5454
errors: [
5555
{
5656
messageId: 'noAliasMethods',
5757
data: {
58-
alias: 'toThrowError',
59-
canonical: 'toThrow',
58+
alias: 'toThrow',
59+
canonical: 'toThrowError',
6060
},
6161
column: 15,
6262
line: 1,

0 commit comments

Comments
 (0)