Skip to content

Commit 0713718

Browse files
committed
Revert "fix(no-done-callback): fix regression with it.each (#708)"
This reverts commit 2f032f8.
1 parent fe80f2f commit 0713718

File tree

2 files changed

+4
-63
lines changed

2 files changed

+4
-63
lines changed

src/rules/__tests__/no-done-callback.test.ts

-44
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ ruleTester.run('no-done-callback', rule, {
1515
'test("something", () => {})',
1616
'test("something", async () => {})',
1717
'test("something", function() {})',
18-
'test.each``("something", ({ a, b }) => {})',
19-
'test.each()("something", ({ a, b }) => {})',
20-
'it.each()("something", ({ a, b }) => {})',
21-
'it.each``("something", ({ a, b }) => {})',
2218
'test("something", async function () {})',
2319
'test("something", someArg)',
2420
'beforeEach(() => {})',
@@ -389,45 +385,5 @@ ruleTester.run('no-done-callback', rule, {
389385
},
390386
],
391387
},
392-
{
393-
code: 'test.each``("something", ({ a, b }, done) => { done(); })',
394-
errors: [
395-
{
396-
messageId: 'noDoneCallback',
397-
line: 1,
398-
column: 37,
399-
},
400-
],
401-
},
402-
{
403-
code: 'test.each()("something", ({ a, b }, done) => { done(); })',
404-
errors: [
405-
{
406-
messageId: 'noDoneCallback',
407-
line: 1,
408-
column: 37,
409-
},
410-
],
411-
},
412-
{
413-
code: 'it.each``("something", ({ a, b }, done) => { done(); })',
414-
errors: [
415-
{
416-
messageId: 'noDoneCallback',
417-
line: 1,
418-
column: 35,
419-
},
420-
],
421-
},
422-
{
423-
code: 'it.each()("something", ({ a, b }, done) => { done(); })',
424-
errors: [
425-
{
426-
messageId: 'noDoneCallback',
427-
line: 1,
428-
column: 35,
429-
},
430-
],
431-
},
432388
],
433389
});

src/rules/no-done-callback.ts

+4-19
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,11 @@ import {
22
AST_NODE_TYPES,
33
TSESTree,
44
} from '@typescript-eslint/experimental-utils';
5-
import {
6-
createRule,
7-
getNodeName,
8-
isFunction,
9-
isHook,
10-
isTestCase,
11-
} from './utils';
5+
import { createRule, isFunction, isHook, isTestCase } from './utils';
126

137
const findCallbackArg = (
148
node: TSESTree.CallExpression,
15-
isJestEach: boolean,
169
): TSESTree.CallExpression['arguments'][0] | null => {
17-
if (isJestEach) {
18-
return node.arguments[1];
19-
}
20-
2110
if (isHook(node) && node.arguments.length >= 1) {
2211
return node.arguments[0];
2312
}
@@ -52,21 +41,17 @@ export default createRule({
5241
create(context) {
5342
return {
5443
CallExpression(node) {
55-
// done is the second argument for it.each, not the first
56-
const isJestEach = getNodeName(node.callee)?.endsWith('.each') ?? false;
57-
58-
const callback = findCallbackArg(node, isJestEach);
59-
const callbackArgIndex = Number(isJestEach);
44+
const callback = findCallbackArg(node);
6045

6146
if (
6247
!callback ||
6348
!isFunction(callback) ||
64-
callback.params.length !== 1 + callbackArgIndex
49+
callback.params.length !== 1
6550
) {
6651
return;
6752
}
6853

69-
const argument = callback.params[callbackArgIndex];
54+
const [argument] = callback.params;
7055

7156
if (argument.type !== AST_NODE_TYPES.Identifier) {
7257
context.report({

0 commit comments

Comments
 (0)