Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions tools/git/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,12 @@ lint_package_json="${root}/lib/node_modules/@stdlib/_tools/lint/pkg-json/bin/cli
lint_repl_help="${root}/lib/node_modules/@stdlib/_tools/lint/repl-txt/bin/cli"

# Define the path to ESLint configuration file for linting examples:
eslint_examples_conf="${root}/etc/eslint/.eslintrc.examples.js"

# Define the path to ESLint configuration file for linting tests:
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 @@ -316,7 +312,7 @@ run_lint() {
if [[ -z "${skip_javascript_examples}" ]]; then
files=$(echo "${changed_files}" | grep '/examples/.*\.js$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make JAVASCRIPT_LINTER=eslint ESLINT_CONF="${eslint_examples_conf}" FILES="${files}" FIX=1 lint-javascript-files > /dev/null >&2
make JAVASCRIPT_LINTER=eslint FILES="${files}" FIX=1 lint-javascript-files > /dev/null >&2
if [[ "$?" -ne 0 ]]; then
task_status 'failed'
echo '' >&2
Expand All @@ -335,7 +331,7 @@ run_lint() {
if [[ -z "${skip_javascript_tests}" ]]; then
files=$(echo "${changed_files}" | grep '/test/.*\.js$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make JAVASCRIPT_LINTER=eslint ESLINT_CONF="${eslint_tests_conf}" FILES="${files}" FIX=1 lint-javascript-files > /dev/null >&2
make JAVASCRIPT_LINTER=eslint FILES="${files}" FIX=1 lint-javascript-files > /dev/null >&2
if [[ "$?" -ne 0 ]]; then
task_status 'failed'
echo '' >&2
Expand All @@ -354,7 +350,7 @@ run_lint() {
if [[ -z "${skip_javascript_benchmarks}" ]]; then
files=$(echo "${changed_files}" | grep '/benchmark/.*\.js$' | tr '\n' ' ')
if [[ -n "${files}" ]]; then
make JAVASCRIPT_LINTER=eslint ESLINT_CONF="${eslint_benchmarks_conf}" FILES="${files}" FIX=1 lint-javascript-files > /dev/null >&2
make JAVASCRIPT_LINTER=eslint FILES="${files}" FIX=1 lint-javascript-files > /dev/null >&2
if [[ "$?" -ne 0 ]]; then
task_status 'failed'
echo '' >&2
Expand Down Expand Up @@ -587,7 +583,7 @@ run_lint() {

# Lint all collected test files...
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
make TYPESCRIPT_DECLARATIONS_LINTER=eslint FILES="${files}" lint-typescript-declarations-files > /dev/null >&2
if [[ "$?" -ne 0 ]]; then
task_status 'failed'
echo '' >&2
Expand Down
39 changes: 10 additions & 29 deletions tools/make/lib/lint/javascript/eslint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,8 @@
# [1]: https://eslint.org/
ESLINT ?= $(BIN_DIR)/eslint

# Define the path to the ESLint configuration file:
ESLINT_CONF ?= $(CONFIG_DIR)/eslint/.eslintrc.js

# Define the path to the ESLint configuration file for examples:
ESLINT_CONF_EXAMPLES ?= $(CONFIG_DIR)/eslint/.eslintrc.examples.js

# Define the path to the ESLint configuration file for tests:
ESLINT_CONF_TESTS ?= $(CONFIG_DIR)/eslint/.eslintrc.tests.js

# Define the path to the ESLint configuration file for benchmarks:
ESLINT_CONF_BENCHMARKS ?= $(CONFIG_DIR)/eslint/.eslintrc.benchmarks.js

# Define the path to the ESLint ignore file:
ESLINT_IGNORE ?= $(ROOT_DIR)/.eslintignore

# Force legacy config mode (eslint.config.cjs exists but Makefiles still use legacy flags):
export ESLINT_USE_FLAT_CONFIG := false

# Define the command-line options to use when invoking the ESLint executable:
eslint_flags := \
--ignore-path $(ESLINT_IGNORE) \
--report-unused-disable-directives

# Define user-supplied command-line options:
Expand Down Expand Up @@ -97,14 +78,14 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) $(FIND_SOURCES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
$(ESLINT) $(eslint_flags) --config $(ESLINT_CONF) $$file || exit 1; \
$(ESLINT) $(eslint_flags) $$file || exit 1; \
done
else
$(QUIET) status=0; \
$(FIND_SOURCES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
if ! $(ESLINT) $(eslint_flags) --config $(ESLINT_CONF) $$file; then \
if ! $(ESLINT) $(eslint_flags) $$file; then \
echo 'Linting failed.'; \
status=1; \
fi; \
Expand Down Expand Up @@ -138,14 +119,14 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) $(FIND_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
$(ESLINT) $(eslint_flags) --config $(ESLINT_CONF_TESTS) $$file || exit 1; \
$(ESLINT) $(eslint_flags) $$file || exit 1; \
done
else
$(QUIET) status=0; \
$(FIND_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
if ! $(ESLINT) $(eslint_flags) --config $(ESLINT_CONF_TESTS) $$file; then \
if ! $(ESLINT) $(eslint_flags) $$file; then \
echo 'Linting failed.'; \
status=1; \
fi; \
Expand Down Expand Up @@ -179,14 +160,14 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) $(FIND_EXAMPLES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
$(ESLINT) $(eslint_flags) --config $(ESLINT_CONF_EXAMPLES) $$file || exit 1; \
$(ESLINT) $(eslint_flags) $$file || exit 1; \
done
else
$(QUIET) status=0; \
$(FIND_EXAMPLES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
if ! $(ESLINT) $(eslint_flags) --config $(ESLINT_CONF_EXAMPLES) $$file; then \
if ! $(ESLINT) $(eslint_flags) $$file; then \
echo 'Linting failed.'; \
status=1; \
fi; \
Expand Down Expand Up @@ -220,14 +201,14 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) $(FIND_BENCHMARKS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
$(ESLINT) $(eslint_flags) --config $(ESLINT_CONF_BENCHMARKS) $$file || exit 1; \
$(ESLINT) $(eslint_flags) $$file || exit 1; \
done
else
$(QUIET) status=0; \
$(FIND_BENCHMARKS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
if ! $(ESLINT) $(eslint_flags) --config $(ESLINT_CONF_BENCHMARKS) $$file; then \
if ! $(ESLINT) $(eslint_flags) $$file; then \
echo 'Linting failed.'; \
status=1; \
fi; \
Expand Down Expand Up @@ -258,14 +239,14 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) for file in $(FILES); do \
echo ''; \
echo "Linting file: $$file"; \
$(ESLINT) $(eslint_flags) --config $(ESLINT_CONF) $$file || exit 1; \
$(ESLINT) $(eslint_flags) $$file || exit 1; \
done
else
$(QUIET) status=0; \
for file in $(FILES); do \
echo ''; \
echo "Linting file: $$file"; \
if ! $(ESLINT) $(eslint_flags) --config $(ESLINT_CONF) $$file; then \
if ! $(ESLINT) $(eslint_flags) $$file; then \
echo 'Linting failed.'; \
status=1; \
fi; \
Expand Down
51 changes: 7 additions & 44 deletions tools/make/lib/lint/typescript/eslint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,8 @@
# [1]: https://eslint.org/
ESLINT ?= $(BIN_DIR)/eslint

# Define the path to the ESLint configuration file:
ESLINT_TS_CONF ?= $(CONFIG_DIR)/eslint/.eslintrc.typescript.js

# Define the path to the ESLint configuration file for tests:
ESLINT_TS_CONF_TESTS ?= $(CONFIG_DIR)/eslint/.eslintrc.typescript.tests.js

# Define the path to a TypeScript configuration file:
TS_CONFIG ?= $(CONFIG_DIR)/typescript/tsconfig.json

# Define the path to the ESLint ignore file:
ESLINT_IGNORE ?= $(ROOT_DIR)/.eslintignore

# Define the command-line options to use when invoking the ESLint executable:
ESLINT_TS_FLAGS ?= \
--ignore-path $(ESLINT_IGNORE)
ESLINT_TS_FLAGS ?=

ifeq ($(AUTOFIX),true)
ESLINT_TS_FLAGS += --fix
Expand Down Expand Up @@ -80,21 +67,13 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) $(FIND_TYPESCRIPT_DECLARATIONS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
DIR=`dirname $$file`; \
LOCAL_TS_CONFIG=$$DIR/tsconfig.json; \
$(CP) $(TS_CONFIG) $$DIR; \
$(ESLINT) $(ESLINT_TS_FLAGS) --config $(ESLINT_TS_CONF) --parser-options=project:$$LOCAL_TS_CONFIG $$file || exit 1; \
rm $$LOCAL_TS_CONFIG; \
$(ESLINT) $(ESLINT_TS_FLAGS) $$file || exit 1; \
done
else
$(QUIET) $(FIND_TYPESCRIPT_DECLARATIONS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
DIR=`dirname $$file`; \
LOCAL_TS_CONFIG=$$DIR/tsconfig.json; \
$(CP) $(TS_CONFIG) $$DIR; \
$(ESLINT) $(ESLINT_TS_FLAGS) --config $(ESLINT_TS_CONF) --parser-options=project:$$LOCAL_TS_CONFIG $$file || echo 'Linting failed.'; \
rm $$LOCAL_TS_CONFIG; \
$(ESLINT) $(ESLINT_TS_FLAGS) $$file || echo 'Linting failed.'; \
done
endif

Expand All @@ -121,21 +100,13 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) $(FIND_TYPESCRIPT_DECLARATIONS_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
DIR=`dirname $$file`; \
LOCAL_TS_CONFIG=$$DIR/tsconfig.json; \
$(CP) $(TS_CONFIG) $$DIR; \
$(ESLINT) $(ESLINT_TS_FLAGS) --config $(ESLINT_TS_CONF_TESTS) --parser-options=project:$$LOCAL_TS_CONFIG $$file || exit 1; \
rm $$LOCAL_TS_CONFIG; \
$(ESLINT) $(ESLINT_TS_FLAGS) $$file || exit 1; \
done
else
$(QUIET) $(FIND_TYPESCRIPT_DECLARATIONS_TESTS_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r file; do \
echo ''; \
echo "Linting file: $$file"; \
DIR=`dirname $$file`; \
LOCAL_TS_CONFIG=$$DIR/tsconfig.json; \
$(CP) $(TS_CONFIG) $$DIR; \
$(ESLINT) $(ESLINT_TS_FLAGS) --config $(ESLINT_TS_CONF_TESTS) --parser-options=project:$$LOCAL_TS_CONFIG $$file || echo 'Linting failed.'; \
rm $$LOCAL_TS_CONFIG; \
$(ESLINT) $(ESLINT_TS_FLAGS) $$file || echo 'Linting failed.'; \
done
endif

Expand All @@ -160,21 +131,13 @@ ifeq ($(FAIL_FAST), true)
$(QUIET) for file in $(FILES); do \
echo ''; \
echo "Linting file: $$file"; \
DIR=`dirname $$file`; \
LOCAL_TS_CONFIG=$$DIR/tsconfig.json; \
$(CP) $(TS_CONFIG) $$DIR; \
$(ESLINT) $(ESLINT_TS_FLAGS) --config $(ESLINT_TS_CONF) --parser-options=project:$$LOCAL_TS_CONFIG $$file || exit 1; \
rm $$LOCAL_TS_CONFIG; \
$(ESLINT) $(ESLINT_TS_FLAGS) $$file || exit 1; \
done
else
$(QUIET) for file in $(FILES); do \
echo ''; \
echo "Linting file: $$file"; \
DIR=`dirname $$file`; \
LOCAL_TS_CONFIG=$$DIR/tsconfig.json; \
$(CP) $(TS_CONFIG) $$DIR; \
$(ESLINT) $(ESLINT_TS_FLAGS) --config $(ESLINT_TS_CONF) --parser-options=project:$$LOCAL_TS_CONFIG $$file || echo 'Linting failed.'; \
rm $$LOCAL_TS_CONFIG; \
$(ESLINT) $(ESLINT_TS_FLAGS) $$file || echo 'Linting failed.'; \
done
endif

Expand Down
Loading