-
Notifications
You must be signed in to change notification settings - Fork 4
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
Question or Bug Report // parth-sort-order for named imports #14
Comments
I believe the problem is the trailing comma and missing end quote. If you replace
with
I think you will find it sorts as expected. |
Removed trailing comma from multiline named-import and gave it a try with: import React from 'react';
import { DialogContent } from '../DialogContent';
import { Label } from '../Label';
import { Slugs } from '../Slugs';
import {
Details,
ToolReference,
ToolReference1,
ToolReference2,
ToolReference3
} from '@my-package/components'; Result import React from 'react';
import { Details, ToolReference, ToolReference1, ToolReference2, ToolReference3 } from '@my-package/components';
import { DialogContent } from '../DialogContent';
import { Label } from '../Label';
import { Slugs } from '../Slugs'; Now, the sort-order is correct indeed, but it's not multi-line anymore. |
Unless you set |
Updated config to be: "typescript.extension.sortImports.sortMethod": "path",
"typescript.extension.sortImports.pathSortOrder": [
"package",
"relativeUpLevel",
"relativeDownLevel"
],
"typescript.extension.sortImports.sortOnSave": true,
"typescript.extension.sortImports.pathSortOrderOverride": ["react"],
"typescript.extension.sortImports.enableJavascript": true,
"typescript.extension.sortImports.forceTrailingCommas": "multiLineOnly",
"typescript.extension.sortImports.maxNamedImportsInSingleLine": 1 ** Step1: Input**
import React from 'react';
import { DialogContent } from '../DialogContent';
import { Label } from '../Label';
import { Slugs } from '../Slugs';
import {
Details,
ToolReference
} from '@my-package/components; ** Step 2: Execute Output
import React from 'react';
import {
Details,
ToolReference,
} from '@my-package/components;
import { DialogContent } from '../DialogContent';
import { Label } from '../Label';
import { Slugs } from '../Slugs'; ** Step 3: Execute import React from 'react';
import { DialogContent } from '../DialogContent';
import { Label } from '../Label';
import { Slugs } from '../Slugs';
import {
Details,
ToolReference,
} from '@my-package/components; You are right, that trailing comma after a multi-line named import seems to be the issue. What do you think? |
you still have a missing quote from your import path, this is causing problems I believe. This is not intentional is it? Shouldn't it be |
Sorry, you are right, but this is just ja copy-paste mistake that I made, since I did not want to disclose actual package name. The actual code has correct number of quotes. |
I see. It appears the trailing comma functionality is broken and prevents correct sorting. |
fix released in v1.17.0 |
Hey!
Love this extension! It's amazing and saving me tons of my time! Thank you so much for making it!
I have observed following behavior for named imports and wanted to check if this is how it is supposed to be:
Observed behavior
Expected behavior
For me, following sort-order would make much more sense:
Please let me know your opinion. Would be happy to contribute myself. Just wanted to align with you upfront.
My config
The text was updated successfully, but these errors were encountered: