Change Request: Support getLocFromIndex()
and getIndexFromLoc()
methods for TextSourceCodeBase
class
#166
Labels
enhancement
New feature or request
Which packages would you like to change?
@eslint/compat
@eslint/config-array
@eslint/config-helpers
@eslint/core
@eslint/migrate-config
@eslint/object-schema
@eslint/plugin-kit
What problem do you want to solve?
Hello,
Currently, when I try to use
getLocFromIndex()
orgetIndexFromLoc()
in languages like@eslint/markdown
, I encounter an error stating thatcontext.sourceCode.getLocFromIndex()
is not a function.I believe this error occurs because these methods are not implemented.
These methods are highly useful when creating custom rules, so I’d like to suggest implementing them in the
TextSourceCodeBase
class for more general usage.When I attempt to access
getLocFromIndex()
orgetIndexFromLoc()
in the context ofmarkdown
,css
, orjson
, I encounter an error stating "getLocFromIndex() is not a function.
"What do you think is the correct solution?
Please add support for both methods.
The original implementations of
getLocFromIndex()
andgetIndexFromLoc()
can be found in the following link:https://github.com/eslint/eslint/blob/main/lib/languages/js/source-code/source-code.js#L654-L736
We can add support for these methods by implementing them in the
TextSourceCodeBase
class, which is linked below:https://github.com/eslint/rewrite/blob/main/packages/plugin-kit/src/source-code.js#L217-L361
Participation
Additional comments
If you need more context, please feel free to let me know!
The text was updated successfully, but these errors were encountered: