Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
marekdedic opened this issue Jan 15, 2023 · 4 comments · Fixed by #123
Closed

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

marekdedic opened this issue Jan 15, 2023 · 4 comments · Fixed by #123

Comments

@marekdedic
Copy link

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.

@lydell lydell changed the title Add support for svelte-eslint-parser Add support for non-toplevel imports: svelte-eslint-parser and TS module declarations Jan 15, 2023
@lydell
Copy link
Owner

lydell commented Jan 15, 2023

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.

@lydell
Copy link
Owner

lydell commented Jan 15, 2023

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

@marekdedic
Copy link
Author

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

@lydell lydell changed the title Add support for non-toplevel imports: svelte-eslint-parser and TS module declarations Add support for svelte-eslint-parser and TS module declarations Jan 16, 2023
@lydell
Copy link
Owner

lydell commented Jan 16, 2023

Released in v9.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants