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

order exports #1888

Open
gajus opened this issue Aug 20, 2020 · 10 comments
Open

order exports #1888

gajus opened this issue Aug 20, 2020 · 10 comments

Comments

@gajus
Copy link
Contributor

gajus commented Aug 20, 2020

Surprisingly do not see an existing issue for this, but I would like to have an equivalent of order with alphabetize for exports.

This would esp. useful for files that only contain exports, e.g.

// @flow

export {
  default as createLogDump,
} from './createLogDump';
export {
  default as createSnackTimeEvent,
} from './createSnackTimeEvent';
export {
  default as executeMaintenanceTask,
} from './executeMaintenanceTask';
export {
  default as inviteSlackTeamUsersToSnackClubChannel,
} from './inviteSlackTeamUsersToSnackClubChannel';
export {
  default as pairSnackTimeEventParticipants,
} from './pairSnackTimeEventParticipants';

At the moment, these exports are in a random order.

Enforcing export order when file only contains exports would be useful.

@tfoxy
Copy link

tfoxy commented Sep 2, 2021

Related to #659. In that case it's for exported members, but some people are commenting libraries that solve the exported module order issue.

@aaronadamsCA
Copy link
Contributor

@gajus Is it fair to say your request here is limited to re-exports, aka export ... from?

That's all I care about personally. Given re-export syntax appears to be a subset of import syntax, it might be a far simpler request to fulfill.

@gajus
Copy link
Contributor Author

gajus commented Jan 3, 2022

Correct. If anyone is keen to contribute, consider adding it to https://github.com/gajus/eslint-plugin-canonical

@ljharb
Copy link
Member

ljharb commented Jan 3, 2022

I'd be happy to accept a PR for a new rule here.

@gajus
Copy link
Contributor Author

gajus commented Jan 3, 2022

or that. I only suggest eslint-plugin-canonical because it is a playground to quickly release and test rules. eslint-plugin-import is more mature and careful in its release of features.

@guillaumeduboc
Copy link

Hey all,
I'd love to see this in eslint-plugin-import and I started looking into it

I listed all these kind of re-exports I'd like to handle (I may have forgotten some)

export * from "module-name";
export * as name1 from "module-name";

export { default } from "module-name";

export { name1, /* …, */ nameN } from "module-name";
export { import1 as name1, import2 as name2, /* …, */ nameN } from "module-name";
export { default as name1 } from "module-name";

export type * from "module-name";

export type { name1 } from "module-name";

@ljharb do you imagine the exports should be grouped (same as imports) ?
for the moment I'm thinking about creating a new rule with only the order but eventually adding grouping, new lines, etc...

@ljharb
Copy link
Member

ljharb commented Apr 5, 2023

I would assume that all the same options for imports would govern exports, whenever it makes sense.

@guillaumeduboc
Copy link

I suggest we do a different rule, but I might move some logic around
I was thinking putting some of the order logic in core

@carlocorradini
Copy link

Super! Any ETA? 🥳

@guillaumeduboc
Copy link

no idea yet, I've just started looking into it 😁

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

No branches or pull requests

6 participants