forked from stdlib-js/stdlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditorconfig.mk
More file actions
96 lines (83 loc) · 3.6 KB
/
editorconfig.mk
File metadata and controls
96 lines (83 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#/
# @license Apache-2.0
#
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/
# VARIABLES #
# Define the path to the [editorconfig-checker][1] executable.
#
# To install editorconfig-checker:
#
# ```bash
# $ npm install editorconfig-checker
# ```
#
# [1]: https://editorconfig-checker.github.io
EDITORCONFIG_CHECKER ?= $(BIN_DIR)/editorconfig-checker
# Define the path to the editorconfig-checker configuration file:
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)
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:
EDITORCONFIG_CHECKER_CONF_FLAGS ?= \
--ignore-defaults \
$(EDITORCONFIG_FORMAT_FLAG)
# RULES #
#/
# Lints files to ensure compliance with EditorConfig settings.
#
# @param {string} [PACKAGES_FILTER] - file path pattern (e.g., `.*/math/base/special/abs/.*`)
#
# @example
# make lint-editorconfig
#
# @example
# make lint-editorconfig PACKAGES_FILTER=".*/math/base/special/abs/.*"
#/
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; \
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`).
#
# @private
# @param {string} FILES - list of file paths
#
# @example
# make lint-editorconfig-files FILES='foo/test.js bar/index.d.ts'
#/
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"
$(QUIET) echo $(FILES) | tr ' ' '\n' | $(TAR) -cf - -T - | $(TAR) -xf - -C "$(BUILD_DIR)/editorconfig-checker/"
$(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