Regular expressions with the v flag support character class set operations like intersection (&&) and subtraction (--).
This rule identifies patterns where these set operations can be simplified using De Morgan’s laws.
The rule detects four types of simplifications:
Intersection to subtraction: [a&&[^b]] becomes [a--b]
Subtraction to intersection: [a--[^b]] becomes [a&&b]
Negation of disjunction: [[^a]&&[^b]] becomes [^ab]
Negation of conjunction: [[^a][^b]] becomes [^a&&b]
If you prefer the explicit form of set operations with negated operands, or if your codebase needs to support older JavaScript engines that don’t fully support the v flag, you may want to disable this rule.