@@ -202,50 +202,99 @@ check_ui_selector_contract() {
202202
203203
204204check_ui () {
205- local ui_files
206- if [ " $MODE " = " check" ]; then
207- ui_files=$( find cmd/ui -type f \( -name " *.ts" -o -name " *.html" -o -name " *.scss" \) -not -path " */node_modules/*" -not -path " */.angular/*" || true)
205+ local ui_files=()
206+ local file
207+ if [ " ${MODE} " = " check" ]; then
208+ while IFS= read -r file; do
209+ if [ -n " ${file} " ]; then ui_files+=(" ${file} " ); fi
210+ done < <( find cmd/ui -type f \( -name " *.ts" -o -name " *.html" -o -name " *.scss" \) -not -path " */node_modules/*" -not -path " */.angular/*" -not -path " */dist/*" -not -path " */coverage/*" -not -path " */out-tsc/*" | sort || true)
208211 else
209- ui_files=$( git diff --cached --name-only --diff-filter=ACM | grep -E ' ^cmd/ui/.*\.(ts|html|scss)$' || true)
212+ while IFS= read -r file; do
213+ if [ -n " ${file} " ]; then ui_files+=(" ${file} " ); fi
214+ done < <( git -c core.quotePath=false diff --cached --name-only --diff-filter=ACMR | grep -E ' ^cmd/ui/.*\.(ts|html|scss)$' || true)
215+ fi
216+
217+ local run_all_eslint=0
218+ if [ " ${MODE} " = " check" ] || staged_paths_match AM ' ^cmd/ui/eslint\.config\.js$' ; then
219+ run_all_eslint=1
210220 fi
211221
212- if [ -z " $ui_files " ]; then
222+ local run_typecheck=0
223+ if [ " ${MODE} " = " check" ] || staged_paths_match AMD ' ^cmd/ui/(.*\.ts|([^/]+/)*tsconfig[^/]*\.json|([^/]+/)*package(-lock)?\.json)$' ; then
224+ run_typecheck=1
225+ fi
226+
227+ if [ " ${# ui_files[@]} " -eq 0 ] && [ " ${run_all_eslint} " -eq 0 ] && [ " ${run_typecheck} " -eq 0 ]; then
213228 return
214229 fi
215230
216231 local prettier_bin=" cmd/ui/node_modules/.bin/prettier"
217232 local eslint_bin=" cmd/ui/node_modules/.bin/eslint"
233+ local tsc_bin=" cmd/ui/node_modules/.bin/tsc"
234+
235+ if [ " ${# ui_files[@]} " -gt 0 ]; then
236+ if [ -x " ${prettier_bin} " ]; then
237+ echo " --> Running UI Formatter (Prettier)..."
238+ if [ " ${MODE} " = " check" ]; then
239+ if ! " ${prettier_bin} " --config cmd/ui/.prettierrc --check " ${ui_files[@]} " ; then
240+ echo " ❌ Prettier check failed."
241+ FAILED=1
242+ fi
243+ else
244+ " ${prettier_bin} " --config cmd/ui/.prettierrc --write " ${ui_files[@]} "
245+ fi
246+ else
247+ echo " ❌ ERROR: Local Prettier not found at ${prettier_bin} ."
248+ echo " Please install dependencies: cd cmd/ui && npm ci --legacy-peer-deps"
249+ if [ " ${MODE} " = " check" ]; then FAILED=1; fi
250+ fi
251+ fi
218252
219- if [ -f " $prettier_bin " ]; then
220- echo " --> Running UI Formatter (Prettier)..."
221- if [ " $MODE " = " check" ]; then
222- if ! $prettier_bin --config cmd/ui/.prettierrc --check $ui_files ; then
223- echo " ❌ Prettier check failed."
253+ local ui_lint_files=()
254+ if [ " ${# ui_files[@]} " -gt 0 ]; then
255+ for file in " ${ui_files[@]} " ; do
256+ case " ${file} " in
257+ cmd/ui/index.html) ;;
258+ * .ts|* .html) ui_lint_files+=(" ${file# cmd/ ui/ } " ) ;;
259+ esac
260+ done
261+ fi
262+
263+ if [ " ${run_all_eslint} " -eq 1 ] || [ " ${# ui_lint_files[@]} " -gt 0 ]; then
264+ if [ -x " ${eslint_bin} " ]; then
265+ echo " --> Running UI Linter (ESLint)..."
266+ local eslint_args=()
267+ if [ " ${MODE} " != " check" ]; then
268+ eslint_args+=(--fix)
269+ fi
270+ if [ " ${run_all_eslint} " -eq 1 ]; then
271+ eslint_args+=(.)
272+ else
273+ eslint_args+=(" ${ui_lint_files[@]} " )
274+ fi
275+ if ! (cd cmd/ui && ./node_modules/.bin/eslint " ${eslint_args[@]} " ); then
276+ echo " ❌ ESLint check failed."
224277 FAILED=1
225278 fi
226279 else
227- $prettier_bin --config cmd/ui/.prettierrc --write $ui_files
280+ echo " ❌ ERROR: Local ESLint not found at ${eslint_bin} ."
281+ echo " Please install dependencies: cd cmd/ui && npm ci --legacy-peer-deps"
282+ if [ " ${MODE} " = " check" ]; then FAILED=1; fi
228283 fi
229- else
230- echo " ❌ ERROR: Local Prettier not found at $prettier_bin ."
231- echo " Please install dependencies: cd cmd/ui && npm ci --legacy-peer-deps"
232- if [ " $MODE " = " check" ]; then FAILED=1; fi
233284 fi
234285
235- if [ -f " $eslint_bin " ]; then
236- echo " --> Running UI Linter (ESLint)... "
237- if [ " $MODE " = " check " ] ; then
238- if ! $eslint_bin --config cmd/ui/eslint.config.js $ui_files ; then
239- echo " ❌ ESLint check failed."
286+ if [ " ${run_typecheck} " -eq 1 ]; then
287+ if [ -x " ${tsc_bin} " ] ; then
288+ echo " --> Running UI Typechecker (tsc)... "
289+ if ! (cd cmd/ui && npm run --silent typecheck) ; then
290+ echo " ❌ UI TypeScript typecheck failed."
240291 FAILED=1
241292 fi
242293 else
243- $eslint_bin --config cmd/ui/eslint.config.js --fix $ui_files
294+ echo " ❌ ERROR: Local tsc not found at ${tsc_bin} ."
295+ echo " Please install dependencies: cd cmd/ui && npm ci --legacy-peer-deps"
296+ if [ " ${MODE} " = " check" ]; then FAILED=1; fi
244297 fi
245- else
246- echo " ❌ ERROR: Local ESLint not found at $eslint_bin ."
247- echo " Please install dependencies: cd cmd/ui && npm ci --legacy-peer-deps"
248- if [ " $MODE " = " check" ]; then FAILED=1; fi
249298 fi
250299}
251300
0 commit comments