/
no-pending-tests.js
35 lines (31 loc) · 997 Bytes
/
no-pending-tests.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const createAstUtils = require('../util/ast');
module.exports = {
meta: {
type: 'suggestion',
docs: {
description: 'Disallow pending tests',
url: 'https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-pending-tests.md'
},
schema: []
},
create(context) {
const astUtils = createAstUtils(context.settings);
const isTestCase = astUtils.buildIsTestCaseAnswerer();
function isPendingMochaTest(node) {
return isTestCase(node) &&
node.arguments.length === 1 &&
node.arguments[0].type === 'Literal';
}
return {
CallExpression(node) {
if (node.callee && isPendingMochaTest(node)) {
context.report({
node,
message: 'Unexpected pending mocha test.'
});
}
}
};
}
};