lydell / eslint-plugin-simple-import-sort

Easy autofixable import sorting.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for svelte-eslint-parser and TS module declarations

marekdedic opened this issue · comments

Hi,
this plugin unfortunately doesn't work with svelte-eslint-parser - I tried opening an issue on their side, but from the response I gather that this needs to be fixed in esplint-plugin-simple-import sort: sveltejs/eslint-plugin-svelte#339. Could this please be fixed?

I am aware of #71 but that is a different parser and the fix does not apply.

Hi! Thanks for the report!

Note to self: sveltejs/eslint-plugin-svelte#199 (comment)

Need to visit SvelteScriptElement and TSModuleBlock and possibly something more. Or: Visit everything and try to sort imports in it.

Program: (programNode) => {
for (const chunk of shared.extractChunks(programNode, (node) =>
isImport(node) ? "PartOfChunk" : "NotPartOfChunk"

Edit: Or, visit all ImportDeclaration and keep track of their parents. Then, in "Program:exit", go through all the parents and do the sorting on each. Note: Also for ExportNamedDeclaration and ExportAllDeclaration.

@marekdedic Can you try npm install eslint-plugin-simple-import-sort@beta and see if it works with your Svelte setup?

I can confirm that it works with my setup - I have only imports. I have tried both reporting and autofixing.

Released in v9.0.0.