Skip to content

Commit 2e594fe

Browse files
committed
feat: add no-processes-layer rule to enforce folder structure
- Implemented `no-processes-layer` rule to disallow a `processes` folder under the project's `src` directory. - Added rule metadata and configuration options for ESLint. - Added utilities to manage run-once rule state and to parse rule options for tests. - Added unit tests for presence/absence of `processes`, error handling, and custom `src` configuration. - Added test helpers used to run the rule in isolation.
1 parent d35b313 commit 2e594fe

File tree

12 files changed

+926
-6
lines changed

12 files changed

+926
-6
lines changed

Makefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,32 @@
1-
@PHONY: lint install test update drawio
1+
.PHONY: install lint test update drawio
2+
23

34
install:
4-
npm install --no-audit --no-fund --prefer-offline
5+
npm install --no-audit --no-fund
56

67
lint:
78
npx eslint . --ext .ts,.js,.vue --fix
89
npx markdownlint --fix "**/*.md" -i node_modules
9-
npx prettier --write "**/*.md" "**/*.json" "**/*.js" "**/*.ts"
10+
npx prettier --write "**/*.md" "**/*.json" "**/*.js" "**/*.ts" --log-level warn
1011

1112
test: lint
12-
echo "CI=CI npx vitest"
13+
CI=CI npx vitest
1314

1415
update:
1516
npx npm-check-updates -u
16-
npm install --no-audit --no-fund --prefer-offline
17+
npm install --no-audit --no-fund
1718

1819
drawio:
19-
/mnt/c/Program\ Files/draw.io/draw.io.exe -x -o docs/assets --transparent -f png docs/assets/drawio/*.drawio
20+
@if [ -z "$(DRAWIO_CMD)" ]; then \
21+
if [ -x "/mnt/c/Program Files/draw.io/draw.io.exe" ]; then DRAWIO_CMD="/mnt/c/Program Files/draw.io/draw.io.exe"; \
22+
elif [ -x "/Applications/draw.io.app/Contents/MacOS/draw.io" ]; then DRAWIO_CMD="/Applications/draw.io.app/Contents/MacOS/draw.io"; \
23+
elif [ -x "/Applications/diagrams.net.app/Contents/MacOS/diagrams.net" ]; then DRAWIO_CMD="/Applications/diagrams.net.app/Contents/MacOS/diagrams.net"; \
24+
elif command -v draw.io >/dev/null 2>&1; then DRAWIO_CMD="$$(command -v draw.io)"; \
25+
elif command -v diagrams.net >/dev/null 2>&1; then DRAWIO_CMD="$$(command -v diagrams.net)"; \
26+
else DRAWIO_CMD=""; fi; \
27+
fi; \
28+
if [ -z "$$DRAWIO_CMD" ]; then \
29+
echo "draw.io/diagrams.net not found. Install it or set DRAWIO_CMD environment variable."; \
30+
exit 1; \
31+
fi; \
32+
"$$DRAWIO_CMD" -x -o docs/assets --transparent -f png docs/assets/drawio/*.drawio

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,45 @@
99
[![License](https://img.shields.io/npm/l/eslint-plugin-vue-fsd.svg)](LICENSE)
1010

1111
A custom ESLint plugin for enforcing FSD patterns in Vue projects.
12+
13+
> [!NOTE]
14+
> The project is in active development and may have breaking changes in minor versions, but we will strive to keep changes minimal and well-documented.
15+
16+
![FSD Pattern](docs/assets/fsd.png)
17+
18+
## Features
19+
20+
- Enforces FSD (Feature-Sliced Design) architecture patterns in Vue.js projects.
21+
- Provides a set of rules and guidelines for structuring Vue components and their interactions.
22+
- Includes a set of predefined configurations for different project setups.
23+
24+
## Installation
25+
26+
```bash
27+
npm install eslint-plugin-vue-fsd --save-dev
28+
```
29+
30+
## Usage
31+
32+
```javascript
33+
import vueFsdPlugin from 'eslint-plugin-vue-fsd'
34+
35+
// .eslintrc.js
36+
module.exports = {
37+
...vueFsdPlugin.configs.recommended,
38+
}
39+
```
40+
41+
## Rules
42+
43+
| Rule | Description |
44+
| ---------------------------------------------------------- | ---------------------------------------------- |
45+
| `[no-processes-layer](./docs/rules/no-processes-layer.md)` | Ensure deprecated processes layer is not used. |
46+
47+
## Contribution
48+
49+
Pull requests and issues are welcome! Please follow the code style and add tests for new rules.
50+
51+
## License
52+
53+
MIT, see [LICENSE](./LICENSE) for details.

docs/assets/drawio/fsd.drawio

Lines changed: 262 additions & 0 deletions
Large diffs are not rendered by default.

docs/assets/fsd.png

549 KB
Loading

docs/rules/no-processes-layer.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# no-processes-layer
2+
3+
Disallow a `processes` folder inside your `src` tree.
4+
5+
## Why
6+
7+
This repository enforces a layered architecture where certain folders are reserved or deprecated.
8+
The `processes` folder is considered a deprecated layer for the Feature-Sliced Design architecture. The rule prevents the presence of a `processes` directory inside your configured `src` path.
9+
10+
The rule is intentionally conservative: it reports once per linting session to reduce noise from the same structural problem appearing in many files.
11+
12+
## Rule details
13+
14+
- Rule name: `vue-fsd/no-processes-layer`
15+
- Default messageId: `forbidden`
16+
- Type: `problem`
17+
18+
This rule checks whether the configured `src` path contains a top-level `processes` directory.
19+
20+
The rule reports at most once per linting session to avoid repeated identical messages across many files.
21+
22+
## Options
23+
24+
The rule accepts a single options object with the following property:
25+
26+
- `src` (string) — the path/alias to your project's source root. Default: `"src"`.
27+
28+
Example (ESLint config):
29+
30+
```json
31+
{
32+
"plugins": ["vue-fsd"],
33+
"rules": {
34+
"vue-fsd/no-processes-layer": ["error", { "src": "src" }]
35+
}
36+
}
37+
```
38+
39+
If your project uses a custom alias or a non-standard src path, pass that string via `src`.
40+
41+
## Examples
42+
43+
Bad:
44+
45+
```text
46+
// filesystem: src/processes/
47+
src/processes/handler.js
48+
```
49+
50+
Good:
51+
52+
```text
53+
// keep code in another allowed layer (services, workers, etc.)
54+
src/services/processor.js
55+
```
56+
57+
## When not to use
58+
59+
Avoid using this rule in the following cases:
60+
61+
- When migrating an existing codebase that heavily relies on the `processes` layer. In such cases, consider using the rule in a more lenient mode or with exceptions.
62+
- When working on experimental features or prototypes that may not adhere to the established folder structure.
63+
64+
## References
65+
66+
- [ESLint Documentation](https://eslint.org/docs/user-guide/configuring)
67+
- [Feature-Sliced Design](https://feature-sliced.design/)

0 commit comments

Comments
 (0)