eslint/typescript-eslint-parser

Parse error when using as parser for eslint-plugin-import

christophercurrie opened this issue · 4 comments

What version of TypeScript are you using?

3.0.1

What version of typescript-eslint-parser are you using?

19.0.1

What code were you trying to parse?

import Foo from "./Foo";

What did you expect to happen?

Using eslint-plugin-import 2.14.0 should allow eslint on Javascript to check imports of Typescript files using typescript-eslint-parser as documented by the plugin.

What happened?

All files importing typescript code complain:

Parse errors in imported module './Foo': parser.parse is not a function. (undefined:undefined)

It appears that version 19 has dropped the parse function from its list of exports, which seems like it would be related.

Seems that eslint-plugin-import should follow the same rules as ESLint when parsing a file: it should check for a parseForESLint method and use that (and get the AST from the output), else fall back to parse.

Not sure if we want/need to add parse back to the exports as a short-term fix in the meanwhile.

I think both approaches would be reasonable. 19 was a breaking change version and this was a breaking change, so there shouldn't be an issue for folks rolling back. On the other hand, it would be trivial to add for backwards compatibility and we could accept a PR?

I'm having this as well, and this is kind of preventing me from upgrading to the latest, you can see the error here https://travis-ci.com/GabrielDuarteM/gd-scripts/jobs/147824652#L4114

I'm not familiar with the codebase/eslint internals, and the error is kind of cryptic, as apparently this is not really an error in my code (at least I hope), so I didn't quite understand what is going on.
Is this an error that should be fixed by eslint-plugin-import (I am using that as well)?

I'm getting the same error as well.