Skip to content

Commit 9816076

Browse files
committed
fix: add target dirs exclusions to yamlfmt
Signed-off-by: Josef Andersson <josef.andersson@digg.se>
1 parent a4e76ab commit 9816076

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

linters/config/.yamlfmt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# SPDX-FileCopyrightText: 2025 Digg - Agency for Digital Government
2+
#
3+
# SPDX-License-Identifier: CC0-1.0
4+
5+
# Default yamlfmt configuration for devbase-justkit
6+
# Projects can override this by creating their own .yamlfmt file
7+
8+
exclude:
9+
- target/
10+
- node_modules/
11+
- vendor/
12+
- dist/
13+
- build/
14+
- generated-sources/
15+
- "**/*generated*"
16+
17+
formatter:
18+
type: basic
19+
retain_line_breaks_single: true

linters/yaml.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,21 @@ source "${SCRIPT_DIR}/../utils/colors.sh"
1111

1212
readonly ACTION="${1:-check}"
1313

14+
# Default config with standard exclusions
15+
readonly DEFAULT_CONFIG="${SCRIPT_DIR}/config/.yamlfmt"
16+
17+
get_config_flag() {
18+
# If project has its own config, use default behavior; otherwise use our default
19+
if [[ ! -f ".yamlfmt" && ! -f "yamlfmt.yml" && ! -f "yamlfmt.yaml" && -f "${DEFAULT_CONFIG}" ]]; then
20+
printf "%s" "-conf ${DEFAULT_CONFIG}"
21+
fi
22+
}
23+
1424
check_yaml() {
15-
if yamlfmt -lint .; then
25+
local conf_flag
26+
conf_flag=$(get_config_flag)
27+
# shellcheck disable=SC2086
28+
if yamlfmt -lint $conf_flag .; then
1629
print_success "YAML linting passed"
1730
return 0
1831
else
@@ -22,7 +35,10 @@ check_yaml() {
2235
}
2336

2437
fix_yaml() {
25-
if yamlfmt .; then
38+
local conf_flag
39+
conf_flag=$(get_config_flag)
40+
# shellcheck disable=SC2086
41+
if yamlfmt $conf_flag .; then
2642
print_success "YAML files formatted"
2743
return 0
2844
else

0 commit comments

Comments
 (0)