Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Clarify the meaning of range #14166

Closed
wants to merge 1 commit into from
Closed

Conversation

gaearon
Copy link

@gaearon gaearon commented Mar 2, 2021

What is the purpose of this pull request? (put an "X" next to an item)

[x] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:

What changes did you make? (Give an overview)

It was not obvious where the range is coming from. This shows where you'd get it.

I could maybe describe the data structure but I figured this is enough because once you know how to obtain it, you might as well log it and see the data structure for yourself.

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

Nope

@eslint-github-bot eslint-github-bot bot added the triage An ESLint team member will look at this issue soon label Mar 2, 2021
@mdjermanovic mdjermanovic added accepted There is consensus among the team that this change meets the criteria for inclusion documentation Relates to ESLint's documentation and removed triage An ESLint team member will look at this issue soon labels Mar 2, 2021
* `replaceText(nodeOrToken, text)` - replaces the text in the given node or token
* `replaceTextRange(range, text)` - replaces the text in the given range
* `replaceTextRange(nodeOrToken.range, text)` - replaces the text in the given range
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better to describe data structure.

*Range methods are commonly used when the range isn't directly taken from a single node/token, but calculated. Most often from other token's ranges, like in this example, but it also doesn't have to be related to any nodes/tokens, as in this example.

If we want to replace a single node/token, we can just call replaceText(nodeOrToken, text).

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that’s a good point. The range is just a two-item array of the starting index and ending index, which exists naturally on nodes or tokens as a range property but can be manually created too.

@nzakas
Copy link
Member

nzakas commented Aug 5, 2021

Closing due to age

@nzakas nzakas closed this Aug 5, 2021
@nzakas
Copy link
Member

nzakas commented Oct 16, 2021

New PR: #15174

@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Feb 2, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion documentation Relates to ESLint's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants