Skip to content

Commit 154c0b8

Browse files
Belco90G-Rath
authored andcommittedNov 29, 2019
feat(no-focused-tests): check each with table format (#430)
1 parent 22d890f commit 154c0b8

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed
 

‎docs/rules/no-focused-tests.md

+14
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ test['only']('bar', () => {});
3232
fdescribe('foo', () => {});
3333
fit('foo', () => {});
3434
ftest('bar', () => {});
35+
fit.each`
36+
table
37+
`();
38+
ftest.each`
39+
table
40+
`();
3541
```
3642

3743
These patterns would not be considered warnings:
@@ -43,4 +49,12 @@ describe.skip('bar', () => {});
4349
it.skip('bar', () => {});
4450
test('foo', () => {});
4551
test.skip('bar', () => {});
52+
it.each()();
53+
it.each`
54+
table
55+
`();
56+
test.each()();
57+
test.each`
58+
table
59+
`();
4660
```

‎src/rules/__tests__/no-focused-tests.test.ts

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { TSESLint } from '@typescript-eslint/experimental-utils';
2+
import resolveFrom from 'resolve-from';
23
import rule from '../no-focused-tests';
34

4-
const ruleTester = new TSESLint.RuleTester();
5+
const ruleTester = new TSESLint.RuleTester({
6+
parser: resolveFrom(require.resolve('eslint'), 'espree'),
7+
parserOptions: {
8+
ecmaVersion: 6,
9+
},
10+
});
511

612
ruleTester.run('no-focused-tests', rule, {
713
valid: [
@@ -13,6 +19,10 @@ ruleTester.run('no-focused-tests', rule, {
1319
'test.skip()',
1420
'var appliedOnly = describe.only; appliedOnly.apply(describe)',
1521
'var calledOnly = it.only; calledOnly.call(it)',
22+
'it.each()()',
23+
'it.each`table`()',
24+
'test.each()()',
25+
'test.each`table`()',
1626
],
1727

1828
invalid: [
@@ -64,5 +74,13 @@ ruleTester.run('no-focused-tests', rule, {
6474
code: 'fit.each()',
6575
errors: [{ messageId: 'focusedTest', column: 1, line: 1 }],
6676
},
77+
{
78+
code: 'fit.each`table`()',
79+
errors: [{ messageId: 'focusedTest', column: 1, line: 1 }],
80+
},
81+
{
82+
code: 'ftest.each`table`()',
83+
errors: [{ messageId: 'focusedTest', column: 1, line: 1 }],
84+
},
6785
],
6886
});

‎src/rules/no-focused-tests.ts

+10
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ export default createRule({
7878
) {
7979
context.report({ messageId: 'focusedTest', node: callee });
8080
}
81+
82+
if (
83+
callee.type === AST_NODE_TYPES.TaggedTemplateExpression &&
84+
callee.tag.type === AST_NODE_TYPES.MemberExpression &&
85+
callee.tag.object &&
86+
callee.tag.object.type === AST_NODE_TYPES.Identifier &&
87+
isCallToFocusedTestFunction(callee.tag.object)
88+
) {
89+
context.report({ messageId: 'focusedTest', node: callee });
90+
}
8191
},
8292
}),
8393
});

0 commit comments

Comments
 (0)
Please sign in to comment.