Skip to content

Commit df73870

Browse files
committed
Improve no-hooks-for-single-case performance
1 parent 1b73ddb commit df73870

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/rules/no-hooks-for-single-case.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ module.exports = {
3232
},
3333
create(context) {
3434
const astUtils = createAstUtils(context.settings);
35+
const isTestCase = astUtils.buildIsTestCaseAnswerer();
36+
const isDescribe = astUtils.buildIsDescribeAnswerer();
37+
3538
const options = context.options[0] || {};
3639
const allowedHooks = options.allow || [];
3740
let layers = [];
@@ -57,7 +60,7 @@ module.exports = {
5760
.forEach(function (hookNode) {
5861
context.report({
5962
node: hookNode,
60-
message: `Unexpected use of Mocha \`${ hookNode.name }\` hook for a single test case`
63+
message: `Unexpected use of Mocha \`${hookNode.name}\` hook for a single test case`
6164
});
6265
});
6366
}
@@ -71,13 +74,13 @@ module.exports = {
7174
},
7275

7376
CallExpression(node) {
74-
if (astUtils.isDescribe(node)) {
77+
if (isDescribe(node)) {
7578
increaseTestCount();
7679
layers.push(newDescribeLayer(node));
7780
return;
7881
}
7982

80-
if (astUtils.isTestCase(node)) {
83+
if (isTestCase(node)) {
8184
increaseTestCount();
8285
}
8386

0 commit comments

Comments
 (0)