Validate Feature-Sliced Design architecture compliance. Checks layer imports, public API usage, and cross-slice violations...
Validates Feature-Sliced Design compliance for this codebase.
The project follows strict FSD methodology:
app → pages → widgets → features → entities → shared
Rules:
index.ts)@/* aliasCheck that imports respect the hierarchy:
app can import: pages, widgets, features, entities, sharedpages can import: widgets, features, entities, sharedwidgets can import: features, entities, sharedfeatures can import: entities, sharedentities can import: shared, other entities (same layer allowed)shared can only import: sharedAll imports from entities, features, pages, widgets must go through index.ts
// CORRECT
import { Article } from '@/entities/Article';
// WRONG - bypasses public API
import { Article } from '@/entities/Article/model/types';
Within the same layer, slices should not import each other directly:
// In features/AuthByUsername - WRONG
import { something } from '@/features/AnotherFeature';
Check if slices have proper index.ts exports.
npx eslint "src/**/*.{ts,tsx}" --rule 'ulbi-tv-plugin/layer-imports: error' --rule 'ulbi-tv-plugin/public-api-imports: error' --rule 'ulbi-tv-plugin/path-checker: error'
When user invokes /fsd-check:
If argument provided (e.g., /fsd-check features):
If no argument:
For each check:
file:line - violation descriptionOutput summary:
# Features importing from pages/widgets
path: src/features/
pattern: from ['"]@/(pages|widgets)/
# Entities importing from features/pages/widgets
path: src/entities/
pattern: from ['"]@/(features|pages|widgets)/
# Shared importing from any other layer
path: src/shared/
pattern: from ['"]@/(entities|features|pages|widgets|app)/
# Deep imports into slices (more than 2 segments after @/)
pattern: from ['"]@/(entities|features|pages|widgets)/[^'"]+/[^'"]+
# Feature importing another feature (check current file path vs import)
# This requires analyzing file location context
Report findings as:
## FSD Violations Found
### Layer Import Violations (X found)
- `src/features/Auth/ui/LoginForm.tsx:15` - features cannot import from widgets
- `src/entities/User/model/slice.ts:3` - entities cannot import from features
### Public API Violations (X found)
- `src/widgets/Sidebar/ui/Sidebar.tsx:8` - import should be `@/entities/User` not `@/entities/User/model/types`
### Cross-Slice Violations (X found)
- `src/features/Auth/ui/Form.tsx:12` - feature should not import from another feature
### Summary
- Total: X violations
- Critical: X (layer violations)
- Fixable: X (public API - has autofix via ESLint)
For the user's reference:
# Run all FSD ESLint rules
npm run lint:ts -- --rule 'ulbi-tv-plugin/layer-imports: error'
# Check specific layer
npx eslint "src/features/**/*.{ts,tsx}" --rule 'ulbi-tv-plugin/layer-imports: error'
# Auto-fix public API imports
npx eslint "src/**/*.{ts,tsx}" --rule 'ulbi-tv-plugin/public-api-imports: error' --fix