github-pages-deploy-action/node_modules/eslint-plugin-jest/lib/rules/no-commented-out-tests.js

55 lines
1023 B
JavaScript
Raw Normal View History

2020-03-07 11:45:40 +08:00
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _utils = require("./utils");
function hasTests(node) {
2020-03-31 20:40:00 +08:00
return /^\s*[xf]?(test|it|describe)(\.\w+|\[['"]\w+['"]\])?\s*\(/mu.test(node.value);
2020-03-07 11:45:40 +08:00
}
var _default = (0, _utils.createRule)({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
2020-05-15 05:33:08 +08:00
description: 'Disallow commented out tests',
2020-07-14 01:09:22 +08:00
recommended: 'warn'
2020-03-07 11:45:40 +08:00
},
messages: {
commentedTests: 'Some tests seem to be commented'
},
schema: [],
type: 'suggestion'
},
defaultOptions: [],
create(context) {
const sourceCode = context.getSourceCode();
function checkNode(node) {
if (!hasTests(node)) {
return;
}
context.report({
messageId: 'commentedTests',
node
});
}
return {
Program() {
const comments = sourceCode.getAllComments();
comments.forEach(checkNode);
}
};
}
});
exports.default = _default;