Skip to content

Commit

Permalink
Add a note about the App layer exception
Browse files Browse the repository at this point in the history
  • Loading branch information
illright committed Dec 26, 2024
1 parent caa9ede commit fc2ede8
Showing 1 changed file with 23 additions and 1 deletion.
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

0 comments on commit fc2ede8

Please sign in to comment.