Closed Bug 1322954 Opened 9 years ago Closed 9 years ago

Fix unsafe `instanceof` negations

Categories

(Toolkit :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: lina, Assigned: lina)

Details

Attachments

(2 files)

Some of our modules use the pattern `!value instanceof Class`, to check if `value` is not an instance of `Class`. This isn't quite right: `!` binds tighter than `instanceof`, so that will evaluate to `false instanceof Class`...which will always be false (https://github.com/DavidBruant/ECMAScript-regrets/issues/27). We need an extra set of parens to make this work: `!(value instanceof Class)`.
Comment on attachment 8817932 [details] Bug 1322954 - Fix incorrect `instanceof` negations. https://reviewboard.mozilla.org/r/98100/#review98410 wow - it's scary how often we weren't checking what we thought we were checking!
Attachment #8817932 - Flags: review?(markh) → review+
Comment on attachment 8817933 [details] Bug 1322954 - Replace deprecated `no-negated-in-lhs` ESLint option with `no-unsafe-negation`. https://reviewboard.mozilla.org/r/98102/#review98412 This looks great, but will require another try.
Attachment #8817933 - Flags: review?(markh) → review+
Pushed by kcambridge@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4d6f11e28343 Fix incorrect `instanceof` negations. r=markh https://hg.mozilla.org/integration/autoland/rev/2c1d9731a014 Replace deprecated `no-negated-in-lhs` ESLint option with `no-unsafe-negation`. r=markh
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: