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

Add a note about the App layer exception #156

Merged
merged 1 commit into from
Jan 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion packages/steiger-plugin-fsd/src/insignificant-slice/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# `insignificant-slice`

It detects slices that have no references to suggest removing them, and also slices that have just one reference, to suggest merging it into the layer above. Note that pages are allowed to only have one reference, as they are the almost like entry points to the application.
It detects slices that have no references to suggest removing them, and also slices that have just one reference, to suggest merging it into the layer above.

Note that pages are allowed to only have one reference, as they are the almost like entry points to the application. Another exception is when slices are only used on the App layer — this doesn't count as a violation of the rule because the App layer shouldn't contain UI, so there's a valid reason for the code to remain on the lower layers.

Example of a project structure that passes this rule (arrows signify imports):

Expand Down Expand Up @@ -32,6 +34,26 @@ flowchart BT
pages/editor/ui/EditorPage.tsx --> pages/editor/ui/Editor.tsx
```

```mermaid
flowchart BT
subgraph widgets
subgraph widgets/sidebar[sidebar]
subgraph widgets/sidebar/ui[ui]
widgets/sidebar/ui/Sidebar.tsx[Sidebar.tsx]
end
widgets/sidebar/index.ts[index.ts]
end
end

subgraph app
subgraph app/routing[routing]
app/routing/routes.ts[routes.ts]
end
end

app/routing/routes.ts --> widgets/sidebar/index.ts
```

Example of a project structure that fails this rule:

```mermaid
Expand Down
Loading