What it flags
A JS/TS function reaches a score of 15.How to review or fix
Start at one and count each conditional, loop, switch, catch or ternary. A flat switch contributes one decision. When most of a function’s decisions are plain bail-outs (anif with no else that only returns, throws, continues or breaks, at the top of the body), up to twelve of them count half toward the 15 and any further ones count in full, so a function made only of such guards is reported from twenty guards on. The reported score is still the plain count.
Inline fix
Combines nested conditional expressions with the same literal success label while preserving short-circuit order. Other fixes merge nestedifs, join adjacent same-exit ifs with ||, turn x ? true : false into Boolean(x), and if (!x) x = value into x ||= value.
Configuration
Set the rule to"off" in loadwise.config.json to drop its findings:
level and options sets the rule’s threshold. It takes a maxComplexity option, a positive integer. The rule then reports a function whose weighted score is above maxComplexity. Without the option, it reports from a weighted score of 15.
level is required: "warn" reports findings without changing the exit code. An overrides entry can set different options for the files it matches, and its options win over the top-level ones.