Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(useArrayLiterals): check all expressions and add a fix #4416

Closed
wants to merge 1 commit into from

Conversation

Conaclos
Copy link
Member

Summary

This PR introduces several fixes/improvements for useArrayLiterals:

  • Improve correctness

    Previously, the rule reported only use of the Array constructor in expressions statements.

    // This was reported
    new Array();
    // This was not reported
    const xs = new Array();

    The rule now correctly report these two cases.

  • Support globalThis.Array and window.Array and don't report Array that resolves to a defined variable.

  • Add a code fix.

    - const xs = new Array();
    + const xs = [];
  • Improve diagnostics

Test Plan

I added tests and updated snapshots.

@github-actions github-actions bot added A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages A-Changelog Area: changelog labels Oct 29, 2024
@Conaclos Conaclos changed the title fix(useArrayLiterals): check all expressions and add a fix refactor(useArrayLiterals): check all expressions and add a fix Oct 29, 2024
@Conaclos Conaclos force-pushed the conaclos/useArrayLiterals-fix branch from 3365925 to 29f23bf Compare October 29, 2024 09:24
Copy link
Contributor

github-actions bot commented Oct 29, 2024

Parser conformance results on

js/262

Test result main count This PR count Difference
Total 48421 48421 0
Passed 47221 47221 0
Failed 1200 1200 0
Panics 0 0 0
Coverage 97.52% 97.52% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 40 40 0
Passed 37 37 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.50% 92.50% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 6580 6580 0
Passed 2205 2205 0
Failed 4375 4375 0
Panics 0 0 0
Coverage 33.51% 33.51% 0.00%

ts/babel

Test result main count This PR count Difference
Total 680 680 0
Passed 607 607 0
Failed 73 73 0
Panics 0 0 0
Coverage 89.26% 89.26% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 18518 18518 0
Passed 14178 14178 0
Failed 4340 4340 0
Panics 0 0 0
Coverage 76.56% 76.56% 0.00%

Copy link

codspeed-hq bot commented Oct 29, 2024

CodSpeed Performance Report

Merging #4416 will not alter performance

Comparing conaclos/useArrayLiterals-fix (2cf143b) with main (044baf4)

Summary

✅ 99 untouched benchmarks

@Conaclos Conaclos requested a review from a team October 29, 2024 10:06
@Conaclos Conaclos force-pushed the conaclos/useArrayLiterals-fix branch from 29f23bf to 2cf143b Compare October 29, 2024 10:45
@Conaclos
Copy link
Member Author

Closing because the PR has been merged.

@Conaclos Conaclos closed this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Changelog Area: changelog A-Linter Area: linter A-Parser Area: parser L-JavaScript Language: JavaScript and super languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants