UNPKG

eslint-plugin-de-morgan

Version:

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

44 lines (43 loc) 1.2 kB
import { UnaryExpression } from 'estree' import { Rule } from 'eslint' interface TransformOptions { /** * The type of logical expression to transform. */ expressionType: ExpressionType /** * Whether the transformed expression should be wrapped in parentheses. */ shouldWrapInParens: boolean /** * Whether a leading '!' may be stripped from already negated operands. */ canStripNegation: boolean /** * The ESLint rule context. */ context: Rule.RuleContext /** * The UnaryExpression node to transform. */ node: UnaryExpression } type ExpressionType = 'conjunction' | 'disjunction' /** * Transforms a negated logical expression according to De Morgan's law. Can * handle both conjunctions `(!(A && B) -> !A || !B)` and disjunctions `(!(A || * B) -> !A && !B)`. Preserves formatting, comments, and whitespace in the * transformed expression. * * @param options - The transformation options. * @returns The transformed expression or null if transformation is not * applicable. */ export declare function transform({ shouldWrapInParens, canStripNegation, expressionType, context, node, }: TransformOptions): string | null export {}