eslint / espree

An Esprima-compatible JavaScript parser
BSD 2-Clause "Simplified" License
2.26k stars 189 forks source link

Please export `TokenTranslator` for reusing outside for ESLint plugins #542

Closed JounQin closed 2 years ago

JounQin commented 2 years ago

My current hack workaround is using absolute path to require the module

https://github.com/mdx-js/eslint-mdx/pull/284/files#diff-28c9951bdd4b9fbbb77321aec606c4ec820dc169ca472ad8991aa553bc4283baR220-R229

nzakas commented 2 years ago

This isn't intended to be part of the public API. Why are you using it?

JounQin commented 2 years ago

My eslint-mdx parser is using remark-mdx which use acorn as parser, so I need to transform the acron tokens into ESLint's.

nzakas commented 2 years ago

TSC Summary: This issue proposes exporting the internal TokenTranslator class that we use to translate Acorn tokens into Espree tokens.

TSC Question: Do we want to export this class?

btmills commented 2 years ago

Hi @JounQin, it doesn’t make sense for us to expose this as part of Espree’s public API because the underlying Acorn parser is just an implementation detail. Since the TokenTranslator implementation doesn’t change, copying the code should be viable.