Skip to content

refactor: use Set instead of Map in no-duplicate-keys - #280

Merged
mdjermanovic merged 2 commits into
mainfrom
refactor/use-set-instead-of-map
Sep 5, 2026
Merged

refactor: use Set instead of Map in no-duplicate-keys#280
mdjermanovic merged 2 commits into
mainfrom
refactor/use-set-instead-of-map

Conversation

@lumirlumir

@lumirlumir lumirlumir commented Sep 5, 2026

Copy link
Copy Markdown
Member

Prerequisites checklist

AI acknowledgment

  • I did not use AI to generate this PR.
  • (If the above is not checked) I have reviewed the AI-generated content before submitting.

What is the purpose of this pull request?

A similar refactor to the one in eslint/css#513.

What changes did you make? (Give an overview)

While reviewing the no-duplicate-keys code, I found that there was no need to use a Map, so I replaced it with a Set.

Related Issues

Ref: eslint/css#513

Is there anything you'd like reviewers to focus on?

N/A

Summary by CodeRabbit

  • Refactor
    • Simplified internal duplicate-key tracking while preserving normalized-key duplicate detection behavior.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 7e5cefed-974b-466b-8452-1ea511373800

📥 Commits

Reviewing files that changed from the base of the PR and between 780bfcd and a263abd.

📒 Files selected for processing (1)
  • src/rules/no-duplicate-keys.js

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The duplicate-key rule now uses per-object Set<string> instances to track normalized keys. It removes the unused MemberNode type import and no longer stores the first member node.

Changes

Duplicate Key Tracking

Layer / File(s) Summary
Set-based duplicate tracking
src/rules/no-duplicate-keys.js
The rule replaces per-object maps with string sets, records keys with Set.add, and removes the unused MemberNode type import.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to a263a

This refactor replaces presence-only Map tracking with Sets while preserving duplicate-key detection behavior. No current merge-blocking risk is identified.

Suggested reviewers: pixel998

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: replacing the Map with a Set in no-duplicate-keys.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/use-set-instead-of-map

Comment @coderabbitai help to get the list of available commands.

@eslintbot eslintbot added this to Triage Sep 5, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Sep 5, 2026
@lumirlumir
lumirlumir marked this pull request as ready for review September 5, 2026 13:38

@mdjermanovic mdjermanovic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks!

@mdjermanovic
mdjermanovic merged commit faebb52 into main Sep 5, 2026
38 checks passed
@mdjermanovic
mdjermanovic deleted the refactor/use-set-instead-of-map branch September 5, 2026 15:10
@github-project-automation github-project-automation Bot moved this from Needs Triage to Complete in Triage Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants