organizeImports should use newlines between groups
See original GitHub issueDescription
I had a look through https://github.com/sveltejs/language-tools/issues/83 and I think this has not been mentioned yet.
Currently when I save a file eslint and the svelte plugin are fighting each other. My non-svelte files are using this plugin to sort imports: https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/order.md
These are the rules I have:
"import/newline-after-import": ["error", { count: 1 }],
"import/order": [
"warn",
{
"newlines-between": "always",
alphabetize: {
order: "asc",
caseInsensitive: true,
},
},
],
Expected | Actual |
---|---|
|
|
Proposed solution
Allow a way to configure this or use the eslint rules
Alternatives
live with the Svelte files being formatted differently.
Additional Information, eg. Screenshots
No response
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
disable organize import on specific lines · Issue #41494 ...
I like using the auto organize imports on save feature ("editor. ... imports would be added in between the organize-imports-disable-above ...
Read more >Ability to add a separator/newline in organize imports ...
Go to [Blank Lines] tab, and edit [Between Import Groups]. Set it to 1 if you want one space. enter image description here....
Read more >Organizing Imports in React and React Native | by Manu Rana
1. Group by origin. We will group system libraries (like react), external libraries, and internal project imports separately. · 2. Sort within each...
Read more >Sorting your imports correctly in React - DEV Community
newlines -between separates each group with a new line in between. alphabetize sort the order in which group will be sorted. I choose...
Read more >Rule: ordered-imports - Palantir Open Source
Import sources must be alphabetized within groups, i.e.: import * as foo ... You can use this rule to group imports however you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Maybe you already set the config in your user settings. So you would have to override it again?
About the “fighting”. this is what I meant by “flash of changes”. Because of that, the group-aware organise import would still help. At least this problem won’t be too obvious.
@jasonlyu123 Thanks for the response. I really appreciate it.
I added your suggestions in this commit https://github.com/seanlail/lint-format-issue/commit/792812aa4590bdca0febdfc324b1d44c1f0d25c6 and you’ll see when I saved the
/src/routes/index.svelte
file that the formatting removed the groups.However, I found that adding the same
"editor.codeActionsOnSave": ["source.organizeImports", "source.fixAll.eslint"],
in the[svelte]
setting fixes this and the formatting is correct. (see https://github.com/seanlail/lint-format-issue/commit/b154299473c5b2cb52306bbb8df4d4e11fb5b747)I’m not sure if this is a bug or something that perhaps should be documented?
I can also see that it’s fighting something else and “jumping around”. Hope that makes sense, video below if not.
https://user-images.githubusercontent.com/142589/169288711-800a1345-c2bd-4238-befd-3ce7f91aa42d.mov