Why does @typescript-eslint/parser
not use the linted code's TypeScript package
#6031
Replies: 1 comment 1 reply
-
The short answer is no - because we need to use the exact same TS version everywhere and we need to make sure that everyone uses th exact same TS version everywhere, which would be a very high effort project to do, which (frankly) isn't something worth doing to solve for this really rare usecase. We control the parser, we control one eslint plugin. But there are many other plugins that exist using type information. In order to make this world of "consume TS from the file's directory" work we would have to:
Hopefully this helps shed some light on the large complexities that are involved in making the ecosystem work like this. As I said - the cost is monumentally high and has large ongoing maintenance costs. Such a cost is too great to pay to solve the very, very unique problem. Generally the solution would be to colocate your linting install and your code install so they have the exact same version. Failing that ensuring that the TS version is synced / enforced via some CI check should be fine. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
RFC
In #3293, I identified a problem where the location of the
@typescript-eslint/parser
package in relation to the linted code seemed to affect how it behaved. It was determined that when@typescript-eslint/parser
doesrequire('typescript')
, it retrieves the version of TypeScript that's nearest to the@typescript-eslint/parser
package, which might be different than the version of TypeScript used by the code being linted.During development on one of our internal tools, this exact issue cropped up again, causing us to revisit #3293. That led me to wonder... why does
@typescript-eslint/parser
use its owntypescript
package instead of the one used by the code being linted?In our case, the
typescript
package our linted code was using was being patched by Yarn's Plug'n'Play feature, but I imagine that other differences could crop up simply between different versions of TypeScript. Should@typescript-eslint/parser
be using the version of TypeScript it finds when searching from the directory that holds the file/code being linted instead?Additional Info
No response
Before you submit your RFC, please confirm the following. If any of these required steps are not taken, we may not be able to review your RFC. Help us to help you!
Beta Was this translation helpful? Give feedback.
All reactions