-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 rule: no-wildcard-export #2493
Comments
I'm not familiar with that tool, but I'm not sure why it would break static analysis - you'd just bounce over to the other file and see what that exports. |
It is possible that it is a limitation of the tool. Nonetheless, it is caused by Don't want to muddy the waters, but I would also argue that |
I agree; re-exporting should be avoided whether it’s explicit or implicit. I don’t however think that the unnecessary limitations of one arbitrary tool is a reasonable motivation for a rule (considering no-restricted-syntax can already ban it). |
If we rephrase the issue as the code legibility, is that not a good enough reason for introducing the rule? Good hint about |
I think if a compelling enough case can be presented, then yes - but i suspect such a case would also discourage any re-exporting, whether with |
IMO the main usecase for a rule like this over Especially in tests where modules are often isolated, knowing what exports are available from a file prevents having to parse that file when none of the exports are actually needed. This can substantially speed up build times on larger projects. While barrel files aren't best practice, they're still widely used across the industry and ecosystem. A lint rule like this would remove some of the pitfalls (duplicate exports, lack of clarity on where exports are coming from, etc), and improve build speeds potentially substantially. |
My question would be why |
I feel that's somewhat of a poor reason to not have a linting rule. Linting rules exist to match preferences of a codebase, and for codebases that want this it can have a major impact. While these seem to break A rule like this that makes barrel files more usable and performant on larger codebases IMO makes a lot of sense. I don't believe this should be in the recommended set of linting rules, just one that people can enable themselves if they want. |
@JounQin quite a lot of things that are now considered harmful exist in the ES spec - existence in any spec is never an inherent endorsement for using anything. Explicit > implicit, and if you don't want to manage exports in a lot of places, don't re-export them anywhere - instead, deep import exactly what you need from the lone place it should be exported from. @me4502 Barrel files are harmful - they cause tons of bundle/memory bloat that treeshaking can never fully account for, as well as conceptual and maintenance burden. They should not be made easier to use, they should be actively prevented. |
I'd like to enable a rule like this in our codebase. It would be helpful to enforce more explicit reexports in a few places, but we still find the barrel file pretty ergonomic. Are you open to contributions here? I could look into it, just want to make sure there's a green light. |
I came to this thread from Google Search. I think Just fyi. As people suggested above, we can ban
|
Examples
✅ Valid with
no-wildcard-export
❌ Invalid with
no-wildcard-export
Why?
export *
breaks static analysis of tools like unimported, effectively making it impossible to determine if there is unused code in the codebase.The text was updated successfully, but these errors were encountered: