-
Notifications
You must be signed in to change notification settings - Fork 55
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
Custom sort order #508
Comments
This is an interesting idea. Can you help me understand your use case a little more? |
On 📱 so short answer: it's not sorting my imports the way I want it to. I could give you a more thorough explanation with examples later if you want |
Yes, examples would be useful! |
So,
is sort of how I want to sort my imports. Preferably with whitespace. Now, with |
Do you have the |
{
sortImports: true,
groupImports: true
} is my configuration when trying this feature. Actually, after playing around a bit with the configuration I noticed that {
sortImports: false,
groupImports: true
} is good enough for what I want. (it would be nice if I could write my own sorting function to sort things exactly like in #508 (comment) - but it's way more than what I often need) |
To add, the ideal (for me) is the following sort order: import React from 'react'; // these should always be first. Prefer React to be first.
import PropTypes from 'prop-types'; // because they're "absolute" packages from node_modules
import { Grid } from '../../something'; // this is a relative import and an "edit distance" of 2 away from my current file. It should be its own group.
import { Button, ButtonTypes, Icon, IconTypes } from '../something'; // this is a relative import and an "edit distance" of 1 away from my current file. It should be its own group
// It would be "fine" to group all imports with an edit distance >0 as well
import Heading from './components/Heading'; // this has a named export and is relative to my current file and an "edit distance" of 0
import List from './components/List'; // same here. The order of `Heading` and `List` doesn't really matter, IMO.
import './styles.scss'; // edit distance of 0 without any value being imported. specifically a stylesheet so I prefer it last. The case around "edit distance" determining the grouping seems general enough but the specifics around |
I think it would be nice to be able to add a custom sort function to allow for a customized sort order.
The text was updated successfully, but these errors were encountered: