# Enable the no-cond-assign rule for eslint

RESOLVED FIXED in Firefox 53

RESOLVED FIXED
2 years ago
2 years ago

unspecified
mozilla53
Points:
---

## Attachments

### (1 attachment)

 59 bytes, text/x-review-board-request mossop : review+ Details
(Assignee)

### Description

2 years ago
There are six errors found with this rule enabled. This rule disallows assignment in conditionals. One of the errors found is a bug (advanced.js).

231:9   error  Expected a conditional expression and instead saw an assignment.  no-cond-assign (eslint)

1019:30  error  Expected a conditional expression and instead saw an assignment.                                             no-cond-assign (eslint)

344:14  error  Expected a conditional expression and instead saw an assignment.  no-cond-assign (eslint)

c:\fx\toolkit\components\places\ClusterLib.js
88:12  error  Expected a conditional expression and instead saw an assignment.  no-cond-assign (eslint)

461:17  error  Expected a conditional expression and instead saw an assignment.                                             no-cond-assign (eslint)

c:\fx\toolkit\mozapps\extensions\test\xpcshell\test_plugins.js
75:10  error  Expected a conditional expression and instead saw an assignment.  no-cond-assign (eslint)
 Comment hidden (mozreview-request)
(Assignee)

### Comment 2

2 years ago
I'm not a fan of surrounding the assignments with parentheses in these cases, but it is a somewhat established convention to explicitly state that these are intentional and I didn't want to spend a bunch of time refactoring this away from these assignments-in-conditionals.

### Comment 3

2 years ago
mozreview-review
Comment on attachment 8823954 [details]
Bug 1328805 - Enable the no-cond-assign rule for eslint and fix the six resulting errors mostly by wrapping the assignment with parentheses to explicitly state that the assignment is intentional with exception for advanced.js where assignment was not inte

https://reviewboard.mozilla.org/r/102438/#review102982

(Diff revision 1)
>    /**
>     * When the user toggles the layers.acceleration.disabled pref,
>     * sync its new value to the gfx.direct2d.disabled pref too.
>     */
>    updateHardwareAcceleration() {
> -    if (AppConstants.platform = "win") {
> +    if (AppConstants.platform == "win") {

My heart warms everytime eslint catches an error
Attachment #8823954 - Flags: review?(dtownsend) → review+

### Comment 4

2 years ago
Pushed by jwein@mozilla.com:
Enable the no-cond-assign rule for eslint and fix the six resulting errors mostly by wrapping the assignment with parentheses to explicitly state that the assignment is intentional with exception for advanced.js where assignment was not intended. r=mossop
https://hg.mozilla.org/mozilla-central/rev/51adf5284d7c