Skip to content

Commit 0f83c70

Browse files
committed
build: add recipe to lint a list of files against EditorConfig
1 parent 920b92a commit 0f83c70

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tools/make/lib/lint/editorconfig.mk

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,33 @@ EDITORCONFIG_CHECKER_CONF_FLAGS ?= \
5656
lint-editorconfig: $(NODE_MODULES)
5757
$(QUIET) $(FIND_PACKAGES_CMD) | grep '^[\/]\|^[a-zA-Z]:[/\]' | while read -r pkg; do \
5858
echo ''; \
59-
echo "Linting package: $$pkg"; \
59+
echo "Linting package for basic formatting errors: $$pkg"; \
6060
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.' ) || exit 1; \
6161
done
6262

6363
.PHONY: lint-editorconfig
64+
65+
#/
66+
# Lints a specified list of files to ensure compliance with EditorConfig settings.
67+
#
68+
# ## Notes
69+
#
70+
# - 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`).
71+
#
72+
# @private
73+
# @param {string} FILES - list of file paths
74+
#
75+
# @example
76+
# make lint-editorconfig-files FILES='foo/test.js bar/index.d.ts'
77+
#/
78+
lint-editorconfig-files: $(NODE_MODULES)
79+
$(QUIET) $(DELETE) $(DELETE_FLAGS) "$(BUILD_DIR)/editorconfig-checker"
80+
$(QUIET) echo 'Linting files for basic formatting errors...'
81+
$(QUIET) $(MKDIR_RECURSIVE) "$(BUILD_DIR)/editorconfig-checker"
82+
$(QUIET) $(TAR) -cf - $(FILES) | $(TAR) -xvf - -C "$(BUILD_DIR)/editorconfig-checker/"
83+
$(QUIET) cd "$(BUILD_DIR)/editorconfig-checker" && \
84+
$(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_CONF) && \
85+
$(NODE) $(EDITORCONFIG_CHECKER) $(EDITORCONFIG_CHECKER_CONF_FLAGS) --config $(EDITORCONFIG_CHECKER_MARKDOWN_CONF) && \
86+
echo 'Success. No detected EditorConfig lint errors.'
87+
88+
.PHONY: lint-editorconfig-files

0 commit comments

Comments
 (0)