@@ -341,6 +341,43 @@ jobs:
341341 make lint-typescript-declarations-files FILES="${files}"
342342 fi
343343
344+ # Lint TypeScript declarations test files:
345+ - name : ' Lint TypeScript declarations test files'
346+ if : success() || failure()
347+ run : |
348+ # Determine root directory:
349+ root=$(git rev-parse --show-toplevel)
350+
351+ # Define the path to ESLint configuration file for linting TypeScript tests:
352+ eslint_typescript_tests_conf="${root}/etc/eslint/.eslintrc.typescript.tests.js"
353+
354+ # Get changed files:
355+ changed_files=$(echo "${{ steps.changed-files.outputs.files }}" | tr ' ' '\n')
356+
357+ # Get directly changed `test.ts` files:
358+ files=$(echo "${changed_files}" | grep '/docs/types/test\.ts$' | tr '\n' ' ' | sed 's/ $//')
359+
360+ # Also get `test.ts` files corresponding to changed `index.d.ts` files...
361+ declaration_files=$(echo "${changed_files}" | grep '/docs/types/.*\.d\.ts$' | sed 's/ $//')
362+ if [[ -n "${declaration_files}" ]]; then
363+ while IFS= read -r decl_file; do
364+ # Only process index.d.ts files (skip other .d.ts files)
365+ if [[ "${decl_file}" == */index.d.ts ]]; then
366+ # Replace `index.d.ts` with `test.ts` to get the test file path:
367+ test_file="${decl_file%index.d.ts}test.ts"
368+
369+ # Check if the test file exists and isn't already in the list:
370+ if [[ -f "${test_file}" ]] && [[ ! " ${files} " =~ [[:space:]]${test_file}[[:space:]] ]]; then
371+ files="${files} ${test_file}"
372+ fi
373+ fi
374+ done <<< "${declaration_files}"
375+ fi
376+
377+ if [[ -n "${files}" ]]; then
378+ make lint-typescript-declarations-files FILES="${files}" ESLINT_TS_CONF="${eslint_typescript_tests_conf}"
379+ fi
380+
344381 # Lint license headers:
345382 - name : ' Lint license headers'
346383 if : success() || failure()
0 commit comments