Skip to content

Commit

Permalink
build: update Git hook to apply different config for TS test files
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Sep 29, 2024
1 parent aad48ea commit 41af122
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tools/git/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ skip_c_benchmarks="${SKIP_LINT_C_BENCHMARKS}"
skip_c_tests_fixtures="${SKIP_LINT_C_TESTS_FIXTURES}"
skip_shell="${SKIP_LINT_SHELL}"
skip_typescript_declarations="${SKIP_LINT_TYPESCRIPT_DECLARATIONS}"
skip_typescript_tests="${SKIP_LINT_TYPESCRIPT_TESTS}"
skip_license_headers="${SKIP_LINT_LICENSE_HEADERS}"

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

# Define the path to ESLint configuration file for linting TypeScript definition tests:
eslint_typescript_tests_conf="${root}/etc/eslint/.eslintrc.typescript.tests.js"

# Define the path to cppcheck configuration file for linting examples:
cppcheck_examples_suppressions_list="${root}/etc/cppcheck/suppressions.examples.txt"

Expand Down Expand Up @@ -354,7 +358,7 @@ run_lint() {
fi
# Lint TypeScript declaration files...
if [[ -z "${skip_typescript_declarations}" ]]; then
files=$(echo "${changed_files}" | grep '/docs/types/.*\.ts$' | tr '\n' ' ')
files=$(echo "${changed_files}" | grep '/docs/types/.*\.d.ts$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES="${files}" lint-typescript-declarations-files > /dev/null >&2
if [[ "$?" -ne 0 ]]; then
Expand All @@ -364,6 +368,18 @@ run_lint() {
fi
fi
fi
# Lint TypeScript declaration test files...
if [[ -z "${skip_typescript_tests}" ]]; then
files=$(echo "${changed_files}" | grep '/docs/types/test.ts$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES="${files}" ESLINT_TS_CONF="${eslint_typescript_tests_conf}" lint-typescript-declarations-files > /dev/null >&2
if [[ "$?" -ne 0 ]]; then
echo '' >&2
echo 'TypeScript test file lint errors.' >&2
return 1
fi
fi
fi
# Lint license headers...
if [[ -z "${skip_license_headers}" ]]; then
files=$(echo "${changed_files}" | tr '\n' ' ')
Expand Down

0 comments on commit 41af122

Please sign in to comment.