build: adding nix, shell, and haskell code formatters

These need to be run through the top-level nix-shell/shell.nix
This commit is contained in:
Brendan Hay 2020-10-27 11:50:05 +01:00
parent 345bf2c39a
commit 48aa77a2fa
No known key found for this signature in database
GPG Key ID: 80E915C54A7C457D
4 changed files with 59 additions and 0 deletions

15
sh/fmt Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Usage: fmt
# Run all formatters and linters ensuring codebase consistency
set -euo pipefail
cd "${0%/*}"
./fmt-shell
./fmt-nix
./fmt-haskell
echo 'Done.'

18
sh/fmt-haskell Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Usage: fmt-haskell
set -euo pipefail
cd "${0%/*}/.."
echo "Formatting Haskell"
# FIXME: Avoid inplace (-i) modifications for now.
find pkg/hs -type f -name '*.hs' \
-exec ormolu --mode check \
-o '-XBangPatterns' \
-o '-XMagicHash' \
-o '-XTypeApplications' \
-o '-XPatternSynonyms' \
{} \+

12
sh/fmt-nix Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Usage: fmt-nix
set -euo pipefail
cd "${0%/*}/.."
echo "Formatting Nix"
find . -type f -name '*.nix' \
-exec nixfmt {} \+

14
sh/fmt-shell Executable file
View File

@ -0,0 +1,14 @@
#!/usr/bin/env bash
# Usage: fmt-shell
set -euo pipefail
cd "${0%/*}/.."
echo "Formatting Shell"
# FIXME: Avoid inplace (-w) modifications for now.
find sh -type f \
-exec shfmt -s -i 2 -ln bash -l {} \+ \
-exec shellcheck --shell=bash --format=tty {} \+