|
| 1 | +# Pre-commit configuration for SurfSense |
| 2 | +# See https://pre-commit.com for more information |
| 3 | + |
| 4 | +repos: |
| 5 | + # General file quality hooks |
| 6 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 7 | + rev: v5.0.0 |
| 8 | + hooks: |
| 9 | + - id: check-yaml |
| 10 | + args: [--multi, --unsafe] |
| 11 | + - id: check-json |
| 12 | + exclude: '(tsconfig\.json|\.vscode/.*\.json)$' |
| 13 | + - id: check-toml |
| 14 | + - id: check-merge-conflict |
| 15 | + - id: check-added-large-files |
| 16 | + args: [--maxkb=10240] # 10MB limit |
| 17 | + - id: debug-statements |
| 18 | + - id: check-case-conflict |
| 19 | + |
| 20 | + # Security - detect secrets across all file types |
| 21 | + - repo: https://github.com/Yelp/detect-secrets |
| 22 | + rev: v1.5.0 |
| 23 | + hooks: |
| 24 | + - id: detect-secrets |
| 25 | + args: ['--baseline', '.secrets.baseline'] |
| 26 | + exclude: | |
| 27 | + (?x)^( |
| 28 | + .*\.env\.example| |
| 29 | + .*\.env\.template| |
| 30 | + .*/tests/.*| |
| 31 | + .*test.*\.py| |
| 32 | + test_.*\.py| |
| 33 | + .github/workflows/.*\.yml| |
| 34 | + .github/workflows/.*\.yaml| |
| 35 | + .*pnpm-lock\.yaml| |
| 36 | + .*alembic\.ini| |
| 37 | + .*alembic/versions/.*\.py| |
| 38 | + .*\.mdx$ |
| 39 | + )$ |
| 40 | +
|
| 41 | + # Python Backend Hooks (surfsense_backend) - Using Ruff for linting and formatting |
| 42 | + - repo: https://github.com/astral-sh/ruff-pre-commit |
| 43 | + rev: v0.12.5 |
| 44 | + hooks: |
| 45 | + - id: ruff |
| 46 | + name: ruff-check |
| 47 | + files: ^surfsense_backend/ |
| 48 | + exclude: ^surfsense_backend/(test_.*\.py|.*test.*\.py) |
| 49 | + args: [--fix] |
| 50 | + - id: ruff-format |
| 51 | + name: ruff-format |
| 52 | + files: ^surfsense_backend/ |
| 53 | + exclude: ^surfsense_backend/(test_.*\.py|.*test.*\.py) |
| 54 | + |
| 55 | + - repo: https://github.com/PyCQA/bandit |
| 56 | + rev: 1.8.6 |
| 57 | + hooks: |
| 58 | + - id: bandit |
| 59 | + files: ^surfsense_backend/ |
| 60 | + args: ['-f', 'json', '--severity-level', 'high', '--confidence-level', 'high'] |
| 61 | + exclude: ^surfsense_backend/(tests/|test_.*\.py|.*test.*\.py|alembic/) |
| 62 | + |
| 63 | + # Biome hooks for TypeScript/JavaScript projects |
| 64 | + - repo: local |
| 65 | + hooks: |
| 66 | + # Biome check for surfsense_web |
| 67 | + - id: biome-check-web |
| 68 | + name: biome-check-web |
| 69 | + entry: bash -c 'cd surfsense_web && npx @biomejs/biome check --diagnostic-level=error .' |
| 70 | + language: system |
| 71 | + files: ^surfsense_web/ |
| 72 | + pass_filenames: false |
| 73 | + always_run: true |
| 74 | + stages: [pre-commit] |
| 75 | + |
| 76 | + # Biome check for surfsense_browser_extension |
| 77 | + # - id: biome-check-extension |
| 78 | + # name: biome-check-extension |
| 79 | + # entry: bash -c 'cd surfsense_browser_extension && npx @biomejs/biome check --diagnostic-level=error .' |
| 80 | + # language: system |
| 81 | + # files: ^surfsense_browser_extension/ |
| 82 | + # pass_filenames: false |
| 83 | + # always_run: true |
| 84 | + # stages: [pre-commit] |
| 85 | + |
| 86 | + # Commit message linting |
| 87 | + - repo: https://github.com/commitizen-tools/commitizen |
| 88 | + rev: v4.8.3 |
| 89 | + hooks: |
| 90 | + - id: commitizen |
| 91 | + stages: [commit-msg] |
| 92 | + |
| 93 | +# Global configuration |
| 94 | +default_stages: [pre-commit] |
| 95 | +fail_fast: false |
| 96 | + |
0 commit comments