diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..27fed85 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{bats,sh,yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index 70215be..c13c93a 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,3 +2,4 @@ tests/ export-ignore .github/ export-ignore .gitattributes export-ignore +.editorconfig export-ignore diff --git a/.github/scripts/update-checker.sh b/.github/scripts/update-checker.sh index 9f9780a..709a506 100755 --- a/.github/scripts/update-checker.sh +++ b/.github/scripts/update-checker.sh @@ -347,6 +347,19 @@ check_file_formatting() { done < <(git ls-files -z 2>/dev/null | grep -zv '^tests/testdata/') } +# Check .editorconfig +check_editorconfig() { + local editorconfig=".editorconfig" + + if [[ -f "$editorconfig" ]]; then + if ! grep -q "charset = utf-8" "$editorconfig"; then + actions+=("$editorconfig should contain 'charset = utf-8', see upstream file $UPSTREAM/$editorconfig") + fi + else + actions+=("$editorconfig is missing, see upstream file $UPSTREAM/$editorconfig") + fi +} + # Main function main() { if [[ ! -f "install.yaml" ]]; then @@ -400,6 +413,9 @@ main() { # Check file formatting check_file_formatting + # Check .editorconfig + check_editorconfig + # Display info messages if any if [[ ${#info_messages[@]} -gt 0 ]]; then echo "INFO:" >&2