@@ -545,8 +545,9 @@ run_lint() {
545
545
fi
546
546
# Lint TypeScript declaration files...
547
547
add_task ' lint_typescript_declarations'
548
+ declaration_files=$( echo " ${changed_files} " | grep ' /docs/types/.*\.d\.ts$' )
548
549
if [[ -z " ${skip_typescript_declarations} " ]]; then
549
- files=$( echo " ${changed_files} " | grep ' /docs/types/.*\.d.ts$ ' | tr ' \n' ' ' )
550
+ files=$( echo " ${declaration_files} " | tr ' \n' ' ' )
550
551
if [[ -n " ${files} " ]]; then
551
552
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES=" ${files} " lint-typescript-declarations-files > /dev/null >&2
552
553
if [[ " $? " -ne 0 ]]; then
@@ -565,7 +566,26 @@ run_lint() {
565
566
# Lint TypeScript declaration test files...
566
567
add_task ' lint_typescript_tests'
567
568
if [[ -z " ${skip_typescript_tests} " ]]; then
569
+ # Get directly changed `test.ts` files:
568
570
files=$( echo " ${changed_files} " | grep ' /docs/types/test.ts$' | tr ' \n' ' ' )
571
+
572
+ # Also get `test.ts` files corresponding to changed `index.d.ts` files...
573
+ if [[ -n " ${declaration_files} " ]]; then
574
+ while IFS= read -r decl_file; do
575
+ # Only process index.d.ts files (skip other .d.ts files)
576
+ if [[ " ${decl_file} " == * /index.d.ts ]]; then
577
+ # Replace `index.d.ts` with `test.ts` to get the test file path:
578
+ test_file=" ${decl_file% index.d.ts} test.ts"
579
+
580
+ # Check if the test file exists and isn't already in the list:
581
+ if [[ -f " ${test_file} " ]] && [[ ! " ${files} " =~ [[:space:]]${test_file} [[:space:]] ]]; then
582
+ files=" ${files} ${test_file} "
583
+ fi
584
+ fi
585
+ done <<< " ${declaration_files}"
586
+ fi
587
+
588
+ # Lint all collected test files...
569
589
if [[ -n " ${files} " ]]; then
570
590
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES=" ${files} " ESLINT_TS_CONF=" ${eslint_typescript_tests_conf} " lint-typescript-declarations-files > /dev/null >&2
571
591
if [[ " $? " -ne 0 ]]; then
0 commit comments