Skip to content

no-duplicate-constant-values: apply minimum-group-size guard to booleans - #50247

Merged
pelikhan merged 2 commits into
mainfrom
copilot/no-duplicate-constant-values-fix
Aug 4, 2026
Merged

no-duplicate-constant-values: apply minimum-group-size guard to booleans#50247
pelikhan merged 2 commits into
mainfrom
copilot/no-duplicate-constant-values-fix

Conversation

Copilot AI commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Numeric constants required 3+ matches before being flagged as duplicates (to avoid false positives on coincidental small numbers like 0/1/-1), but booleans had no such guard despite having an even smaller value space (only 2 possible values). Any two unrelated const bindings both set to true (or both false) were incorrectly flagged.

Rule changes (no-duplicate-constant-values.ts)

  • Added MIN_BOOLEAN_DUPLICATE_GROUP_SIZE = 3, mirroring the existing numeric threshold and rationale.
  • Generalized shouldReportDuplicates to compute a minGroupSize per value-key prefix (number: and boolean: → 3, everything else → 2), replacing the previous number-only special case.
  • Strings are left as-is (threshold of 2): their collision space is much larger, and no coincidental collisions were found in the existing corpus.

Tests

  • Added a valid case: two unrelated boolean constants sharing the same value are not flagged.
  • Added an invalid case: three or more matching boolean constants are still flagged, consistent with the numeric behavior.
// No longer flagged (only 2 occurrences):
const FIRST_ENABLED = true;
const SECOND_ENABLED = true;

// Still flagged (3+ occurrences):
const A = true;
const B = true;
const C = true; // duplicates A

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix no-duplicate-constant-values to guard boolean literals no-duplicate-constant-values: apply minimum-group-size guard to booleans Aug 4, 2026
Copilot AI requested a review from pelikhan August 4, 2026 12:35
@pelikhan
pelikhan marked this pull request as ready for review August 4, 2026 12:36
Copilot AI balanced review requested due to automatic review settings August 4, 2026 12:36
@pelikhan
pelikhan merged commit b81146b into main Aug 4, 2026
@pelikhan
pelikhan deleted the copilot/no-duplicate-constant-values-fix branch August 4, 2026 12:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a boolean duplicate-group threshold to reduce false positives in the ESLint rule.

Changes:

  • Requires three matching boolean constants before reporting duplicates.
  • Adds coverage for both accepted pairs and reported triplets.
Show a summary per file
File Description
eslint-factory/src/rules/no-duplicate-constant-values.ts Applies the minimum group-size guard to booleans.
eslint-factory/src/rules/no-duplicate-constant-values.test.ts Tests boolean duplicate thresholds.

Review details

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.84.4

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

no-duplicate-constant-values: boolean/string values lack the coincidence guard given to numbers

3 participants