Closed Bug 1328800 Opened 7 years ago Closed 7 years ago

Enable the no-sparse-arrays rule for eslint

Categories

(Toolkit :: General, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla53
Tracking Status
firefox53 --- fixed

People

(Reporter: jaws, Assigned: jaws)

Details

Attachments

(1 file)

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 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+
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
https://hg.mozilla.org/mozilla-central/rev/579916ba9456
Status: ASSIGNED → RESOLVED
Closed: 7 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: