Skip to content

Conversation

lumirlumir
Copy link
Member

@lumirlumir lumirlumir commented May 14, 2025

Prerequisites checklist

What is the purpose of this pull request?

Working in progress.

What changes did you make? (Give an overview)

Related Issues

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

Prerequisite

@nzakas
Copy link
Member

nzakas commented May 14, 2025

Before you get too far on this, is this function currently needed? As discussed in eslint/rewrite#166, this is an expensive operation and I don't think we want to incorporate it unless we absolutely need it.

@lumirlumir
Copy link
Member Author

lumirlumir commented May 14, 2025

@nzakas

I thought this method could replace the findOffsets method used throughout the rules in @eslint/markdown, so I saw it as both a refactor and a new feature.

image

It’s currently used in two rules, and I use this kind of logic in my own rules as well (for context, please see https://github.com/lumirlumir/npm-eslint-plugin-mark/blob/main/packages/eslint-plugin-mark/src/core/ast/text-handler/text-handler.js).

If this feature isn’t necessary for now, I’ll go ahead and close it.


(If it is fine, I would like to keep exploring and look for a more performant solution.)

@nzakas
Copy link
Member

nzakas commented May 14, 2025

@lumirlumir ah, I forgot about that. Gotcha. 👍 If you're going to go through the trouble of investigating, then I'd suggest doing it on TextSourceCodeBase so every project can benefit.

@lumirlumir
Copy link
Member Author

lumirlumir commented May 14, 2025

@nzakas Thanks for understanding!

I’ll keep this PR open for now, move on to implementing TextSourceCodeBase, and then come back to this one afterward.

Can I assign myself for the issue I've created? eslint/rewrite#166

@nzakas
Copy link
Member

nzakas commented May 14, 2025

Go ahead.

@nzakas
Copy link
Member

nzakas commented May 14, 2025

The other thing to keep in mind is that findOffsets() is not always used from the beginning of the document. Like in this case:

const { lineOffset, columnOffset } = findOffsets(

It's finding the offset inside a given node's text.

@lumirlumir lumirlumir changed the title feat: add support for getLocFromIndex feat: add support for getLocFromIndex and getIndexFromLoc Jun 6, 2025
Copy link
Contributor

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

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

Successfully merging this pull request may close these issues.

2 participants