Skip to content

Conversation

@lumirlumir
Copy link
Member

@lumirlumir lumirlumir commented Sep 29, 2025

Prerequisites checklist

What is the purpose of this pull request?

This PR originated from #536. While working on that, I found the scope had become too large, so I split this refactoring into a separate PR.

In this PR, I've used the native getLocFromIndex method added in #376 instead of the custom findOffsets util.

Notable changes:

  • Replace the findOffsets util with the native getLocFromIndex.
  • Use the d flag and a named capturing group for the reversedPattern regex.
  • Declare skipRanges as const and reset it with skipRanges.length = 0 to avoid creating a new reference each time.
  • Consolidate three ESQuery selectors into a single selector.
    Ref:
    ":matches(heading, paragraph, tableCell) html"(
    /** @type {Html} */ node,
    ) {
    const tagInfo = parseHtmlTag(node.value);
    if (!tagInfo) {
    return;
    }
    if (!tagInfo.isClosing && lastTagName === null) {
    lastTagName = tagInfo.name;
    }
    if (tagInfo.isClosing && lastTagName === tagInfo.name) {
    reset();
    }
    },

What changes did you make? (Give an overview)

In this PR, I've used the native getLocFromIndex method added in #376 instead of the custom findOffsets util.

Related Issues

Ref: #376, #536

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

N/A

@eslintbot eslintbot added this to Triage Sep 29, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Sep 29, 2025
@lumirlumir lumirlumir requested review from a team and mdjermanovic September 29, 2025 10:00
@lumirlumir lumirlumir marked this pull request as draft September 29, 2025 12:51
Copy link
Member

@mdjermanovic mdjermanovic left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! Very nice simplification.

@mdjermanovic mdjermanovic merged commit 104d4b7 into main Sep 29, 2025
23 checks passed
@mdjermanovic mdjermanovic deleted the refactor-use-getlocfromindex-in-no-reversed-media-syntax branch September 29, 2025 13:52
@github-project-automation github-project-automation bot moved this from Implementing to Complete in Triage Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants