eslint-plugin-sonarjs
Version:
17 lines (16 loc) • 667 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExpectChain = getExpectChain;
const ast_js_1 = require("../helpers/ast.js");
function getExpectChain(node) {
if (node.type === 'MemberExpression' && !node.computed && (0, ast_js_1.isIdentifier)(node.property, 'not')) {
const chain = getExpectChain(node.object);
return chain ? { ...chain, negated: !chain.negated } : null;
}
if (node.type !== 'CallExpression' ||
!(0, ast_js_1.isIdentifier)(node.callee, 'expect') ||
node.arguments.length !== 1) {
return null;
}
return { actual: node.arguments[0], negated: false };
}