Skip to content

Commit 6a5aec1

Browse files
committed
docs: update vue-modular-architecture.md to integrate ESLint plugin rules for modular architecture
1 parent 919e906 commit 6a5aec1

File tree

1 file changed

+2
-143
lines changed

1 file changed

+2
-143
lines changed

docs/vue-modular-architecture.md

Lines changed: 2 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -211,150 +211,9 @@ src/
211211
└── utilities.css # Utility classes
212212
```
213213

214-
## Rules
214+
## ESLint Plugin Integration
215215

216-
### File Organization Rules
217-
218-
- All Vue components must use PascalCase naming (e.g., `UserForm.vue`, `ProductList.vue`)
219-
- All TypeScript files must use camelCase naming (e.g., `useAuth.ts`, `userApi.ts`)
220-
- All folders must use kebab-case naming (e.g., `user-management/`, `auth/`)
221-
- Each feature folder must contain an `index.ts` file as its public API
222-
- All `components/` folders must contain an `index.ts` file for component exports
223-
- The `shared/ui/` folder must contain an `index.ts` file for UI component exports
224-
225-
### Dependency Rules
226-
227-
- Features cannot import from other features directly
228-
- Features can only import from `shared/` folder
229-
- `shared/` folder cannot import from `features/` or `views/`
230-
- `app/` folder can import from `shared/` and `features/` (exception: `app/router.ts` may import feature route files to compose the global router)
231-
- All cross-feature communication must go through the `shared/` layer
232-
233-
### Component Rules
234-
235-
- All Vue components should be written as Single File Components (SFC) with `.vue` extension
236-
- SFC blocks must be ordered: `<script>`, `<template>`, `<style>` (at least one of script or template must exist)
237-
- Layout-specific components must be in `app/components/`
238-
- Reusable UI components (design system) must be in `shared/ui/`
239-
- Business components used across features must be in `shared/components/`
240-
- Feature-specific components must be in `features/{feature}/components/`
241-
- Component props must be typed with TypeScript interfaces
242-
243-
### Service Rules
244-
245-
- Cross-cutting services must be in `shared/services/`
246-
- Feature-specific services must be in `features/{feature}/services/`
247-
- Service files must not have "Service" suffix (e.g., `auth.ts`, not `authService.ts`)
248-
- Services must export named classes or named functions (avoid default exports)
249-
- API services must use the shared `apiClient.ts`
250-
251-
### Store Rules
252-
253-
- Global state must be in `shared/stores/`
254-
- Feature-specific state must be in `features/{feature}/stores/`
255-
- Store files must use Pinia composition API syntax
256-
- Store files must not have "Store" suffix (e.g., `auth.ts`, not `authStore.ts`)
257-
- Cross-cutting concerns (auth, notifications) must be in `shared/stores/`
258-
- Feature stores cannot import other feature stores directly
259-
260-
### Type Rules
261-
262-
- Global types must be in `shared/types/`
263-
- Feature-specific types must be in `features/{feature}/types/`
264-
- Type files must export interfaces and types, not classes
265-
- Common utility types must be in `shared/types/common.ts`
266-
- API response types must be in `shared/types/api.ts`
267-
268-
### Routing Rules
269-
270-
- Global routes must be in `app/router.ts`
271-
- Feature routes must be in `features/{feature}/routes.ts`
272-
- Feature routes must be imported and merged in `app/router.ts`
273-
- Route components must be lazy-loaded using dynamic imports
274-
- Layout selection must be defined in route `meta.layout` property
275-
276-
### View Rules
277-
278-
- Feature views must be in `features/{feature}/views/`
279-
- Global views (not feature-specific) must be in `views/` folder
280-
- View files must end with `View.vue` suffix
281-
- Views cannot contain business logic (delegate to composables/services)
282-
- Layout selection must be defined in route metadata, not imported directly in views
283-
284-
### Composable Rules
285-
286-
- Global composables must be in `shared/composables/`
287-
- Feature composables must be in `features/{feature}/composables/`
288-
- Composable files must start with `use` prefix
289-
- Composables must return reactive refs and computed properties
290-
- Composables cannot directly manipulate DOM elements
291-
292-
### Asset Rules
293-
294-
- Global styles must be in `assets/styles/`
295-
- Images must be in `assets/images/`
296-
- Icons must be in `assets/icons/`
297-
- Fonts must be in `assets/fonts/`
298-
- Component-specific styles must be scoped within component files
299-
300-
### Utility Rules
301-
302-
- Global utilities must be in `shared/utils/`
303-
- Feature-specific utilities must be in `features/{feature}/utils/`
304-
- Utility files must export pure functions without side effects
305-
- Utility functions must be stateless and deterministic
306-
307-
### Middleware Rules
308-
309-
- Global route middleware must be in `app/middleware/`
310-
- Feature-specific middleware must be in `features/{feature}/middleware/`
311-
- Middleware files must use descriptive names (e.g., `authGuard.ts`, not `guard.ts`)
312-
- Route guards must be registered in feature route configurations
313-
- Middleware must be composable and chainable
314-
315-
### Plugin Rules
316-
317-
- Global plugin registration must be in `app/plugins.ts`
318-
- Plugin configurations must be environment-aware
319-
- Third-party plugins must be initialized before app mounting
320-
- Custom plugins must follow Vue.js plugin API conventions
321-
- Plugin dependencies must be clearly documented
322-
323-
### Environment/Config Rules
324-
325-
- Environment configurations must be type-safe
326-
- Configuration files must use `.env` files for environment variables
327-
- Sensitive data must not be committed to version control
328-
- Different environments (dev/staging/prod) must have separate config handling
329-
- Runtime configuration must be validated at application startup
330-
- App configurations must be in `app/config/` folder
331-
- Config files must export typed configuration objects
332-
333-
### Import Rules
334-
335-
- Use absolute imports with `@/` alias for cross-layer imports and shared resources
336-
- Use relative imports for same-feature or nearby file imports (within 2 levels)
337-
- Avoid relative imports with more than 2 levels (`../../../`) - use absolute instead
338-
- Import from `index.ts` files when available
339-
- Group imports: Vue imports, third-party imports, internal imports
340-
- Type imports must use `import type` syntax
341-
- Avoid deep imports into feature internals
342-
343-
### Export Rules
344-
345-
- Use named exports instead of default exports for better tree-shaking
346-
- Internal feature helpers should not be exported from their modules
347-
- Types must be exported with `export type` syntax
348-
- Components must use default exports and be re-exported as named exports in `index.ts`
349-
350-
### Naming Conventions
351-
352-
- Use camelCase for variables, function names, and named exports (e.g., `fetchUsers`, `getUserById`).
353-
- Use PascalCase for exported types, interfaces, classes, and component identifiers (e.g., `User`, `AuthState`, `UserCard`). Avoid `I` prefixes on interfaces
354-
- Prefix composable functions with `use` and keep them camelCase (e.g., `useAuth`, `useProductForm`).
355-
- Pinia store factory exports should follow Pinia's recommendation: start with `use` and include the `Store` suffix (e.g., `useAuthStore`, `useNotificationsStore`)
356-
- Use UPPER_SNAKE_CASE for compile-time constants and environment keys (e.g., `API_TIMEOUT_MS`) and camelCase for runtime constants.
357-
- Component-emitted custom event names should use kebab-case (e.g., `item-selected`, `save:success`).
216+
To enforce modular architecture patterns, use the `eslint-plugin-vue-modular` plugin. This plugin provides rules to ensure that your Vue.js project adheres to the modular architecture principles outlined above.
358217

359218
## Conclusion
360219

0 commit comments

Comments
 (0)