Skip to content

Commit

Permalink
fix(bench): avoid bench being recognized consistent-test-it rule (#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
luxass authored Jul 16, 2024
1 parent 6f186a1 commit 32c02f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/rules/consistent-test-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ export default createEslintRule<
}
},
CallExpression(node: TSESTree.CallExpression) {
if (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === 'bench')
return
const vitestFnCall = parseVitestFnCall(node, context)

if (!vitestFnCall) return
Expand Down
8 changes: 7 additions & 1 deletion tests/consistent-test-it.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ ruleTester.run(RULE_NAME, rule, {
});
function myTest() { if ('bar') {} }`,
options: [{ fn: TestCaseName.it }]
}
},
{
code: `bench("foo", function () {
fibonacci(10);
})`,
options: [{ fn: TestCaseName.it }]
},
],
invalid: [
{
Expand Down

0 comments on commit 32c02f2

Please sign in to comment.