Skip to content

Comments

feat(linter): add unicorn/no-useless-collection-argument#15545

Merged
camc314 merged 2 commits intooxc-project:mainfrom
baevm:unicorn/no-useless-collection-argument
Nov 10, 2025
Merged

feat(linter): add unicorn/no-useless-collection-argument#15545
camc314 merged 2 commits intooxc-project:mainfrom
baevm:unicorn/no-useless-collection-argument

Conversation

@baevm
Copy link
Contributor

@baevm baevm commented Nov 10, 2025

This PR adds unicorn/no-useless-collection-argument rule, issue #684

rule doc
rule source

not sure about rule category, should this be style or correctness?

Copilot AI review requested due to automatic review settings November 10, 2025 06:56
@baevm baevm requested a review from camc314 as a code owner November 10, 2025 06:56
@graphite-app
Copy link
Contributor

graphite-app bot commented Nov 10, 2025

How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@github-actions github-actions bot added A-linter Area - Linter C-enhancement Category - New feature or request labels Nov 10, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a new ESLint rule unicorn/no-useless-collection-argument that detects and flags useless arguments passed to Set, Map, WeakSet, and WeakMap constructors.

Key changes:

  • Adds rule implementation to detect empty arrays, empty strings, null, and undefined values passed to collection constructors
  • Detects useless fallback values in nullish coalescing expressions (e.g., foo ?? [])
  • Includes comprehensive test coverage with 28 test cases

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
crates/oxc_linter/src/rules/unicorn/no_useless_collection_argument.rs Core rule implementation with logic to detect useless collection arguments
crates/oxc_linter/src/snapshots/unicorn_no_useless_collection_argument.snap Snapshot file containing expected diagnostic outputs for test cases
crates/oxc_linter/src/rules.rs Registers the new rule module and adds it to the rule list
crates/oxc_linter/src/generated/rule_runner_impls.rs Generated code to enable the rule runner for NewExpression AST nodes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@baevm baevm force-pushed the unicorn/no-useless-collection-argument branch from 8343183 to de43f3d Compare November 10, 2025 07:00
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 10, 2025

CodSpeed Performance Report

Merging #15545 will not alter performance

Comparing baevm:unicorn/no-useless-collection-argument (535e963) with main (b7d8d57)

Summary

✅ 4 untouched
⏩ 33 skipped1

Footnotes

  1. 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Copy link
Contributor

@camc314 camc314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@camc314 camc314 merged commit 9f759a0 into oxc-project:main Nov 10, 2025
21 checks passed
@Perdolique
Copy link

Perdolique commented Nov 10, 2025

@camc314 is it not in the documentation yet? Can't find it here. 🤔

Not sure if it's a bug or not.

@camc314
Copy link
Contributor

camc314 commented Nov 10, 2025

yeah good catch. our CI failed. Try looking in 10 min? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants