UNPKG

eslint-plugin-sonarjs

Version:
34 lines (33 loc) 1.23 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getChaiPropertyPredicate = getChaiPropertyPredicate; exports.getArgumentAtIndex = getArgumentAtIndex; function getChaiPropertyPredicate(name) { switch (name) { case 'ok': return { predicate: 'truthy', negated: false }; // chai's `.true`/`.false` are strict (`=== true`/`=== false`), unlike `.ok`, which accepts // any truthy/falsy value case 'true': return { predicate: 'true', negated: false }; case 'false': return { predicate: 'false', negated: false }; case 'null': return { predicate: 'null', negated: false }; case 'undefined': return { predicate: 'undefined', negated: false }; // chai's `.exist` is stricter than "defined": it requires not-null AND not-undefined case 'exist': case 'exists': return { predicate: 'exists', negated: false }; default: return null; } } function getArgumentAtIndex(node, index) { const argument = node.arguments[index]; if (!argument || argument.type === 'SpreadElement') { return null; } return argument; }