.pre-commit-config.yaml•3.99 kB
# Pre-commit configuration for DocuMCP TypeScript MCP Server
# Comprehensive code quality gates aligned with existing development workflow
repos:
# Built-in pre-commit hooks for basic file quality
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# File integrity and formatting
- id: trailing-whitespace
exclude: '\.md$' # Preserve markdown formatting
- id: end-of-file-fixer
exclude: '\.md$'
- id: check-yaml
args: ['--unsafe'] # Allow custom YAML tags
- id: check-json
exclude: 'tsconfig\.json$' # Allow JSON with comments
- id: check-toml
- id: check-merge-conflict
- id: check-case-conflict
# Security and secrets
- id: detect-private-key
- id: check-added-large-files
args: ['--maxkb=1000']
# Code quality basics
- id: mixed-line-ending
args: ['--fix=lf']
# GitHub Actions linting
- repo: https://github.com/rhysd/actionlint
rev: v1.6.26
hooks:
- id: actionlint-docker
name: GitHub Actions Lint
# TypeScript and JavaScript quality
- repo: local
hooks:
- id: eslint
name: ESLint
entry: npm run lint:fix
language: system
files: \.(ts|js)$
pass_filenames: false
# Code formatting with Prettier
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
files: \.(ts|js|json|md|yaml|yml)$
exclude: 'package-lock\.json$|\.prettierrc$|\.github/workflows/deploy-docs\.yml$'
args: [--write]
# TypeScript type checking
- repo: local
hooks:
- id: typescript-check
name: TypeScript Type Check
entry: npm run typecheck
language: system
files: \.(ts)$
pass_filenames: false
# Security auditing
- repo: local
hooks:
- id: npm-audit
name: npm Security Audit
entry: npm audit --audit-level=moderate
language: system
pass_filenames: false
stages: [pre-commit]
# Test execution (temporarily disabled due to failing tests)
# - repo: local
# hooks:
# - id: jest-tests-stable
# name: Jest Stable Tests (Core)
# entry: bash -c 'npm run test -- --testPathPattern="tests/(functional|tools|integration)" --testPathIgnorePatterns="memory"'
# language: system
# pass_filenames: false
# stages: [pre-commit]
# Documentation link validation (disabled - missing script)
# - repo: local
# hooks:
# - id: docs-link-check
# name: Documentation Link Check
# entry: npm run docs:check-links:internal
# language: system
# files: \.(md)$
# pass_filenames: false
# Package.json validation
- repo: local
hooks:
- id: package-json-validate
name: Package.json Validation
entry: node -e "JSON.parse(require('fs').readFileSync('package.json', 'utf8'))"
language: system
files: package\.json$
pass_filenames: false
- id: package-json-structure-check
name: Package.json Structure Protection
entry: node scripts/check-package-structure.cjs
language: system
files: package\.json$
pass_filenames: false
# Build verification (ensures TypeScript compiles)
- repo: local
hooks:
- id: build-check
name: Build Verification
entry: npm run build
language: system
files: \.(ts)$
pass_filenames: false
# Global configuration
default_language_version:
node: '20.11.0'
# Performance and behavior settings
default_stages: [pre-commit]
fail_fast: false # Run all hooks even if one fails
# File exclusions
exclude: |
(?x)^(
dist/.*|
node_modules/.*|
\.git/.*|
\.husky/_/.*|
benchmarks/.*\.log|
coverage/.*|
\.github/workflows/deploy-docs\.yml
)$
# Minimum pre-commit version
minimum_pre_commit_version: '3.5.0'