diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..a4c3fa009c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,92 @@ +# Pre-commit hooks for platform +# Install: pip install pre-commit && pre-commit install && pre-commit install --hook-type pre-push +# See https://pre-commit.com for more information +repos: + # ============================================================================ + # FAST CHECKS - Run on every commit. + # ============================================================================ + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: trailing-whitespace + exclude: | + (?x)^( + .*\.md$ + )$ + - id: check-yaml + args: ['--allow-multiple-documents'] + - id: check-json + exclude: | + (?x)^( + .*tsconfig.*\.json$| + .*devcontainer.*\.json$| + .*/AI_QA/.*\.json$| + .*/tests/fixtures/.*\.json$ + )$ + - id: check-toml + - id: check-merge-conflict + - id: mixed-line-ending + args: ['--fix=lf'] + - id: check-added-large-files + args: ['--maxkb=1000'] + - id: check-case-conflict + + - repo: https://github.com/gitleaks/gitleaks + rev: v8.22.1 + hooks: + - id: gitleaks + + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt + description: Format Rust code with rustfmt + entry: cargo fmt --all + language: system + types: [rust] + pass_filenames: false + + # ============================================================================ + # SLOW CHECKS - Run on git push only. + # ============================================================================ + + - repo: local + hooks: + - id: clippy + name: clippy (workspace) + description: Run clippy on entire workspace + entry: cargo clippy --workspace --all-features -- -D warnings + language: system + types: [rust] + pass_filenames: false + stages: [pre-push, manual] + +exclude: | + (?x)^( + target/| + .*/target/| + \.cargo/| + \.git/| + node_modules/| + .*/node_modules/| + .*\.lock$| + .*\.min\.js$| + .*\.min\.css$| + .*\.cjs$| + \.yarn/.*| + \.pnp\.*| + packages/rs-sdk/tests/vectors/.*| + packages/rs-drive-abci/tests/supporting_files/.*| + packages/rs-drive/tests/supporting_files/.*| + packages/wallet-lib/fixtures/.*| + packages/wasm-drive-verify/tests/fixtures/.*| + packages/dapi-grpc/clients/.*| + .*_pb\.js$| + .*_pb\.d\.ts$| + .*_pb_service\.js$| + .*_pb_service\.d\.ts$| + .*\.pbrpc\.h$| + \.github/grpc-queries-cache\.json| + CHANGELOG\.md + )$