Enable no-array-constructor across mozilla-central

RESOLVED FIXED in Firefox 55

Status

RESOLVED FIXED
2 years ago
3 months ago

People

(Reporter: standard8, Assigned: dbugs, Mentored)

Tracking

({good-first-bug})

3 Branch
mozilla55
good-first-bug

Firefox Tracking Flags

(firefox55 fixed)

Details

(Whiteboard: [lang=js])

Attachments

(1 attachment)

(Reporter)

Description

2 years ago
From eslint.org:

Use of the Array constructor to construct a new array is generally discouraged in favour of array literal notation because of the single-argument pitfall and because the Array global may be redefined

http://eslint.org/docs/rules/no-array-constructor

Hence, we should enable the no-array-constructor across mozilla-central. The rule is already enabled for some areas:

https://dxr.mozilla.org/mozilla-central/search?q=no-array-constructor&redirect=false

I'm willing to mentor this bug. Approximate steps:

- Ensure you've got ESLint setup on mozilla-central (https://developer.mozilla.org/docs/ESLint).
- In tools/lint/eslint/eslint-plugin-mozilla/lib/configs/recommended.js un-comment the no-array-constructor line.
- Remove the no-array-constructor lines from the other .eslintrc.js files (* apart from devtools/ *)
- Run:

./mach eslint

- Fix the 30 or so instances that it reports as failing. I think all of these should just be switching the `new Array()` to `[]`.
- Commit to a patch and push it to mozreview (http://mozilla-version-control-tools.readthedocs.io/en/latest/mozreview.html)
(Assignee)

Updated

2 years ago
Assignee: nobody → dbugs
Comment hidden (mozreview-request)

Comment 2

2 years ago
Can I work on this bug as one of my starting bugs ? If so, I'd like to start working unless Dan has already started working.

Thanks
- Kushal
(Reporter)

Comment 3

2 years ago
(In reply to Kushal Singh from comment #2)
> Can I work on this bug as one of my starting bugs ? If so, I'd like to start
> working unless Dan has already started working.

Hi, Dan has already started working on this (and attached a patch). I'll probably have similar bugs available later today or tomorrow, so keep an eye out if you're looking for more.
(Reporter)

Comment 4

2 years ago
mozreview-review
Comment on attachment 8872040 [details]
Bug 1368041 - Enable no-array-constructor across mozilla-central

https://reviewboard.mozilla.org/r/143558/#review147846

Looks good. r=Standard8

Thank you!
Attachment #8872040 - Flags: review?(standard8) → review+

Comment 5

2 years ago
Pushed by mbanner@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/6dab94af60d4
Enable no-array-constructor across mozilla-central r=standard8

Comment 6

2 years ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/6dab94af60d4
Status: NEW → RESOLVED
Last Resolved: 2 years ago
status-firefox55: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55

Updated

a year ago
Product: Testing → Firefox Build System
Keywords: good-first-bug
Version: Version 3 → 3 Branch
Keywords: good-first-bug
You need to log in before you can comment on or make changes to this bug.