Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.language

Assignment used as a conditional test

Control-flow conditions should compare values, not perform assignments.

#Metadata

Rule ID
ts.correctness.assignment-in-condition
Severity
medium
Confidence
0.9
Languages
javascript, typescript
Presets
recommended, strict
Stability
stable
Applies to
file
Tags
correctness, crq-cor-016, language, public-directory-parity, rules-catalog

#Why it matters

Using `=` where `===` was intended is a common defect; assignments in conditions also obscure data flow.

#Remediation

Use a comparison operator or move the assignment before the condition. Note that the parser may not preserve extra grouping parentheses around the assignment.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/typescript/ts.correctness.assignment-in-condition.rule.yaml.