Skip to content

Conversation

@hyperz111
Copy link

@hyperz111 hyperz111 commented Jan 22, 2026

User description

Description

Replace lodash.uniq(array) with [...new Set(array)]. Extracted from #4596.

Motivation and Context

Now we can do [...new Set(array)] instead lodash.uniq(array).

Usage examples

Nothing

How Has This Been Tested?

I run the test in changed package (@commitlint/load).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Enhancement


Description

  • Replace lodash.uniq dependency with native Set-based deduplication

  • Remove lodash.uniq package from dependencies and type definitions

  • Use [...new Set(array)] pattern for array deduplication


Diagram Walkthrough

flowchart LR
  A["lodash.uniq import"] -->|"remove"| B["Native Set deduplication"]
  C["lodash.uniq dependency"] -->|"remove"| D["package.json updated"]
  B -->|"use [...new Set()]"| E["load.ts implementation"]
Loading

File Walkthrough

Relevant files
Enhancement
load.ts
Replace lodash.uniq with native Set deduplication               

@commitlint/load/src/load.ts

  • Removed lodash.uniq import statement
  • Replaced uniq(extended.plugins) call with inline [...new
    Set(extended.plugins)] deduplication
  • Local variable uniq now holds the deduplicated array result
+2/-2     
Dependencies
package.json
Remove lodash.uniq package dependencies                                   

@commitlint/load/package.json

  • Removed lodash.uniq from dependencies
  • Removed @types/lodash.uniq from devDependencies
  • Kept lodash.merge and lodash.isplainobject as they are still in use
+1/-3     

@qodo-code-review
Copy link

qodo-code-review bot commented Jan 22, 2026

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

🔴
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status:
Vague variable name: The new variable name uniq is not self-documenting and should be renamed to something
clearer like uniquePlugins to reflect its purpose.

Referred Code
const uniq = [...new Set(extended.plugins)];
for (const plugin of uniq) {

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jan 22, 2026

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@qodo-code-review
Copy link

qodo-code-review bot commented Jan 22, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Iterate directly over the Set

Avoid creating an unnecessary intermediate array by iterating directly over the
new Set(extended.plugins).

@commitlint/load/src/load.ts [87-88]

-const uniq = [...new Set(extended.plugins)];
-for (const plugin of uniq) {
+for (const plugin of new Set(extended.plugins)) {
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that creating an intermediate array is unnecessary, as a Set is directly iterable, leading to more concise and slightly more memory-efficient code.

Low
  • Update

@escapedcat escapedcat requested a review from Copilot January 22, 2026 16:29
@escapedcat escapedcat changed the title chore: replace lodash.uniq with simple code reactor: replace lodash.uniq with simple code Jan 22, 2026
@escapedcat escapedcat changed the title reactor: replace lodash.uniq with simple code refactor: replace lodash.uniq with simple code Jan 22, 2026
Copy link

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 replaces the lodash.uniq dependency with native JavaScript Set-based deduplication to reduce external dependencies and use modern JavaScript features.

Changes:

  • Removed lodash.uniq import and replaced usage with [...new Set(array)] pattern
  • Removed lodash.uniq and @types/lodash.uniq from package dependencies
  • Updated yarn.lock to reflect dependency removal

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
@commitlint/load/src/load.ts Replaced lodash.uniq function call with native Set deduplication for plugins array
@commitlint/load/package.json Removed lodash.uniq from dependencies and @types/lodash.uniq from devDependencies
yarn.lock Removed package entries for lodash.uniq and @types/lodash.uniq

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

@escapedcat
Copy link
Member

Please have a look at the comment from copilot, thanks!

@hyperz111
Copy link
Author

@escapedcat

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

Development

Successfully merging this pull request may close these issues.

2 participants