Skip to content

Commit 909f07e

Browse files
Merge pull request #92 from CodeDeficient/claude/project-thread-36cl1x-tidy
Tidy repo files: misplaced doc comment, dead screenshot, pre-commit hook
2 parents 1cdb40c + d14886a commit 909f07e

6 files changed

Lines changed: 14 additions & 58 deletions

File tree

‎.karpeslop/pre-commit‎

Lines changed: 0 additions & 27 deletions
This file was deleted.

‎.npmignore‎

Lines changed: 0 additions & 29 deletions
This file was deleted.

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ There are no inline suppression comments. A comment that silences the linter is
118118
run: npx karpeslop@latest --quiet --strict
119119
```
120120
121-
[`examples/github-workflow.yml`](examples/github-workflow.yml) is a complete workflow that also uploads the JSON report and comments on the pull request when the check fails.
121+
[`examples/github-workflow.yml`](examples/github-workflow.yml) is a complete workflow that also uploads the JSON report and comments on the pull request when the check fails. [`examples/pre-commit`](examples/pre-commit) is a git hook that blocks a commit on critical findings.
122122

123123
## Contributing
124124

‎Screenshot.png‎

-37.8 KB
Binary file not shown.

‎examples/pre-commit‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
# KarpeSlop pre-commit hook.
3+
# Copy to .git/hooks/pre-commit (or call it from husky or lint-staged) and make it executable.
4+
#
5+
# Blocks the commit on critical findings (imports or packages that do not
6+
# exist), and on any error that stops the scan. Use --fail-on=high to block
7+
# on high-severity findings too.
8+
9+
if ! npx karpeslop@latest --fail-on=critical --no-report; then
10+
echo "KarpeSlop: commit blocked by the findings or error above."
11+
exit 1
12+
fi

‎rules.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ interface CastReport {
381381
form: string;
382382
}
383383

384-
/** Classify one cast. Chained casts report the chain, plus `as any` when it ends in any. */
385384
function skipParentheses(expr: ts.Expression): ts.Expression {
386385
let current = expr;
387386
while (ts.isParenthesizedExpression(current)) current = current.expression;
@@ -405,6 +404,7 @@ function isInnerOfChain(node: AssertionNode): boolean {
405404
return isCast(parent);
406405
}
407406

407+
/** Classify one cast. Chained casts report the chain, plus `as any` when it ends in any. */
408408
function classifyCast(node: AssertionNode): CastReport[] {
409409
const isAny = node.type.kind === ts.SyntaxKind.AnyKeyword;
410410
if (innerCast(node) !== undefined) {

0 commit comments

Comments
 (0)