-
-
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
Add ignore pattern before using unusedExports by default #2970
Comments
This seems like it would promote the antipattern of "barrel files" - the best practice is for each file to export a single thing. This is ofc less important for types, but I'm not clear on why you'd want to check the JS exports but not the types? |
Thanks for raising the potential antipattern of "barrel files". Which I agree we should avoid. The use cas would apply for example when we got a custom built-in library. This library has components. A component We don't want developers to edit the DS to export the props when other developers need it. Similar to the flexibility offered by no-unused-vars with |
In that case, would perhaps an |
The problem of the |
I'm still very confused. I understand why you'd want to check for unused exported types. I also understand why you'd want to have entry point files (whether they export types or values or both) not checked. I'm not clear on why, within a single file, you'd want some items checked and some not, since if a file is an entry point, everything it exports is part of its API. |
Got it! Let me clarify with an example: Consider MyBox.tsx:
In this case, By allowing selective checking, we strike a balance between ensuring that their is no used export / dead code while still providing flexibility for developers to use supporting elements as needed. Let me know if this clarifies things! |
ok, so this isn't for entrypoints at all, it's because you want every component to have the same exported types even if they're unused? what happens if the component is unused but the types are used? |
Not sure to follow what you mean by "ok, so this isn't for entrypoints at all, it's because you want every component to have the same exported types even if they're unused?". Each component its prop.
I'm not sure for which context your question is. But let's say we have a kinda The component is unused, eslint yell. If you're afraid of users deleting the component while the type is used, I'd say, if the user has added an ignore pattern then they should be carful. |
Before doing #1324 We should have a
varsIgnorePattern
or similar. There is cases where you don't want to remove all unsued exports.For example in some project when we have a custom library / DS we export the props from the component files. Though we do not want to ignore the files itself, only interface / type that end with
Props
The text was updated successfully, but these errors were encountered: