feature-sliced / steiger

Universal file structure and project architecture linter
https://www.npmjs.com/package/steiger
MIT License
18 stars 0 forks source link

Bug: Folder name "entity-card/ui" in "shared/ui" is reserved for segment names #46

Open EliseyMartynov opened 1 week ago

EliseyMartynov commented 1 week ago

Правило: no-reserved-folder-names. Не совсем понятно что именно тут нарушается.

Sandbox: https://codesandbox.io/p/devbox/steiger-test-g4f4wp

illright commented 1 week ago

This is a rule that forbids having folders with segment-like names inside segments: https://github.com/feature-sliced/steiger/blob/master/packages/steiger-plugin-fsd/src/no-reserved-folder-names/README.md

For example, you can't have shared -> ❗️ ui -> entity-card -> ❌ ui to avoid confusion

EliseyMartynov commented 1 week ago

But wait.. Segments can be complicated, and entity-card can have their own segment ui just because it can be complicated. So we can just turn off this rule?

illright commented 1 week ago

It's true that segments can be complicated, but I don't see how you would need to subdivide to ui if you (theoretically) have already excluded all non-UI code. For instance, for this structure:

EliseyMartynov commented 1 week ago

It doesn't make sense with api, but make sense with other segments like model (why not)?

illright commented 1 week ago

but make sense with other segments like model (why not)?

If I'm inside a segment ui, I expect to only find code related to UI, not the data model. The data model has its own segment, model, which is where I'd go to look for that code. So for me, it never makes sense to have segments inside of segments

EliseyMartynov commented 1 week ago

Can't accept that. There are plenty UI elements that can have internal state, such as select-box. So where should I place logic? In UI segment?

illright commented 1 week ago

Not every instance of state needs to be a model. For example, a select box might track the state of selected options, but this is not business logic, so I would simply write that state inside the component, or in a sibling file.