Skip to content
Closed
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
31 changes: 17 additions & 14 deletions tools/make/lib/lint/editorconfig.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 #

#/
Expand All @@ -64,17 +60,21 @@ 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

#/
# Lints a specified list of files to ensure compliance with EditorConfig settings.
#
# ## 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
Expand All @@ -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
Loading