UNPKG

eslint-plugin-de-morgan

Version:

ESLint plugin for transforming negated boolean expressions via De Morgan’s laws

37 lines (36 loc) 982 B
'use strict' Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }) let hasBooleanContext = node => node.parent ? isControlFlowBooleanContext(node.parent) || isComparison(node.parent) || isBooleanFunction(node.parent) : false let isControlFlowBooleanContext = parent => booleanControlFlowNodes.has(parent.type) let booleanControlFlowNodes = /* @__PURE__ */ new Set([ 'ConditionalExpression', 'LogicalExpression', 'DoWhileStatement', 'UnaryExpression', 'WhileStatement', 'ForStatement', 'IfStatement', ]) let isComparison = parent => parent.type === 'BinaryExpression' && comparisonOperators.has(parent.operator) let comparisonOperators = /* @__PURE__ */ new Set([ '===', '!==', '==', '!=', '<=', '>=', '<', '>', ]) let isBooleanFunction = parent => parent.type === 'CallExpression' && parent.callee.type === 'Identifier' && parent.callee.name === 'Boolean' exports.hasBooleanContext = hasBooleanContext