ld-cv
v1.0.3
Published
Frontend convention checker for React/Vue/TypeScript projects
Maintainers
Readme
ld-cv
Frontend convention checker for React/Vue/TypeScript projects with 33 built-in rules.
Installation
# Global installation
npm install -g ld-cv
# Or as dev dependency
npm install --save-dev ld-cvUsage
# Check a directory
ld-cv check ./src
# Check with custom config
ld-cv check ./src --config convention-checker.yaml
# Output as JSON
ld-cv check ./src --format json --output report.json
# Run specific rules only
ld-cv check ./src --rules no-any,no-magic-string
# List all available rules
ld-cv list-rules
# Generate default config file
ld-cv initRules (33 total)
Type Safety (4)
no-any- Disallowsanytypeno-null-undefined-unsafe- Ensure safe null/undefined handlingasync-return-type- Async functions must have explicit return typesreusable-types- Types should be reusable
Magic Values (3)
no-magic-string- Disallows magic stringsno-magic-number- Avoid magic numbersno-hardcoded-api-path- API paths should not be hardcoded
Naming Convention (3)
naming-convention- Functions should start with verbsboolean-prefix- Booleans should have is/has/can prefixdomain-language- Use domain-specific names
Component Structure (5)
max-component-lines- Components should not exceed 150 linesno-business-logic-in-component- No business logic in componentssingle-responsibility- Components should have single responsibilitypure-ui-component- UI components should be puresplit-conditional-render- Split 3+ conditional renders
React Patterns (9)
no-unnecessary-useeffect- Avoid unnecessary useEffectminimal-state- Avoid storing derivable values in stateno-conditional-hook- Hooks must not be called conditionallyuseeffect-cleanup- useEffect should have cleanupno-array-index-key- Avoid array index as keyno-inline-handler- No inline event handlersno-props-drilling- Detect props drillingrequired-loading-error-empty- Handle loading/error/empty statesuse-form-library- Use form library for complex forms
Async/API (3)
no-nested-async- Avoid nested asyncapi-response-mapping- Map API responses to domain typesresult-type-error- Prefer Result pattern
Code Quality (6)
no-deep-optional-chaining- Limit optional chaining depthextract-complex-condition- Extract complex conditionsno-deep-equal- Avoid deep equality checksno-new-date-in-component- Avoid new Date() in componentsserver-client-time- Distinguish server/client timeminimal-global-state- Minimize global state
Configuration
Create convention-checker.yaml:
version: "1.0"
frontend:
enabled: true
paths:
include: ["src/**/*.ts", "src/**/*.tsx"]
exclude: ["**/node_modules/**", "**/*.d.ts"]
rules:
no-any:
enabled: true
severity: ERROR
max-component-lines:
enabled: true
severity: WARNING
options:
max-lines: 150
output:
format: console
colors: true
fail-on-error: trueLicense
MIT
