eslint-plugin-import: Error when importing .svelte files in .ts files
Hi,
I am currently trying to migrate from eslint-plugin-svelte3
to eslint-plugin-svelte
. Most things are working, but when I import a .svelte
file from a .ts
file (for example in unit tests), I get two errors from eslint-plugin-import
(at least I think the errors comes from this plugin).
Error while parsing C:\pathToRepo\src\routes\Counter.svelte
Line 10, column 19: Unexpected token :
`parseForESLint` from parser `svelte-eslint-parser` is invalid and will just be ignored
and
C:\pathToRepo\svelte-eslint-import-error\src\routes\Counter.test.ts
2:21 warning Parse errors in imported module './Counter.svelte': parser.parse is not a function (undefined:undefined) import/no-named-as-default
I created a reproduction repo https://github.com/vekunz/svelte-eslint-import-error. Probably I still have a configuration issue somewhere, but after several hours of reading documentation and GitHub Issues, I could not find any solution to this.
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 16 (6 by maintainers)
ah but we’re not getting the config for other files perhaps? I’ll be interested to review your pr.
I have the same problem.
svelte-plugin-eslint
for typescript ist configured like this:To be able to import svelte files from js/ts we also need:
But I guess here the
parserOptions.parser
for typescript is missing.EDIT:
My guess seems to be correct. The problem goes away after adding
somewhere in between https://github.com/import-js/eslint-plugin-import/blob/da71746147450a5b7eeeaca77efc521125d91d41/utils/parse.js#L64-L78
Of course hard coding this is not the final solution. I think the plugin should take the
overrides
section into account. I will try to get a PR ready.Until there’s a resolver, that might be your only option.