diff --git a/tools/make/lib/lint/editorconfig.mk b/tools/make/lib/lint/editorconfig.mk index 85cdbe6c67d4..d269fd12aac8 100644 --- a/tools/make/lib/lint/editorconfig.mk +++ b/tools/make/lib/lint/editorconfig.mk @@ -18,35 +18,31 @@ # VARIABLES # -# Define the path to the [editorconfig-checker][1] executable. +# Define the path to the editorconfig-checker executable. # # To install editorconfig-checker: -# # ```bash -# $ npm install editorconfig-checker +# $ npm install -g editorconfig-checker # ``` # -# [1]: https://editorconfig-checker.github.io +# @see https://editorconfig-checker.github.io EDITORCONFIG_CHECKER ?= $(BIN_DIR)/editorconfig-checker -# Define the path to the editorconfig-checker configuration file: +# Define the path to the editorconfig-checker configuration files EDITORCONFIG_CHECKER_CONF ?= $(CONFIG_DIR)/editorconfig-checker/.editorconfig_checker.json - -# Define the path to the editorconfig-checker configuration file for Markdown files: EDITORCONFIG_CHECKER_MARKDOWN_CONF ?= $(CONFIG_DIR)/editorconfig-checker/.editorconfig_checker.markdown.json -# Define the output format (default is unset, which uses editorconfig-checker's default format) +# Define the output format (default uses editorconfig-checker's default format) EDITORCONFIG_FORMAT ?= # Add the format flag if EDITORCONFIG_FORMAT is set EDITORCONFIG_FORMAT_FLAG := $(if $(EDITORCONFIG_FORMAT),--format=$(EDITORCONFIG_FORMAT)) -# Define the command-line options to use when invoking the editorconfig-checker executable: +# Define command-line options for editorconfig-checker EDITORCONFIG_CHECKER_CONF_FLAGS ?= \ --ignore-defaults \ $(EDITORCONFIG_FORMAT_FLAG) - # RULES # #/ @@ -64,9 +60,13 @@ lint-editorconfig: $(NODE_MODULES) $(QUIET) $(FIND_PACKAGES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r pkg; do \ echo ''; \ echo "Linting package for basic formatting errors: $$pkg"; \ - cd "$$pkg" && ( $(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_CONF) ./ && $(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_MARKDOWN_CONF) ./ && echo 'Success. No detected EditorConfig lint errors.' && echo '' ) || exit 1; \ + cd "$$pkg" && ( \ + $(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_CONF) ./ && \ + $(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_MARKDOWN_CONF) ./ && \ + echo 'Success. No detected EditorConfig lint errors.' && \ + echo '' \ + ) || exit 1; \ done - .PHONY: lint-editorconfig #/ @@ -74,7 +74,7 @@ lint-editorconfig: $(NODE_MODULES) # # ## Notes # -# - This rule is useful when wanting to lint a list of files generated by some other command (e.g., a list of changed files obtained via `git diff`). +# - Useful for linting files generated by other commands (e.g., git diff) # # @private # @param {string} FILES - list of file paths @@ -86,11 +86,14 @@ lint-editorconfig-files: $(NODE_MODULES) $(QUIET) $(DELETE) $(DELETE_FLAGS) "$(BUILD_DIR)/editorconfig-checker" $(QUIET) echo 'Linting files for basic formatting errors...' $(QUIET) $(MKDIR_RECURSIVE) "$(BUILD_DIR)/editorconfig-checker" + + # Copy files to a temporary directory for linting $(QUIET) echo $(FILES) | tr ' ' '\n' | $(TAR) -cf - -T - | $(TAR) -xf - -C "$(BUILD_DIR)/editorconfig-checker/" + + # Run EditorConfig checks $(QUIET) cd "$(BUILD_DIR)/editorconfig-checker" && \ $(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_CONF) ./ && \ $(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_MARKDOWN_CONF) ./ && \ echo 'Success. No detected EditorConfig lint errors.' && \ echo '' - .PHONY: lint-editorconfig-files