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

[New] add sort-by-length option to order rule #2051

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

[New] add sort-by-length option to order rule #2051

wants to merge 2 commits into from

Conversation

azat-io
Copy link

@azat-io azat-io commented May 7, 2021

Add option to import/order rule for sorting imports by length.

For example:

// { groups: ['external', 'index'], 'sort-by-length': { order: 'desc' } }

import { foo , bar } from 'module-name/path/to/specific/un-exported/file';
import { export1 as alias } from 'module-name-1';
import { export1, export2 } from 'module-name-2';
import defaultExport from 'module-name-3';
import { export3 } from 'module-4';
import * as name from 'module-5';

import index from './';
import './module';

@coveralls
Copy link

Coverage Status

Coverage increased (+14.4%) to 83.938% when pulling a313438 on azat-io:order-by-length into e871a9a on benmosher:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage increased (+14.4%) to 83.938% when pulling a313438 on azat-io:order-by-length into e871a9a on benmosher:master.

@coveralls
Copy link

coveralls commented May 7, 2021

Coverage Status

Coverage increased (+14.6%) to 84.144% when pulling 6289b54 on azat-io:order-by-length into e871a9a on benmosher:master.

@ai
Copy link
Contributor

ai commented May 11, 2021

My favorite way to sort imports

@ljharb
Copy link
Member

ljharb commented May 13, 2021

Is the intention here to sort by length of the module specifier only, or by the length of the whole line? if the latter, what happens to multiline named imports?

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

Successfully merging this pull request may close these issues.

4 participants