@windyroad/style-guide 0.1.3 → 0.1.4-preview.56
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.
|
@@ -35,6 +35,16 @@ if [ -z "$FILE_PATH" ]; then
|
|
|
35
35
|
exit 0
|
|
36
36
|
fi
|
|
37
37
|
|
|
38
|
+
# P004: Only gate files inside the project root.
|
|
39
|
+
case "$FILE_PATH" in
|
|
40
|
+
/*)
|
|
41
|
+
case "$FILE_PATH" in
|
|
42
|
+
"$PWD"/*) ;;
|
|
43
|
+
*) exit 0 ;;
|
|
44
|
+
esac
|
|
45
|
+
;;
|
|
46
|
+
esac
|
|
47
|
+
|
|
38
48
|
# Gate all UI source files (CSS and component files)
|
|
39
49
|
case "$FILE_PATH" in
|
|
40
50
|
*.css|*.html|*.jsx|*.tsx|*.vue|*.svelte|*.ejs|*.hbs) ;;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env bats
|
|
2
|
+
|
|
3
|
+
# P004: style-guide-enforce-edit.sh project-root check.
|
|
4
|
+
|
|
5
|
+
setup() {
|
|
6
|
+
SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
|
|
7
|
+
HOOK="$SCRIPT_DIR/style-guide-enforce-edit.sh"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
run_hook_with_file() {
|
|
11
|
+
local file_path="$1"
|
|
12
|
+
local json="{\"tool_input\":{\"file_path\":\"${file_path}\"},\"session_id\":\"test-$$\"}"
|
|
13
|
+
echo "$json" | bash "$HOOK"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@test "style-guide project-root: absolute .css outside project exits 0" {
|
|
17
|
+
run run_hook_with_file "/Users/other/project/src/style.css"
|
|
18
|
+
[ "$status" -eq 0 ]
|
|
19
|
+
[[ "$output" != *"BLOCKED"* ]]
|
|
20
|
+
}
|