For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/static_analysis/static_analysis_rules/javascript-best-practices/no-cond-assign.md.
A documentation index is available at /llms.txt.
This product is not supported for your selected Datadog site. ().
Metadata
ID:javascript-best-practices/no-cond-assign
Language: JavaScript
Severity: Error
Category: Best Practices
Description
While there might be valid reasons to use an assignment operation in a condition, it is very easy to mistake = with the more usual intended ==. This rule prevents such mistakes, as it is easier to intentionally disable the rule than identify the error.