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

Rule for banning export {} from '...' #3078

Open
blended-bram opened this issue Oct 2, 2024 · 2 comments
Open

Rule for banning export {} from '...' #3078

blended-bram opened this issue Oct 2, 2024 · 2 comments

Comments

@blended-bram
Copy link

A new rule that allows you to ban the creation of export {} from '...'.

This will help enforce a policy to not create barrel files, which are index.js / index.ts files that only serves to export parts of other modules.

This is not a commentary on the good or bad for this way of organizing modules and packages, I'd just like to be able to set up linting rules over its usage.

With eslint's own settings we can already control the file patterns any individual rule applies to.
Perhaps having a flag to distinguish between export-only files and files that mix re-exported elements and exports of locally defined elements. Although that could also be achieved with lint-ignore comments.

@blended-bram blended-bram changed the title Rule for banning barrel files Rule for banning export {} from '...' Oct 2, 2024
@ljharb
Copy link
Member

ljharb commented Oct 2, 2024

Barrel files are incredibly bad, and commentary on that is welcome.

You can already ban this form with no-restricted-syntax, so it doesn't really make sense to make a full-blown rule for it.

If you want a "no barrel files" rule, that would have more merit.

@blended-bram
Copy link
Author

I didn't know about no-restricted-syntax; thanks for pointing it out.
Then this issue can become a direct feature request for a no-barrel-exports rule.

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

No branches or pull requests

2 participants