-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# `no-processes` | ||
|
||
Discourage the use of the deprecated Processes layer. | ||
|
||
Examples of project structures that pass this rule: | ||
|
||
``` | ||
📂 shared | ||
📂 ui | ||
📄 index.ts | ||
📂 lib | ||
📄 index.ts | ||
📂 entities | ||
📂 user | ||
📂 ui | ||
📂 model | ||
📄 index.ts | ||
📂 pages | ||
📂 home | ||
📂 ui | ||
📄 index.ts | ||
``` | ||
|
||
Examples of project structures that fail this rule: | ||
|
||
``` | ||
📂 shared | ||
📂 ui | ||
📄 index.ts | ||
📂 lib | ||
📄 index.ts | ||
📂 entities | ||
📂 user | ||
📂 ui | ||
📂 model | ||
📄 index.ts | ||
📂 pages | ||
📂 home | ||
📂 ui | ||
📄 index.ts | ||
📂 processes // ❌ | ||
📂 cart | ||
``` | ||
|
||
## Rationale | ||
|
||
The Processes layer was deprecated because there weren't enough use cases to justify its exitsence. | ||
|
||
If your project has this layer, consider moving the code from this layer into App or Features. |
51 changes: 51 additions & 0 deletions
51
packages/steiger-plugin-fsd/src/no-processes/index.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { expect, it } from 'vitest' | ||
|
||
import noProcesses from './index.js' | ||
import { parseIntoFsdRoot } from '../_lib/prepare-test.js' | ||
|
||
it('reports no errors on a project without the Processes layer', () => { | ||
const root = parseIntoFsdRoot(` | ||
📂 shared | ||
📂 ui | ||
📄 index.ts | ||
📂 lib | ||
📄 index.ts | ||
📂 entities | ||
📂 user | ||
📂 ui | ||
📂 model | ||
📄 index.ts | ||
📂 pages | ||
📂 home | ||
📂 ui | ||
📄 index.ts | ||
`) | ||
|
||
expect(noProcesses.check(root)).toEqual({ diagnostics: [] }) | ||
}) | ||
|
||
it('reports errors on a project with the Processes layer', () => { | ||
const root = parseIntoFsdRoot(` | ||
📂 shared | ||
📂 ui | ||
📄 index.ts | ||
📂 lib | ||
📄 index.ts | ||
📂 entities | ||
📂 user | ||
📂 ui | ||
📂 model | ||
📄 index.ts | ||
📂 pages | ||
📂 home | ||
📂 ui | ||
📄 index.ts | ||
📂 processes | ||
📂 cart | ||
📂 ui | ||
📄 index.ts | ||
`) | ||
|
||
const diagnostics = noProcesses.check(root).diagnostics | ||
expect(diagnostics).toEqual([{ message: 'Layer "processes" is deprecated, avoid using it' }]) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { basename } from 'node:path' | ||
import type { Diagnostic, Rule } from '../types.js' | ||
|
||
const noProcesses = { | ||
name: 'no-processes', | ||
check(root) { | ||
const diagnostics: Array<Diagnostic> = [] | ||
|
||
const processesLayer = root.children.find( | ||
(child) => child.type === 'folder' && basename(child.path) === 'processes', | ||
) | ||
|
||
if (processesLayer !== undefined) { | ||
diagnostics.push({ | ||
message: 'Layer "processes" is deprecated, avoid using it', | ||
}) | ||
} | ||
|
||
return { diagnostics } | ||
}, | ||
} satisfies Rule | ||
|
||
export default noProcesses |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters