Rule proposal: `no-new-array`
See original GitHub issueThere is a no-array-constructor
rule in core, but it’s not what I want, it enforce Array(1, 2)
and new Array(1, 2)
to [1, 2]
,
Fail
const foo = new Array(10);
Pass
const foo = Array.from({length: 10});
Rule should provide suggestions for unknown argument:
const foo = new Array(bar);
Suggestion 1:
const foo = [bar];
Suggestion 2:
const foo = Array.from({length: bar});
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top Results From Across the Web
SEC Proposed Rules
SEC Proposed Rules · Regulation NMS: Minimum Pricing Increments, Access Fees, and Transparency of Better Priced Orders · File No: S7-30-22 · Comments...
Read more >eslint-plugin-unicorn/no-new-array.md at main - GitHub
This rule fills that gap. When using the Array constructor with one argument, it's not clear whether the argument is meant to be...
Read more >Federal Register/Vol. 87, No. 46/Wednesday, March 9, 2022 ...
ACTION: Proposed rule. SUMMARY: The Securities and Exchange. Commission is proposing new rules under the Investment Advisers Act of.
Read more >eslint | Yarn - Package Manager
Website | Configuring | Rules | Contributing | Reporting Bugs | Code of Conduct | Twitter | Mailing List | Chat Room. ESLint...
Read more >Agency Rule List - Spring 2022 - Reginfo.gov
Agency Agenda Stage of Rulemaking RIN
SEC Proposed Rule Stage 3235‑AL91
SEC Proposed Rule Stage 3235‑AM06
SEC Proposed Rule Stage 3235‑AM78
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
Array.from
trick also has the benefit that it’s the most efficient solution if you need to map over the array afterward as you can do so in one operation:Hmm I don’t like this
Array.from({length: 10})
because it’s abusing a object to be an arrayLike.