chore(qa): add ESLint, Prettier, and a cognitive-complexity gate
The project shipped no linting or formatting; add both ahead of the first npm publish. ESLint (flat config, typescript-eslint) + Prettier enforce a consistent style, and a cognitive-complexity gate (ccts, threshold 25) keeps any function from regressing into the unreadable. Both run in CI and in a pre-commit hook (.githooks, enabled via core.hooksPath + the `prepare` script). Cyclomatic complexity stays advisory-only — its ??-chain false positives make it a poor gate. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
6 files changed
+100
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Pre-commit gate. Auto-fixes formatting/lint on staged source, then enforces
|
||||
# lint + cognitive-complexity. Enabled via `git config core.hooksPath .githooks`
|
||||
# (run automatically by the `prepare` npm script on install).
|
||||
set -e
|
||||
|
||||
# Auto-fix format + lint on staged TypeScript sources, then re-stage them.
|
||||
staged=$(git diff --cached --name-only --diff-filter=ACM -- 'src/*.ts' 'src/**/*.ts')
|
||||
if [ -n "$staged" ]; then
|
||||
echo "$staged" | xargs npx prettier --write
|
||||
echo "$staged" | xargs npx eslint --fix
|
||||
echo "$staged" | xargs git add
|
||||
fi
|
||||
|
||||
# Enforce (no auto-fix): lint must be clean, and no function over the complexity gate.
|
||||
npm run lint
|
||||
npm run complexity:check
|
||||
Reference in new issue
Block a user