-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlint-gjs.sh
More file actions
executable file
·79 lines (64 loc) · 2.26 KB
/
Copy pathlint-gjs.sh
File metadata and controls
executable file
·79 lines (64 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# GJS Extension Lint Checker
# Usage: ./lint-gjs.sh extension.js
if [ -z "$1" ]; then
echo "Usage: $0 <extension.js>"
exit 1
fi
FILE="$1"
echo "=== GJS Extension Lint: $FILE ==="
ERRORS=0
# Check for known bad API calls
echo "Checking for known problematic API calls..."
# SocketService methods
if grep -qE "\.listen\(\)" "$FILE"; then
echo "ERROR: .listen() does not exist on Gio.SocketService - use .start()"
ERRORS=1
fi
if grep -qE "\.set_active\(" "$FILE"; then
echo "ERROR: .set_active() does not exist on Gio.SocketService - use .start()/.stop()"
ERRORS=1
fi
# connect() takes exactly 2 args
if grep -qE "\.connect\(.+,\s*[^,)]+\)\s*,\s*true\)" "$FILE"; then
echo "ERROR: .connect() only takes 2 args - remove extra true"
ERRORS=1
fi
# write_all_async takes 4 args, not 5
if grep -qE "\.write_all_async\([^)]+,\s*[^,)]+,\s*[^,)]+,\s*[^,)]+,\s*[^)]+\)" "$FILE"; then
echo "ERROR: write_all_async() takes 4 args (buffer, count, priority, callback), not 5"
ERRORS=1
fi
# write_async takes 4 args, not 5
if grep -qE "\.write_async\([^)]+,\s*[^,)]+,\s*[^,)]+,\s*[^,)]+,\s*[^)]+\)" "$FILE"; then
echo "ERROR: write_async() takes 4 args (buffer, count, priority, callback), not 5"
ERRORS=1
fi
# read_async takes 3 args, not 4
if grep -qE "\.read_bytes_async\([^)]+,\s*[^,)]+,\s*[^,)]+,\s*[^,)]+,\s*[^)]+\)" "$FILE"; then
echo "ERROR: read_bytes_async() takes 3 args (count, priority, cancellable, callback), not 4"
ERRORS=1
fi
# is_active is property, not method
if grep -qE "\.is_active\(" "$FILE"; then
echo "ERROR: is_active is a property, not a method - use .is_active (no parens)"
ERRORS=1
fi
# Common typos
if grep -q "sessionintent-ws.sort" "$FILE"; then
echo "ERROR: typo 'sessionintent-ws.sort' should be '.sock'"
ERRORS=1
fi
echo ""
echo "=== API Reference ==="
echo "Gio.SocketService: .start(), .stop(), .is_active (property)"
echo "Gio.OutputStream.write_all_async: 4 args (buffer, count, priority, callback)"
echo "Gio.OutputStream.write_async: 4 args (buffer, count, priority, callback)"
echo "Gio.InputStream.read_bytes_async: 4 args (count, priority, cancellable, callback)"
echo ""
if [ $ERRORS -eq 0 ]; then
echo "PASS - No issues found"
else
echo "FAIL - Issues found"
fi
exit $ERRORS