Enable the no-sparse-arrays rule for eslint

RESOLVED FIXED in Firefox 53

Status

()

Toolkit
General
RESOLVED FIXED
6 months ago
6 months ago

People

(Reporter: jaws, Assigned: jaws)

Tracking

unspecified
mozilla53
Points:
---

Firefox Tracking Flags

(firefox53 fixed)

Details

MozReview Requests

()

Submitter Diff Changes Open Issues Last Updated
Loading...
Error loading review requests:

Attachments

(1 attachment)

There are only two errors reported with this rule enabled and they are explicitly using sparse arrays for error testing. Enabling this rule may prevent unintended bugs from being created.

c:\fx\toolkit\components\places\tests\unit\test_tagging.js
  122:26  error  Unexpected comma in middle of array.        no-sparse-arrays (eslint)
  128:28  error  Unexpected comma in middle of array.        no-sparse-arrays (eslint)
Comment hidden (mozreview-request)

Comment 2

6 months ago
mozreview-review
Comment on attachment 8823950 [details]
Bug 1328800 - Enable the no-sparse-arrays rule for eslint and change the two instances of it to use 'undefined' instead of a sparse array since the test will still be fine either way.

https://reviewboard.mozilla.org/r/102426/#review102956

::: toolkit/components/places/tests/unit/test_tagging.js:119
(Diff revision 1)
>    do_check_true(uri4Tags.includes(tagTitle));
>    do_check_true(uri4Tags.includes("tag 3"));
>    do_check_true(uri4Tags.includes("456"));
>  
>    // Test sparse arrays.
> +  /* eslint-disable no-sparse-arrays */

Based on the code, you can just put undefined instead of the empty entries, and the test will still be fine, without the need to special-case it.
It's basically the same:
[,][0] === undefined
Attachment #8823950 - Flags: review?(mak77) → review+
Comment hidden (mozreview-request)
Comment hidden (mozreview-request)

Comment 5

6 months ago
Pushed by jwein@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/579916ba9456
Enable the no-sparse-arrays rule for eslint and change the two instances of it to use 'undefined' instead of a sparse array since the test will still be fine either way. r=mak

Comment 6

6 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/579916ba9456
Status: ASSIGNED → RESOLVED
Last Resolved: 6 months ago
status-firefox53: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla53
You need to log in before you can comment on or make changes to this bug.