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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/developer-guide/working-with-rules.md
Expand Up @@ -306,13 +306,13 @@ Here, the `fix()` function is used to insert a semicolon after the node. Note th
The `fixer` object has the following methods:

* `insertTextAfter(nodeOrToken, text)` - inserts text after the given node or token
* `insertTextAfterRange(range, text)` - inserts text after the given range
* `insertTextAfterRange(nodeOrToken.range, text)` - inserts text after the given range
* `insertTextBefore(nodeOrToken, text)` - inserts text before the given node or token
* `insertTextBeforeRange(range, text)` - inserts text before the given range
* `insertTextBeforeRange(nodeOrToken.range, text)` - inserts text before the given range
* `remove(nodeOrToken)` - removes the given node or token
* `removeRange(range)` - removes text in the given range
* `removeRange(nodeOrToken.range)` - removes text in the given range
* `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.


The above methods return a `fixing` object.
The `fix()` function can return the following values:
Expand Down