Skip to content

fix: false positives after definitions in no-missing-label-refs - #757

Open
lumirlumir wants to merge 2 commits into
mainfrom
fix/false-positives-after-definitions-in-no-missing-label-refs
Open

lumirlumir wants to merge 2 commits into
mainfrom
fix/false-positives-after-definitions-in-no-missing-label-refs

Conversation

@lumirlumir

@lumirlumir lumirlumir commented Oct 23, 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?

Which language are you using?

commonmark & gfm

What did you do?

<!-- eslint markdown/no-missing-label-refs: "error" -->

[foo]: http://foo.com

[foo][bar\]
image

What did you expect to happen?

No error because foo is defined.

What actually happened?

The rule incorrectly reports Label reference 'foo' not found. Moving the definition below the reference avoids the error.

"[foo][bar\\]\n\n[foo]: http://foo.com",

image

What changes did you make? (Give an overview)

This PR fixes a false positive where a definition node comes before reference-like text.

The definition node can appear before or after the reference-like text, so their order should not affect the result.

However, the current rule processes nodes sequentially and only clears matching error candidates collected before the definition, so the following passes:

image

but the following produces a false positive:

image

Related Issues

N/A

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

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Fixed missing-reference reports for labels that have a matching definition, including cases where the definition appears before or between references containing an escaped closing bracket.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Central YAML; Path: .coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e798fb5f-f716-47db-8344-4fc33411ab20
Commits

Reviewing files that changed from the base of the PR and between 0b1bd6c and 66b5082.

Files selected for processing: 2
  • src/rules/no-missing-label-refs.js
  • tests/rules/no-missing-label-refs.test.js

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

Walkthrough

The rule now records label definition identifiers in allowLabels. Added valid cases cover references that appear after a matching definition and references that appear both before and after it.

Changes: Label reference handling

Layer / File(s) Summary
Track definitions and validate unfinished references
src/rules/no-missing-label-refs.js, tests/rules/no-missing-label-refs.test.js
The definition handler adds each identifier to allowLabels. Tests cover unfinished references after a definition and on both sides of a definition.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Merge Risk: Minimal · up to 66b50

The change addresses the reported false positive without introducing a concrete merge-blocking risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: fixing false positives after definitions in the no-missing-label-refs rule. The raw summary confirms the change adds a label definition identifier to allowLabels when …
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 2…
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.
Full details: Title check

Explanation

The title names the main change: fixing false positives after definitions in the no-missing-label-refs rule. The raw summary confirms the change adds a label definition identifier to allowLabels when the definition is visited, so later text nodes do not report that label as missing. The title is specific, uses a conventional commit prefix, and matches the PR objectives, which describe a missed reference reported after a definition.

Full details: Docstring Coverage

Explanation

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 2 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@eslintbot eslintbot added this to Triage Oct 23, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in Triage Oct 23, 2026
@lumirlumir lumirlumir moved this from Needs Triage to Implementing in Triage Oct 23, 2026
@lumirlumir lumirlumir moved this from Implementing to Needs Triage in Triage Oct 26, 2026
@lumirlumir
lumirlumir marked this pull request as ready for review October 26, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

2 participants