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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

import/order: Impose custom ordering within groups #1378

Open
futpib opened this issue Jun 11, 2019 · 7 comments
Open

import/order: Impose custom ordering within groups #1378

futpib opened this issue Jun 11, 2019 · 7 comments

Comments

@futpib
Copy link
Contributor

futpib commented Jun 11, 2019

For example, new option could look like this:

{
	"withinGroups": {
		"external": [
			"ramda",
			"react"
		]
	}
}

With this option, this would pass 馃憤:

import { compose } from 'ramda';
import React from 'react';

And this would fail 馃憥:

import React from 'react';
import { compose } from 'ramda'; // error: should be placed above `react`

If a package without configured order is imported, it could be ignored:

import { compose } from 'ramda';
import somethingElse from 'something-else'; // could be placed anywhere within the "external" group, as it is not mentioned in the config
import React from 'react';
@ljharb
Copy link
Member

ljharb commented Jun 11, 2019

Why? What鈥檚 the reason you鈥檇 want ordering, but also an arbitrary order?

@futpib
Copy link
Contributor Author

futpib commented Jun 11, 2019

I primarily want ordering, arbitrary order only as a fallback for imports from packages for which the order is not configured. Another option is to report such imports to force users to update their configuration.

@kyranjamie
Copy link

Came here to second this. Ordering alphabetical means very little to me, personally. I want to group my domain/purpose. Beginning with framework, for example. An Angular app, @angular/* goes first, react then react etc

@billyvg
Copy link

billyvg commented May 19, 2020

This is something I'm looking for so that we can also enforce new lines between custom groups.

@kevinwolfcr
Copy link

I think #1746 is related to this.

@amannn
Copy link

amannn commented Jul 9, 2020

I have a use case that might be related to this.

import React from 'react';
import Button from 'components/Button';
import config from './config';
import styles from './ErrorBoundaryError.scss';

In this case import/order wants to put styles before config.

I'd like to always have imports to a local stylesheet at the very bottom. Ideally I'd be able to match files based on a glob within a group and move them to the bottom.

@tyteen4a03

This comment was marked as spam.

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

No branches or pull requests

7 participants