Skip to content

Commit 5050ab9

Browse files
committed
feat: update enforce-import-boundaries documentation and tests to allow global services and stores imports
1 parent 48e504b commit 5050ab9

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

docs/rules/enforce-import-boundaries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ Rules implemented by this lint rule (short):
2121
- Modules (`src/modules/<name>`): isolated from other modules — importing other modules or their internals is forbidden.
2222
- Features (`src/features/<name>`): isolated from other features — importing other features is forbidden. Features must not import modules directly.
2323
- Composables / Components (`src/composables`, `src/components`): should not import app/modules/features internals — these are global-business layers and should stay framework-agnostic.
24-
- Services (`src/services`): allowed to import `stores`, `entities`, `shared` only.
25-
- Stores (`src/stores`): allowed to import `entities`, `shared` only.
24+
- Services (`src/services`): allowed to import other `services`, `stores`, `entities`, `shared`.
25+
- Stores (`src/stores`): allowed to import other `stores`, `entities`, `shared`.
2626
- Entities (`src/entities`): allowed to import `entities`, `shared` only.
2727
- Shared (`src/shared`): must be self-contained; importing other layers is forbidden.
2828

docs/vue3-project-modules-blueprint.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,8 @@ The modular architecture follows a strict 6-layer hierarchy where each layer has
861861
| 🟡 **features/** | Shared Business, State, Data, Utility layers | ❌ No cross-feature imports |
862862
| 🟢 **composables/** | Components, Services, State, Data, Utility | Cross-reference with components |
863863
| 🟢 **components/** | Composables, Services, State, Data, Utility | Cross-reference with composables |
864-
| 🟢 **services/** | State, Data, Utility layers | No service-to-service imports |
865-
|**stores/** | Data, Utility layers | State management kernel |
864+
| 🟢 **services/** | State, Data, Utility layers | Global services can import other global services |
865+
|**stores/** | Data, Utility layers | Global stores can import other global stores |
866866
| 🔵 **entities/** | Other entities, Utility layer | Entity relationships allowed |
867867
| 🟣 **shared/** | Self-contained | Foundation layer - no imports |
868868

@@ -888,8 +888,8 @@ The modular architecture follows a strict 6-layer hierarchy where each layer has
888888
| **`features/`** ||||||||||
889889
| **`composables/`** ||||||||||
890890
| **`components/`** ||||||||||
891-
| **`services/`** |||||| ||||
892-
| **`stores/`** ||||||| |||
891+
| **`services/`** |||||| ||||
892+
| **`stores/`** ||||||| |||
893893
| **`entities/`** ||||||||||
894894
| **`shared/`** ||||||||||
895895

@@ -1450,13 +1450,13 @@ export default {
14501450
import { useApi } from '@/composables/useApi'
14511451
```
14521452

1453-
2. **`services/` cross-referencing**: **Forbidden**
1453+
2. **`services/` cross-referencing**: **Allowed for global services**
14541454

14551455
```javascript
1456-
// ❌ Services should not import from each other
1456+
// ✅ Global services can import other global services
14571457
import { authService } from '@/services/auth' // from userService
14581458

1459-
// ✅ Use dependency injection or shared stores instead
1459+
// ✅ Also can use dependency injection or shared stores
14601460
import { useAuthStore } from '@/stores/auth'
14611461
```
14621462

tests/enforce-import-boundaries.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ describe('vue-modular/enforce-import-boundaries rule', () => {
3434
filename: '/src/modules/admin/pages/Users.vue',
3535
options: [{ allow: ['@/modules/allowed/*'] }],
3636
},
37+
// ✅ Global services can import other global services
38+
{ code: "import { authService } from '@/services/auth'", filename: '/src/services/user/api.js' },
39+
{ code: "import apiClient from '@/services/http'", filename: '/src/services/auth/index.js' },
40+
// ✅ Global stores can import other global stores
41+
{ code: "import { useAuthStore } from '@/stores/auth'", filename: '/src/stores/user.js' },
42+
{ code: "import appStore from '@/stores/app'", filename: '/src/stores/settings.js' },
3743
// (Type-only import tests require a TS parser; skipped here)
3844
],
3945
invalid: [

0 commit comments

Comments
 (0)