Closed Bug 1578190 Opened 5 years ago Closed 5 years ago

Add a rule to enable linting for `!foo.length` and `if (foo.length)` over `if (foo.length == 0)` and `if (foo.length > 0)` etc.

Categories

(Developer Infrastructure :: Lint and Formatting, task, P3)

Tracking

(firefox71 fixed)

RESOLVED FIXED
mozilla71
Tracking Status
firefox71 --- fixed

People

(Reporter: standard8, Assigned: MonikaMaheshwari)

References

Details

Attachments

(1 file)

Branching out from bug 1552055 so that we can land the actual rule addition (but not enable it). See that bug for more discussion.

+++ This bug was initially created as a clone of Bug #1552055 +++

Our guidelines are fairly clear that if (!foo.length) is preferred over if (foo.length == 0) (and ditto for the "positive" ie non-0 length case), we should have an eslint rule (w/ --fix functionality) to enforce this.

Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/f9bcfe969f6b
Add a rule to ensure 'if(foo.length)' instead of 'foo.length>0'. r=Standard8
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla71
Blocks: 1588872
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: