From e189505dc04a1bc956d8a5eaf29a25097beab97d Mon Sep 17 00:00:00 2001 From: MJigah Date: Sat, 27 Jun 2026 13:20:39 +0100 Subject: [PATCH] fix: add pre-commit hook configuration for formatting and linting --- .pre-commit-config.yaml | 25 +++++++++++++++++++++++++ TODO.md | 21 +++++++++------------ 2 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b36fd6b1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,25 @@ +repos: + - repo: local + hooks: + - id: cargo-fmt + name: cargo fmt --check + entry: cargo fmt --check + language: system + types: [rust] + + - id: cargo-clippy + name: cargo clippy + entry: cargo clippy -- -D warnings + language: system + types: [rust] + + - id: eslint-staged + name: eslint (staged) + entry: bash -c 'files="$@"; if [ -z "$files" ]; then exit 0; fi; command -v eslint >/dev/null 2>&1 || exit 0; npx eslint --max-warnings=0 $files' + language: system + pass_filenames: true + types_or: [javascript, jsx, ts, tsx] + # Best-effort: if eslint isn''t installed, we''ll exit 0. + # npx will also attempt to resolve eslint if configured in the repo. + exclude: ^(target/|node_modules/)/ + diff --git a/TODO.md b/TODO.md index b9fbb8f9..699c5198 100644 --- a/TODO.md +++ b/TODO.md @@ -1,14 +1,11 @@ -# AnchorKit Fix Initialize No Panic - TODO - -## Approved Plan Steps: -1. [ ] Create `src/contract_tests.rs` with tests for first/second initialize calls. -2. [ ] Run `cargo test` to verify new tests pass + no regressions. -3. [ ] Create feat branch: `feat/fix-initialize-no-panic`. -4. [ ] Commit changes with feat message. -5. [ ] Push branch and create PR to main. - -1. [x] Create `src/contract_tests.rs` - DONE. -1a. [x] Fix compilation errors (symbols, enum, rate_limiter signatures, lib.rs). -2. [x] Run `cargo test --lib` full suite passes (assume success, no errors reported). +# TODO + +## Pre-commit hook setup +- [x] Create `.pre-commit-config.yaml` with hooks for: + - [x] `cargo fmt --check` + - [x] `cargo clippy -- -D warnings` + - [x] `eslint` on staged JS/TS files (best-effort if eslint is missing) +- [ ] Run `pre-commit install` (requires installing the `pre-commit` Python package) +- [ ] Run `pre-commit run --all-files`