-
Notifications
You must be signed in to change notification settings - Fork 11
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
Advanced configuration of no-private rule based on element types #198
Comments
Hi @dantman, I agree, given the great amount of different possible scenarios, it is a good idea to allow configuring this rule based on element types. But, maybe allowing to import any private element may be dangerous, so I think it would be also useful to define a new option For the moment, until the issue is solved, maybe you can use the eslint {
overrides: [
{
files: ["*.spec.tsx"],
rules: {
"boundaries/no-private": [0],
}
},
]
}
Thank you very much for your feedback 😃 |
I actually thought this was already the case when you had
So my biggest confusion was discovering this rule only applies when both private elements are of the same type. |
For better reference, my actual use case for no-private. I have feature elements at However various features, routes, and other elements do have an no-private would make this work as Maybe this all could be better expressed with |
The
Then, you want to allow importing In your case, as the The type of elements shouldn't be affecting to this rule, and, in case it is, of course it should be fixed. Could you please provide an example of code and your configuration in order to reproduce it? If it is not a bug, and it is related only to some misunderstanding about the rules, please provide a schematic example of your structure, and a list of the boundaries that you want to implement on it, so maybe I can help you with the configuration. |
Describe the bug
If a file of one element imports a file that is of a different element which is is a parent/uncle/etc no-private will block it.
To Reproduce
I've created a demo repo on StackBlitz where you can
npm run lint
.https://stackblitz.com/edit/node-jtplrw?file=.eslintrc.js
Expected behavior
In the example, the unit-test file should be able to import the ui file from its parent. Instead of getting an error that the file belonging to its parent is private.
Logs
Additional context
This can happen easily if you have a bunch of different element types. Having a variety of element types shouldn't be unexpected, as
boundaries/externals
exists and is a great way of defining rules like "only tests can import test libraries", "only UI components in our design library can import components from external UI libraries, other components must be made up of our UI components", or "only *.web.js files can import libraries that assume react-dom is present, for react-native-web users".I understand that if you have something like a "server" element with a "module" element inside of it. Then the idea of no-private not crossing element boundaries makes sense. But in the context of lighter element types this doesn't work out. Maybe the solution is for no-private to have an option for the change of behaviour or an option with an element matcher for what types of element boundaries should allow crossing / not make an element private.
The text was updated successfully, but these errors were encountered: