From 9a6ce6c77337a20260e225bb39dae10ffa8949f1 Mon Sep 17 00:00:00 2001 From: Jack Franklin Date: Tue, 16 Oct 2018 09:24:48 +0100 Subject: [PATCH] fix(prefer-expect-assertions): fix greedy regex --- rules/__tests__/prefer-expect-assertions.test.js | 2 ++ rules/prefer-expect-assertions.js | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/rules/__tests__/prefer-expect-assertions.test.js b/rules/__tests__/prefer-expect-assertions.test.js index ad5396cd1..e7a5d9989 100644 --- a/rules/__tests__/prefer-expect-assertions.test.js +++ b/rules/__tests__/prefer-expect-assertions.test.js @@ -87,5 +87,7 @@ ruleTester.run('prefer-expect-assertions', rule, { '\n\t\t\texpect(someValue).toBe(true)\n' + '\t\t\t})', 'test("it1")', + 'itHappensToStartWithIt("foo", function() {})', + 'testSomething("bar", function() {})', ], }); diff --git a/rules/prefer-expect-assertions.js b/rules/prefer-expect-assertions.js index cac04f9a9..99b8949a5 100644 --- a/rules/prefer-expect-assertions.js +++ b/rules/prefer-expect-assertions.js @@ -54,7 +54,7 @@ module.exports = { }, create(context) { return { - 'CallExpression[callee.name=/^it|test$/][arguments.1.body.body]'(node) { + 'CallExpression[callee.name=/^(it|test)$/][arguments.1.body.body]'(node) { const testFuncBody = node.arguments[1].body.body; if (!isFirstLineExprStmt(testFuncBody)) {