Skip to content

fix: escaped parentheses in nested labels in no-reversed-media-syntax - #752

Open
lumirlumir wants to merge 1 commit into
mainfrom
fix/escaped-parentheses-in-nested-labels-in-no-reversed-media-syntax
Open

lumirlumir wants to merge 1 commit into
mainfrom
fix/escaped-parentheses-in-nested-labels-in-no-reversed-media-syntax

Conversation

@lumirlumir

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

Environment

  • ESLint: 10.9.1
  • @eslint/markdown: 8.0.3
  • Node: 24.18.0
  • npm: 12.2.0
  • OS: Windows

Which language are you using?

commonmark and gfm

What did you do?

Linted the following Markdown:

<!-- eslint markdown/no-reversed-media-syntax: "error" -->

(a (b \(c\)) d)[x]

What did you expect to happen?

The rule should report reversed syntax and autofix it to:

<!-- eslint markdown/no-reversed-media-syntax: "error" -->

[a (b \(c\)) d](x)

What actually happened?

No problems were reported.

What changes did you make? (Give an overview)

Fixes a regression introduced in #693 that was overlooked during review. I found it while reviewing #736 (comment), thanks to a comment from CodeRabbit.

The limitation introduced in #693 was that parentheses nested two or more levels deep were no longer reported. However, escaped parentheses should still be reported because they don’t create nested parentheses.

I’ve looked into this carefully, and this change does not introduce any ReDoS-related regressions. The newly added [\s\S] pattern does not cause catastrophic time complexity.

Related Issues

#693

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

N/A

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of reversed Markdown links and images when labels contain nested parentheses or escaped characters, including escaped newlines.
    • Error reporting continues to cover the full original construct.

@eslint-github-bot eslint-github-bot Bot added the bug label Oct 8, 2026
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: eslint/coderabbit/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d84d055b-78c1-4a39-89fe-0fe867351f5c
📥 Commits

Reviewing files that changed from the base of the PR and between 4233685 and 507ff28.

📒 Files selected for processing (2)
  • src/rules/no-reversed-media-syntax.js
  • tests/rules/no-reversed-media-syntax.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

Walkthrough

The reversed media pattern now supports nested parentheses and escaped characters in labels. Tests cover reversed links and images with these label forms and verify conversion and error ranges.

Changes

Reversed media syntax

Layer / File(s) Summary
Pattern and label coverage
src/rules/no-reversed-media-syntax.js, tests/rules/no-reversed-media-syntax.test.js
The pattern supports nested parentheses and escaped characters in labels while retaining its non-overlap constraint. Tests cover reversed links and images with escaped delimiters, backslash runs, and backslash-newline sequences. They verify the converted syntax and reversedSyntax error ranges.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 507ff

The targeted reversed-syntax cases are covered, and no actionable merge risk remains beyond normal checks.

🚥 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 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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing escaped parentheses in nested labels for no-reversed-media-syntax.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · 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.

@lumirlumir
lumirlumir marked this pull request as ready for review October 8, 2026 12:02
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.

1 participant