Loading...
Loading...
Implements and enforces code quality gates for TypeScript/React projects. Use when setting up Biome/ESLint/TypeScript, configuring pre-commit hooks (Husky), fixing lint errors, or running quality checks. Examples - "setup code quality", "fix lint errors", "configure Biome", "run quality checks".
npx skill4agent add d-oit/do-novelist-ai code-quality-managementQuality Gates Sequence:
- [ ] Step 1: Format code (Biome)
- [ ] Step 2: Lint code (ESLint + TypeScript)
- [ ] Step 3: Type check (TypeScript)
- [ ] Step 4: Run unit tests (Vitest)
- [ ] Step 5: Run E2E tests (Playwright)npm run lint && npm run type-check && npm run testnpm install -D @biomejs/biome eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
npm install -D eslint-plugin-react-hooks eslint-plugin-react-refresh
npm install -D husky lint-staged vitest @playwright/test{
"scripts": {
"build": "vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:fix": "eslint . --ext ts,tsx --fix",
"lint:ci": "eslint . --ext ts,tsx --max-warnings 0",
"format": "biome format --write .",
"format:check": "biome format --write --dry-run .",
"type-check": "tsc --noEmit",
"test": "vitest run",
"test:coverage": "vitest run --coverage",
"test:e2e": "playwright test",
"test:e2e:ui": "playwright test --ui",
"prepare": "husky"
}
}biome.json{
"$schema": "https://biomejs.dev/schemas/1.9.0/schema.json",
"organizeImports": { "enabled": true },
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"style": { "useImportType": "error", "useConst": "error" },
"suspicious": { "noExplicitAny": "warn" },
"correctness": {
"noUnusedVariables": "error",
"noUnusedImports": "error"
}
}
},
"formatter": { "enabled": true }
}.eslintrc.cjsmodule.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parser: '@typescript-eslint/parser',
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'react-hooks/rules-of-hook': 'error',
'react-hooks/exhaustive-deps': 'warn',
},
};tsconfig.json{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"types": ["vite/client"]
},
"include": ["src"]
}npx husky init.husky/pre-commit#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npm run lint:ci.lintstagedrc.json{
"*.{ts,tsx}": [
"biome check --write --no-errors-on-unmatched",
"eslint --ext .ts,.tsx --fix --no-error-on-unmatched"
],
"*.{js,jsx}": [
"biome check --write --no-errors-on-unmatched",
"eslint --fix --no-error-on-unmatched"
],
"*.json": ["biome check --write"],
"package.json": ["prettier --write"]
}vitest.config.tsimport { defineConfig } from 'vitest/config';
import path from 'path';
export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
coverage: { provider: 'v8', reporter: ['text', 'html', 'lcov'] },
},
resolve: { alias: { '@': path.resolve(__dirname, './src') } },
});playwright.config.tsimport { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
fullyParallel: true,
reporter: 'html',
use: { baseURL: 'http://localhost:4173', trace: 'on-first-retry' },
projects: [{ name: 'chromium', use: { ...devices['Desktop Chrome'] } }],
webServer: {
command: 'npm run dev',
url: 'http://localhost:4173',
timeout: 120000,
},
});Daily Development:
- [ ] Format during development: npm run format
- [ ] Fix lint issues: npm run lint:fix
- [ ] Run unit tests: npm run test:watch
- [ ] Before committing: npm run lint:ci && npm run type-check && npm run test
- [ ] Run E2E tests: npm run test:e2enpm run format # Fix formatting
npm run lint:fix # Fix linting
npm run type-check # Check types
npm run test # Run unit tests
npm run test:e2e # Run E2E testsnpm run lint && npm run type-check && npm run test.github/workflows/quality.ymlname: Quality Checks
on: [push, pull_request]
jobs:
quality:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20', cache: 'npm' }
- run: npm ci
- run: npm run format:check
- run: npm run lint:ci
- run: npm run type-check
- run: npm run test:coverage
- run: npx playwright install --with-deps
- run: npm run test:e2e
env: { CI: true }anyunknownanynpm run test # Unit tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
npm run test:e2e # E2E tests
npx playwright show-report # View test report# During development
npm run format && npm run lint:fix
# Before commit
npm run lint:ci && npm run type-check && npm run test
# Full check (includes E2E)
npm run lint && npm run type-check && npm run test && npm run test:e2e