ESLint Uses Similar Thing to Ranges

by — posted on

Well, sort of.

If you check the ESLint API, the verify() opens in a new tab will return a range key:

{
fatal: false,
ruleId: "semi",
severity: 2,
line: 1,
column: 23,
message: "Expected a semicolon.",
fix: {
range: [1, 15], // <---- this
text: ";"
}
}

The string indexes are the same — they are also placed in an array — the only difference is ESLint explicitly tells what to insert using a separate key.

If ESLint opens in a new tab marked a finding like this:

{
range: [1, 15],
text: ";"
}

Ranges would mark it shorter:

[
[1, 15, ";"]
]

Very similar!

Related packages:

📦 eslint opens in a new tab
An AST-based pattern checker for JavaScript
📦 ranges-apply 3.2.4
Take an array of string index ranges, delete/replace the string according to them
📦 ranges-push 3.7.23
Gather string index ranges