Skip to content

Commit c8ddcc3

Browse files
GMartignynovemberborn
authored andcommitted
Guard direct function calls in prefer-t-regex
Fix #251
1 parent 32b45c0 commit c8ddcc3

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

rules/prefer-t-regex.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const create = context => {
3737

3838
// First argument is a call expression
3939
const isFunctionCall = firstArg.type === 'CallExpression';
40-
if (!isFunctionCall) {
40+
if (!isFunctionCall || !firstArg.callee.property) {
4141
return;
4242
}
4343

test/prefer-t-regex.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ ruleTester.run('prefer-t-regex', rule, {
2323
header + 'test(t => t.true(foo.bar()));',
2424
header + 'const a = /\\d+/;\ntest(t => t.truthy(a));',
2525
header + 'const a = "not a regexp";\ntest(t => t.true(a.test("foo")));',
26+
header + 'test("main", t => t.true(foo()));',
2627
// Shouldn't be triggered since it's not a test file
2728
'test(t => t.true(/\\d+/.test("foo")));'
2829
],

0 commit comments

Comments
 (0)