Open Bug 1409693 Opened 8 years ago Updated 3 years ago

[eslint] Investigate turning on no-unused-expressions

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement, P2)

enhancement

Tracking

(Not tracked)

People

(Reporter: standard8, Unassigned)

References

Details

no-unused-expressions can catch a few issues in the code, that generally are bugs or could lead to strict warnings. Although we do invoke various properties for side-effects intentionally, I think it is probably worth turning this on anyway, as it will highlight those. As an initial stab, it seems we'll want this in recommended.js: "no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }],
Depends on: 1409694
Product: Testing → Firefox Build System
Depends on: 1502309
Depends on: 1502312
I took another look at this today. First an update config: + "no-unused-expressions": ["error", { + "allowShortCircuit": true, + "allowTaggedTemplates": true, + "allowTernary": true, + }], With this, there's about 200 errors. The majority of these are false positives. There's a few actual issues which I'll file as blockers as I get time, though the more worrying bugs are already filed. Of the false positives, there's a lot of places where we do `element.clientTop` or similar to force a layout flush or hooking up of xbl. For those we probably want to think about if we could have a utility function, e.g. forceFlush(element), so that this is explicit in the code, and then ESLint doesn't warn about it. For other intentional things we could just do // eslint-disable-next-line no-unused-expressions or similar. The few things we have caught make me think it is worth moving on this at some stage.
Priority: P3 → P2
Version: Version 3 → 3 Branch
Summary: Investigate turning on no-unused-expressions → [eslint] Investigate turning on no-unused-expressions
Version: 3 Branch → unspecified

Recent example found by coverity: https://bugzilla.mozilla.org/show_bug.cgi?id=1662769
Probably saved some time for devs

Product: Firefox Build System → Developer Infrastructure
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.