eslint-plugin-de-morgan
Version:
ESLint plugin for transforming negated boolean expressions via De Morgan’s laws
16 lines (15 loc) • 861 B
TypeScript
import { Rule } from 'eslint'
/**
* Checks whether the given expression is consumed only for its truthiness. In
* such positions — statement conditions, ternary tests, logical negation, or a
* discarded expression statement — replacing a strict boolean with any value of
* the same truthiness is observable-behavior preserving. The check climbs
* through `&&`/`||` chains, ternary branches, and trailing sequence positions,
* because those forward the value to their own consumer. Any other consumer
* (comparison, assignment, function argument, `return`, `??`, and so on) uses
* the value itself, so the function returns false there.
*
* @param node - The negated expression ESLint node to check.
* @returns True if only the truthiness of the expression is observable.
*/
export declare function isInTruthinessContext(node: Rule.Node): boolean