From 9f5dc101ef13948d6fbd116f4d044f50afebf7d4 Mon Sep 17 00:00:00 2001 From: Simon Warta Date: Mon, 29 Jul 2024 14:41:42 +0200 Subject: [PATCH] Add editorconfig and markdown formatter script --- .editorconfig | 17 +++++++++++++++++ scripts/format.sh | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 .editorconfig create mode 100755 scripts/format.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..6bdc0228 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 120 + +[*.rs] +indent_size = 4 +max_line_length = 100 + +[*.{md,mdx}] +max_line_length = 100 diff --git a/scripts/format.sh b/scripts/format.sh new file mode 100755 index 00000000..94d12316 --- /dev/null +++ b/scripts/format.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -o errexit -o nounset -o pipefail +command -v shellcheck >/dev/null && shellcheck "$0" + +# Running with -c makes the script only validate instead of editing in place. +op="write" +while getopts c option; do + case "${option}" in + c) op="check" ;; + *) ;; + esac +done + +npx prettier@3.3.3 --$op --no-config "./src/**/*.md" "./src/**/*.mdx"