Skip to content

Commit 41af122

Browse files
committed
build: update Git hook to apply different config for TS test files
1 parent aad48ea commit 41af122

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tools/git/hooks/pre-commit

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ skip_c_benchmarks="${SKIP_LINT_C_BENCHMARKS}"
4343
skip_c_tests_fixtures="${SKIP_LINT_C_TESTS_FIXTURES}"
4444
skip_shell="${SKIP_LINT_SHELL}"
4545
skip_typescript_declarations="${SKIP_LINT_TYPESCRIPT_DECLARATIONS}"
46+
skip_typescript_tests="${SKIP_LINT_TYPESCRIPT_TESTS}"
4647
skip_license_headers="${SKIP_LINT_LICENSE_HEADERS}"
4748

4849
# Determine root directory:
@@ -66,6 +67,9 @@ eslint_tests_conf="${root}/etc/eslint/.eslintrc.tests.js"
6667
# Define the path to ESLint configuration file for linting benchmarks:
6768
eslint_benchmarks_conf="${root}/etc/eslint/.eslintrc.benchmarks.js"
6869

70+
# Define the path to ESLint configuration file for linting TypeScript definition tests:
71+
eslint_typescript_tests_conf="${root}/etc/eslint/.eslintrc.typescript.tests.js"
72+
6973
# Define the path to cppcheck configuration file for linting examples:
7074
cppcheck_examples_suppressions_list="${root}/etc/cppcheck/suppressions.examples.txt"
7175

@@ -354,7 +358,7 @@ run_lint() {
354358
fi
355359
# Lint TypeScript declaration files...
356360
if [[ -z "${skip_typescript_declarations}" ]]; then
357-
files=$(echo "${changed_files}" | grep '/docs/types/.*\.ts$' | tr '\n' ' ')
361+
files=$(echo "${changed_files}" | grep '/docs/types/.*\.d.ts$' | tr '\n' ' ')
358362
if [[ -n "${files}" ]]; then
359363
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES="${files}" lint-typescript-declarations-files > /dev/null >&2
360364
if [[ "$?" -ne 0 ]]; then
@@ -364,6 +368,18 @@ run_lint() {
364368
fi
365369
fi
366370
fi
371+
# Lint TypeScript declaration test files...
372+
if [[ -z "${skip_typescript_tests}" ]]; then
373+
files=$(echo "${changed_files}" | grep '/docs/types/test.ts$' | tr '\n' ' ')
374+
if [[ -n "${files}" ]]; then
375+
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES="${files}" ESLINT_TS_CONF="${eslint_typescript_tests_conf}" lint-typescript-declarations-files > /dev/null >&2
376+
if [[ "$?" -ne 0 ]]; then
377+
echo '' >&2
378+
echo 'TypeScript test file lint errors.' >&2
379+
return 1
380+
fi
381+
fi
382+
fi
367383
# Lint license headers...
368384
if [[ -z "${skip_license_headers}" ]]; then
369385
files=$(echo "${changed_files}" | tr '\n' ' ')

0 commit comments

Comments
 (0)