Skip to content

Commit

Permalink
Meta: Enforce Prettier formatting of Markdown files
Browse files Browse the repository at this point in the history
We already use the opinionated Prettier formatter
for JavaScript (with appropriate configuration),
and in general it seems to be one of the best
Markdown auto-formatters. Therefore, the choice
seems natural to finally enforce Markdown
formatting.
  • Loading branch information
kleinesfilmroellchen authored and nico committed Oct 4, 2024
1 parent 19163e7 commit f0ba4d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Meta/lint-prettier.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ if [ "$#" -eq "0" ]; then
git ls-files \
--exclude-from .prettierignore \
-- \
'*.js' '*.mjs'
'*.js' '*.mjs' '*.md'
)
else
files=()
for file in "$@"; do
if [[ "${file}" == *".js" ]] || [[ "${file}" == *".mjs" ]]; then
if [[ "${file}" == *".js" || "${file}" == *".mjs" || "${file}" == *".md" ]]; then
files+=("${file}")
fi
done
fi

if (( ${#files[@]} )); then
if ! command -v prettier >/dev/null 2>&1 ; then
echo "prettier is not available, but JS files need linting! Either skip this script, or install prettier."
echo "prettier is not available, but JS or Markdown files need linting! Either skip this script, or install prettier."
exit 1
fi

Expand All @@ -34,5 +34,5 @@ if (( ${#files[@]} )); then

prettier --check "${files[@]}"
else
echo "No .js or .mjs files to check."
echo "No .js, .mjs, or .md files to check."
fi

0 comments on commit f0ba4d9

Please sign in to comment.