Skip to content

Commit ad8174b

Browse files
y-hsgwveritem
andauthored
chore(prefer-called-exactly-once-with): clarify message (#792)
* chore: clarify prefer-called-exactly-once-with rule message * test: update test * Update src/rules/prefer-called-exactly-once-with.ts * Update src/rules/prefer-called-exactly-once-with.ts * update lines --------- Co-authored-by: Verité Mugabo <[email protected]>
1 parent 6ee7112 commit ad8174b

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

src/rules/prefer-called-exactly-once-with.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
145145
},
146146
messages: {
147147
preferCalledExactlyOnceWith:
148-
'Prefer {{matcherName}} (/* expected args */)',
148+
'Using `toHaveBeenCalledOnce` and `toHaveBeenCalledWith` on the same target; prefer `toHaveBeenCalledExactlyOnceWith` instead.',
149149
},
150150
type: 'suggestion',
151151
fixable: 'code',
@@ -217,8 +217,7 @@ export default createEslintRule<Options, MESSAGE_IDS>({
217217
if (!targetNode) continue
218218

219219
const { callExpression: firstCallExpression } = firstMatcherReference
220-
const { callExpression: secondCallExpression, matcherName } =
221-
secondMatcherReference
220+
const { callExpression: secondCallExpression } = secondMatcherReference
222221

223222
if (
224223
hasMockResetBetween(body, firstCallExpression, secondCallExpression)
@@ -228,7 +227,6 @@ export default createEslintRule<Options, MESSAGE_IDS>({
228227
context.report({
229228
messageId: 'preferCalledExactlyOnceWith',
230229
node: targetNode,
231-
data: { matcherName },
232230
fix(fixer) {
233231
const indentation = sourceCode.text.slice(
234232
firstCallExpression.parent.range[0],

tests/prefer-called-exactly-once-with.test.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ ruleTester.run(RULE_NAME, rule, {
5757
errors: [
5858
{
5959
messageId: 'preferCalledExactlyOnceWith',
60-
data: { matcherName: 'toHaveBeenCalledWith' },
6160
column: 17,
6261
line: 3,
6362
},
@@ -74,7 +73,6 @@ ruleTester.run(RULE_NAME, rule, {
7473
errors: [
7574
{
7675
messageId: 'preferCalledExactlyOnceWith',
77-
data: { matcherName: 'toHaveBeenCalledOnce' },
7876
column: 17,
7977
line: 3,
8078
},
@@ -91,7 +89,6 @@ ruleTester.run(RULE_NAME, rule, {
9189
errors: [
9290
{
9391
messageId: 'preferCalledExactlyOnceWith',
94-
data: { matcherName: 'toHaveBeenCalledOnce' },
9592
column: 17,
9693
line: 3,
9794
},
@@ -110,7 +107,6 @@ ruleTester.run(RULE_NAME, rule, {
110107
errors: [
111108
{
112109
messageId: 'preferCalledExactlyOnceWith',
113-
data: { matcherName: 'toHaveBeenCalledOnce' },
114110
column: 19,
115111
line: 4,
116112
},
@@ -131,13 +127,11 @@ ruleTester.run(RULE_NAME, rule, {
131127
errors: [
132128
{
133129
messageId: 'preferCalledExactlyOnceWith',
134-
data: { matcherName: 'toHaveBeenCalledOnce' },
135130
column: 17,
136131
line: 3,
137132
},
138133
{
139134
messageId: 'preferCalledExactlyOnceWith',
140-
data: { matcherName: 'toHaveBeenCalledOnce' },
141135
column: 17,
142136
line: 5,
143137
},
@@ -156,7 +150,6 @@ ruleTester.run(RULE_NAME, rule, {
156150
errors: [
157151
{
158152
messageId: 'preferCalledExactlyOnceWith',
159-
data: { matcherName: 'toHaveBeenCalledOnce' },
160153
column: 17,
161154
line: 4,
162155
},
@@ -175,7 +168,6 @@ ruleTester.run(RULE_NAME, rule, {
175168
errors: [
176169
{
177170
messageId: 'preferCalledExactlyOnceWith',
178-
data: { matcherName: 'toHaveBeenCalledWith' },
179171
column: 17,
180172
line: 4,
181173
},

0 commit comments

Comments
 (0)