feat(linter): add unicorn/no-useless-collection-argument#15545
feat(linter): add unicorn/no-useless-collection-argument#15545camc314 merged 2 commits intooxc-project:mainfrom
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
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. |
There was a problem hiding this comment.
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.
8343183 to
de43f3d
Compare
CodSpeed Performance ReportMerging #15545 will not alter performanceComparing Summary
Footnotes
|
crates/oxc_linter/src/rules/unicorn/no_useless_collection_argument.rs
Outdated
Show resolved
Hide resolved
|
yeah good catch. our CI failed. Try looking in 10 min? thanks |
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?