safeword 0.4.3 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Safeword: Auto-lint changed files (PostToolUse)
|
|
3
3
|
# Silently auto-fixes, only outputs unfixable errors
|
|
4
4
|
|
|
5
|
+
# Require jq for JSON parsing
|
|
6
|
+
command -v jq &> /dev/null || exit 0
|
|
7
|
+
|
|
5
8
|
input=$(cat)
|
|
6
9
|
file=$(echo "$input" | jq -r '.tool_input.file_path // .tool_input.notebook_path // empty' 2>/dev/null)
|
|
7
10
|
|
|
@@ -13,7 +16,7 @@ file=$(echo "$input" | jq -r '.tool_input.file_path // .tool_input.notebook_path
|
|
|
13
16
|
|
|
14
17
|
# Determine linters based on file extension
|
|
15
18
|
case "$file" in
|
|
16
|
-
*.js|*.jsx|*.ts|*.tsx|*.mjs|*.cjs|*.astro
|
|
19
|
+
*.js|*.jsx|*.ts|*.tsx|*.mjs|*.cjs|*.astro)
|
|
17
20
|
# Prettier (silent, ignore errors)
|
|
18
21
|
npx prettier --write "$file" 2>/dev/null
|
|
19
22
|
|
|
@@ -25,6 +28,11 @@ case "$file" in
|
|
|
25
28
|
fi
|
|
26
29
|
;;
|
|
27
30
|
|
|
31
|
+
*.vue|*.svelte)
|
|
32
|
+
# Vue/Svelte: Prettier only (ESLint requires project-specific plugins)
|
|
33
|
+
npx prettier --write "$file" 2>/dev/null
|
|
34
|
+
;;
|
|
35
|
+
|
|
28
36
|
*.md)
|
|
29
37
|
# Markdownlint (capture unfixable errors)
|
|
30
38
|
errors=$(npx markdownlint-cli2 --fix "$file" 2>&1)
|
|
@@ -40,24 +48,26 @@ case "$file" in
|
|
|
40
48
|
;;
|
|
41
49
|
|
|
42
50
|
*.py)
|
|
43
|
-
# Python: ruff format + ruff check --fix
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
# Python: ruff format + ruff check --fix
|
|
52
|
+
if command -v ruff &> /dev/null; then
|
|
53
|
+
ruff format "$file" 2>/dev/null
|
|
54
|
+
errors=$(ruff check --fix "$file" 2>&1)
|
|
55
|
+
exit_code=$?
|
|
56
|
+
if [ $exit_code -ne 0 ] && [ -n "$errors" ]; then
|
|
57
|
+
echo "$errors"
|
|
58
|
+
fi
|
|
49
59
|
fi
|
|
50
60
|
;;
|
|
51
61
|
|
|
52
62
|
*.go)
|
|
53
|
-
# Go: gofmt
|
|
63
|
+
# Go: gofmt
|
|
54
64
|
if command -v gofmt &> /dev/null; then
|
|
55
65
|
gofmt -w "$file" 2>/dev/null
|
|
56
66
|
fi
|
|
57
67
|
;;
|
|
58
68
|
|
|
59
69
|
*.rs)
|
|
60
|
-
# Rust: rustfmt
|
|
70
|
+
# Rust: rustfmt
|
|
61
71
|
if command -v rustfmt &> /dev/null; then
|
|
62
72
|
rustfmt "$file" 2>/dev/null
|
|
63
73
|
fi
|