Closed Opened 3 years ago Closed 3 years ago

# Enable the no-cond-assign rule for eslint

Not set
normal

## Tracking

### ()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

## Attachments

### (1 file)

 59 bytes, text/x-review-board-request mossop : review+ Details
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)
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 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+
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