@zairakai/js-dev-tools 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/config.sh +18 -5
- package/scripts/eslint-fix.sh +12 -2
- package/scripts/eslint.sh +11 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zairakai/js-dev-tools",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "The unified and centralized development toolkit for JavaScript/TypeScript projects - ESLint, Prettier, Stylelint, Knip, Vitest, Git Hooks, and GitLab CI pipeline templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dev-tools",
|
package/scripts/config.sh
CHANGED
|
@@ -132,12 +132,25 @@ ensure_bin_optional() {
|
|
|
132
132
|
}
|
|
133
133
|
export -f ensure_bin_optional
|
|
134
134
|
|
|
135
|
-
# Check if files matching
|
|
135
|
+
# Check if files matching any of the given patterns exist.
|
|
136
|
+
#
|
|
137
|
+
# Variadic: accepts one or more glob patterns, returns success if ANY matches.
|
|
138
|
+
# Callers needing a brace-alternation pattern (e.g. *.{js,ts,vue}) must leave that
|
|
139
|
+
# portion unquoted at the call site so bash's brace expansion splits it into
|
|
140
|
+
# separate arguments BEFORE this function ever sees it — brace expansion only
|
|
141
|
+
# applies to unquoted literal text, never to the contents of a variable, so a
|
|
142
|
+
# pattern like "**/*.{js,ts}" passed as a single quoted string is matched
|
|
143
|
+
# literally (and never matches a real file) instead of being expanded.
|
|
136
144
|
has_files() {
|
|
137
|
-
local pattern
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
local pattern
|
|
146
|
+
for pattern in "$@"; do
|
|
147
|
+
# SC2086: unquoted intentionally — we need word splitting + glob expansion via nullglob+globstar
|
|
148
|
+
# shellcheck disable=SC2086
|
|
149
|
+
if ( shopt -s nullglob globstar; set -- $pattern; [ $# -gt 0 ] ); then
|
|
150
|
+
return 0
|
|
151
|
+
fi
|
|
152
|
+
done
|
|
153
|
+
return 1
|
|
141
154
|
}
|
|
142
155
|
export -f has_files
|
|
143
156
|
|
package/scripts/eslint-fix.sh
CHANGED
|
@@ -21,8 +21,18 @@ fi
|
|
|
21
21
|
|
|
22
22
|
log_step "Fixing: $LINT_TARGET"
|
|
23
23
|
|
|
24
|
-
#
|
|
25
|
-
|
|
24
|
+
# Normalize away any trailing slash before appending our own — LINT_TARGET can be
|
|
25
|
+
# "resources/js/", "src/" or "." (via override) depending on project type, and
|
|
26
|
+
# concatenating "." directly with "**/*.ext" produces the invalid glob
|
|
27
|
+
# ".**/*.ext" (no match ever).
|
|
28
|
+
LINT_TARGET_GLOB_BASE="${LINT_TARGET%/}/"
|
|
29
|
+
|
|
30
|
+
# Skip gracefully if no matching files exist.
|
|
31
|
+
# The brace portion is intentionally left unquoted so bash's brace expansion
|
|
32
|
+
# splits it into separate arguments before has_files() sees it (see has_files
|
|
33
|
+
# doc comment in config.sh — brace expansion never applies to quoted text or
|
|
34
|
+
# to the contents of a variable).
|
|
35
|
+
if ! has_files "${PROJECT_ROOT}/${LINT_TARGET_GLOB_BASE}"**/*.{js,ts,vue,jsx,tsx}; then
|
|
26
36
|
log_info "No JS/TS files found in ${LINT_TARGET} — skipping"
|
|
27
37
|
exit 0
|
|
28
38
|
fi
|
package/scripts/eslint.sh
CHANGED
|
@@ -31,8 +31,17 @@ fi
|
|
|
31
31
|
|
|
32
32
|
log_step "Checking: $LINT_TARGET"
|
|
33
33
|
|
|
34
|
-
#
|
|
35
|
-
|
|
34
|
+
# Normalize away any trailing slash before appending our own — LINT_TARGET can be
|
|
35
|
+
# "resources/js/", "src/" or "." depending on project type, and concatenating "."
|
|
36
|
+
# directly with "**/*.ext" produces the invalid glob ".**/*.ext" (no match ever).
|
|
37
|
+
LINT_TARGET_GLOB_BASE="${LINT_TARGET%/}/"
|
|
38
|
+
|
|
39
|
+
# Skip gracefully if no matching files exist.
|
|
40
|
+
# The brace portion is intentionally left unquoted so bash's brace expansion
|
|
41
|
+
# splits it into separate arguments before has_files() sees it (see has_files
|
|
42
|
+
# doc comment in config.sh — brace expansion never applies to quoted text or
|
|
43
|
+
# to the contents of a variable).
|
|
44
|
+
if ! has_files "${PROJECT_ROOT}/${LINT_TARGET_GLOB_BASE}"**/*.{js,ts,vue,jsx,tsx}; then
|
|
36
45
|
log_info "No JS/TS files found in ${LINT_TARGET} — skipping"
|
|
37
46
|
exit 0
|
|
38
47
|
fi
|