Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Comment on lines +56 to +63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Clippy flags should match CI to prevent surprise failures.

The pre-commit clippy hook uses only cargo clippy --workspace, but CI runs with stricter flags including --all-features and -D warnings. This means code can pass the pre-commit hook but fail CI because:

  1. -D warnings is missing: warnings don't fail locally but are errors in CI
  2. --all-features is missing: feature-gated code isn't linted locally
🔧 Proposed fix to align with CI
       - id: clippy
         name: clippy (workspace)
         description: Run clippy on entire workspace
-        entry: cargo clippy --workspace
+        entry: cargo clippy --workspace --all-features -- -D warnings
         language: system
         types: [rust]
         pass_filenames: false
         stages: [pre-push, manual]

Note: --locked and --no-deps from CI are omitted intentionally—--locked can cause issues if Cargo.lock drifts locally, and --no-deps is the default behavior when not using -D warnings on dependencies.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.pre-commit-config.yaml around lines 56 - 63, Pre-commit's clippy hook (id:
clippy, entry: cargo clippy --workspace) is less strict than CI; update the hook
entry to match CI by running cargo clippy --workspace --all-features -D warnings
so local runs fail on warnings and lint feature-gated code too, leaving out
--locked and --no-deps as noted.


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
)$