forked from FastLED/FastLED
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathlint
More file actions
executable file
·182 lines (166 loc) · 5.95 KB
/
lint
File metadata and controls
executable file
·182 lines (166 loc) · 5.95 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/bash
set -e
# Parse command line arguments
JS_ONLY=false
while [[ $# -gt 0 ]]; do
case $1 in
--help|-h)
echo "Usage: bash lint [OPTIONS]"
echo ""
echo "Options:"
echo " --help Show this help message"
echo " --js Run JavaScript linting only"
echo ""
echo "This script runs comprehensive linting for Python, C++, and JavaScript."
echo "JavaScript linting: FAST ONLY (skips if not available)."
exit 0
;;
--js)
JS_ONLY=true
shift
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
# Unset VIRTUAL_ENV to avoid warnings about mismatched paths
unset VIRTUAL_ENV
echo "Linting tests/ for temporary cmake files"
# Remove Visual Studio project files if they exist
find tests/ -name "*.vcxproj" -exec rm {} \; 2>/dev/null || true
find tests/ -name "*.vcxproj.filters" -exec rm {} \; 2>/dev/null || true
find tests/ -name "*.sln" -exec rm {} \; 2>/dev/null || true
if [ "$JS_ONLY" = true ]; then
echo "🌐 Running JavaScript Linting Only"
echo "==================================="
else
echo "🚀 Running FastLED Comprehensive Linting Suite"
echo "=============================================="
# Python linting
echo ""
echo "📝 PYTHON LINTING"
echo "------------------"
echo "Running ruff check (linting)"
uv run ruff check --fix test.py
uv run ruff check --fix ci --exclude ci/tmp/ --exclude ci/wasm/
echo "Running ruff format (formatting + import sorting)"
uv run ruff format test.py
uv run ruff format ci --exclude ci/tmp/ --exclude ci/wasm/
# Check if pyright needs to run using fingerprint cache
echo "Checking if pyright needs to run..."
if uv run python ci/python_lint_cache.py check; then
echo "Running pyright (all configured files)"
if uv run pyright; then
# Mark pyright as successful
uv run python ci/python_lint_cache.py success
else
# Invalidate cache on pyright failure
uv run python ci/python_lint_cache.py failure
echo "❌ pyright failed"
exit 1
fi
fi
export CLANG_FORMAT_STYLE="{SortIncludes: false}"
# C++ linting
echo ""
echo "🔧 C++ LINTING"
echo "---------------"
folders=(
#"src/lib8tion"
#"src/platforms/stub"
#"src/platforms/apollo3" # clang-format breaks apollo3
#"src/platforms/esp/8266" # clang-format breaks esp8266
#"src/platforms/arm" # clang-format breaks arm
#"src/fx"
#"src/fl"
#"src/platforms/wasm"
)
for folder in "${folders[@]}"; do
echo "Running clang-format on $folder"
uv run ci/run-clang-format.py -i -r "$folder" || uv run ci/run-clang-format.py -i -r "$folder"
done
# C++ custom linters
echo ""
echo "🔍 C++ CUSTOM LINTERS"
echo "----------------------"
for lint_script in ci/lint_cpp/*.py; do
if [ -f "$lint_script" ]; then
echo "Running $(basename "$lint_script")"
# Check if it's a unittest-based script or standalone
if grep -q "unittest.main()" "$lint_script"; then
# Run as unittest
uv run python -m pytest "$lint_script" -v || {
echo "❌ C++ linter failed: $(basename "$lint_script")"
exit 1
}
else
# Run as standalone script
uv run python "$lint_script" || {
echo "❌ C++ linter failed: $(basename "$lint_script")"
exit 1
}
fi
fi
done
fi
# JavaScript linting and enhanced checking (now included by default)
echo ""
echo "🌐 JAVASCRIPT LINTING & TYPE CHECKING"
echo "--------------------------------------"
# Colors for JavaScript linting output
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Check if fast linting is available
ESLINT_EXE=""
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
ESLINT_EXE=".cache/js-tools/node_modules/.bin/eslint.cmd"
else
ESLINT_EXE=".cache/js-tools/node_modules/.bin/eslint"
fi
if [ -f "ci/lint-js-fast" ] && [ -f "$ESLINT_EXE" ]; then
echo -e "${BLUE}🚀 Using fast JavaScript linting (Node.js + ESLint)${NC}"
if ! bash ci/lint-js-fast; then
echo -e "${RED}❌ Fast JavaScript linting failed${NC}"
exit 1
fi
else
echo -e "${BLUE}⚠️ Fast JavaScript linting not available. Setting up now...${NC}"
# Auto-setup JavaScript linting
if uv run ci/setup-js-linting-fast.py; then
echo -e "${GREEN}✅ JavaScript linting setup complete${NC}"
# Now run the linting
if [ -f "ci/lint-js-fast" ]; then
echo -e "${BLUE}🚀 Running JavaScript linting...${NC}"
if ! bash ci/lint-js-fast; then
echo -e "${RED}❌ JavaScript linting failed${NC}"
exit 1
fi
else
echo -e "${RED}❌ Failed to create lint script${NC}"
exit 1
fi
else
echo -e "${RED}❌ Failed to setup JavaScript linting${NC}"
echo -e "${BLUE}💡 You can manually run: uv run ci/setup-js-linting-fast.py${NC}"
# Don't exit with error, just skip JS linting
fi
fi
echo ""
if [ "$JS_ONLY" = true ]; then
echo "🎉 JavaScript linting completed!"
else
echo "🎉 All linting completed!"
fi
echo "========================="
echo ""
echo "💡 FOR AI AGENTS:"
echo " - Use 'bash lint' for comprehensive linting (Python, C++, and JavaScript)"
echo " - Use 'bash lint --js' for JavaScript linting only"
echo " - JavaScript linting: FAST ONLY (no slow fallback)"
echo " - To enable fast JavaScript linting: uv run ci/setup-js-linting-fast.py"
echo " - Use 'bash lint --help' for usage information"