fuzzyworld

word-waltz / commit

configuring lint as pre-commit check

488526c87712f1ece49ea208008799f1b198160e · Pavel Safronov · 2026-03-23 22:53:21 -0700 · parents 7fc56aa68354

configuring lint as pre-commit check
 .githooks/pre-commit | 13 +++++++++++++
 .gitlab-ci.yml       |  2 --
 cspell.json          |  6 +++---
 package.json         |  3 ++-
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/.githooks/pre-commit b/.githooks/pre-commit
new file mode 100755
index 0000000..803577a
--- /dev/null
+++ b/.githooks/pre-commit
@@ -0,0 +1,13 @@
+#!/bin/sh
+# Pre-commit hook: run spell check and type check before allowing a commit.
+# Installed automatically via `npm run prepare` (git config core.hooksPath).
+
+set -e
+
+echo "→ cspell…"
+npx cspell "**" --no-progress
+
+echo "→ tsc…"
+npx tsc --noEmit
+
+echo "✓ Pre-commit checks passed."
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7612aa9..c91763f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,8 +11,6 @@ build:
   image: node:${NODE_VERSION}-alpine
   script:
     - npm ci
-    - npm run spell
-    - npm run typecheck
     - npm run build
   artifacts:
     paths:
diff --git a/cspell.json b/cspell.json
index 585fab0..fe0c97b 100644
--- a/cspell.json
+++ b/cspell.json
@@ -6,18 +6,18 @@
         "ASDFGHJKL",
         "ciphertext",
         "ENTERZCVBNM",
+        "Firestore",
+        "firestore",
         "firebaseapp",
         "firebasestorage",
-        "firestore",
-        "Firestore",
         "Flaticon",
         "Freepik",
         "idempotent",
         "IHDR",
         "initialisation",
         "maxlength",
-        "qrcode",
         "QWERTYUIOP",
+        "qrcode",
         "serialisation",
         "unencrypted",
         "Wordle"
diff --git a/package.json b/package.json
index 39cdbb7..6b6f27a 100644
--- a/package.json
+++ b/package.json
@@ -6,8 +6,9 @@
   "type": "module",
   "scripts": {
     "dev": "vite",
-    "build": "vite build",
+    "build": "npm run spell && npm run typecheck && vite build",
     "preview": "vite preview",
+    "prepare": "git config core.hooksPath .githooks",
     "generate-assets": "tsx scripts/generate-assets.ts",
     "typecheck": "tsc --noEmit",
     "spell": "cspell \"**\" --no-progress"