github-pages-deploy-action/node_modules/eslint-plugin-jest/lib/rules/no-truthy-falsy.js

58 lines
1.1 KiB
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");
// todo: refactor into "ban-matchers"
var _default = (0, _utils.createRule)({
name: __filename,
meta: {
docs: {
category: 'Best Practices',
description: 'Disallow using `toBeTruthy()` & `toBeFalsy()`',
recommended: false
},
2020-05-24 22:59:46 +08:00
deprecated: true,
replacedBy: ['no-restricted-matchers'],
2020-03-07 11:45:40 +08:00
messages: {
2020-03-31 20:40:00 +08:00
avoidMatcher: 'Avoid {{ matcherName }}'
2020-03-07 11:45:40 +08:00
},
type: 'suggestion',
schema: []
},
defaultOptions: [],
create(context) {
return {
CallExpression(node) {
if (!(0, _utils.isExpectCall)(node)) {
return;
}
2020-03-31 20:40:00 +08:00
const {
matcher
} = (0, _utils.parseExpectCall)(node);
2020-03-07 11:45:40 +08:00
if (!matcher || !['toBeTruthy', 'toBeFalsy'].includes(matcher.name)) {
return;
}
context.report({
2020-03-31 20:40:00 +08:00
messageId: 'avoidMatcher',
node: matcher.node.property,
2020-03-07 11:45:40 +08:00
data: {
2020-03-31 20:40:00 +08:00
matcherName: matcher.name
}
2020-03-07 11:45:40 +08:00
});
}
};
}
});
exports.default = _default;