TypeScript Project
A complete example for a typical TypeScript React project.
Project Structure
Section titled “Project Structure”my-app/├── src/│ ├── components/│ │ ├── Button/│ │ │ ├── Button.tsx│ │ │ ├── Button.test.tsx│ │ │ └── Button.module.css│ │ └── index.ts│ ├── hooks/│ │ └── index.ts│ ├── utils/│ │ └── index.ts│ └── index.ts├── docs/│ ├── README.md│ └── guides/├── tests/├── package.json├── tsconfig.json└── repotype.yamlConfiguration
Section titled “Configuration”version: "1"
defaults: unmatchedFiles: deny
# Folder structurefolders: - id: src-root path: src requiredFolders: - components - hooks - utils allowedFolders: - components - hooks - utils - types - lib - styles requiredFiles: - index.ts pathCase: kebab
- id: components path: src/components requiredFiles: - index.ts
- id: component-folders path: src/components/* requiredFiles: - "*.tsx" # Main component - "*.test.tsx" # Tests allowedFiles: - "*.tsx" - "*.test.tsx" - "*.module.css" - "*.stories.tsx" - index.ts
- id: docs path: docs requiredFiles: - README.md
# File rulesfiles: # TypeScript source - id: typescript-source glob: "src/**/*.{ts,tsx}" pathCase: kebab forbidContentPatterns: - "console\\.log" - "debugger"
# Test files - id: test-files glob: "src/**/*.test.{ts,tsx}" pathCase: kebab
# React components - must have tests - id: react-components glob: "src/components/**/*.tsx" requiredCompanion: - pattern: "*.test.tsx"
# CSS modules - id: css-modules glob: "src/**/*.module.css" pathCase: kebab
# Documentation - id: markdown-docs glob: "docs/**/*.md" frontmatter: required: - title
# Config files - id: root-configs glob: "*.{json,yaml,yml,js,mjs,cjs}"
- id: package-json glob: "package.json" schema: kind: json schema: schemas/package.schema.json
# Catch-all for common files - id: misc-allowed glob: "{.gitignore,.env.example,LICENSE,README.md}"
# Pluginsplugins: - id: eslint enabled: true validate: cmd: "pnpm exec eslint src/" fix: cmd: "pnpm exec eslint --fix src/" severityOnFailure: error
- id: tsc enabled: true validate: cmd: "pnpm exec tsc --noEmit" severityOnFailure: error
# Operationsoperations: hooks: enabled: true hook: pre-commitSchemas
Section titled “Schemas”package.json Schema
Section titled “package.json Schema”{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "required": ["name", "version"], "properties": { "name": { "type": "string", "pattern": "^@?[a-z0-9-]+(/[a-z0-9-]+)?$" }, "version": { "type": "string", "pattern": "^\\d+\\.\\d+\\.\\d+(-[a-z0-9.]+)?$" }, "private": { "type": "boolean" }, "scripts": { "type": "object", "required": ["build", "test"], "properties": { "build": { "type": "string" }, "test": { "type": "string" }, "lint": { "type": "string" } } } }}# Initialize hooksnpx repotype apply .
# Validatenpx repotype validate .
# Fix auto-fixable issuesnpx repotype fix .
# Generate reportnpx repotype report . --output .repotype/compliance.md