From 0a359b753baf0d64a0da26f29bc06c777f6e100b Mon Sep 17 00:00:00 2001 From: Winter Date: Wed, 13 Aug 2025 13:34:23 -0400 Subject: [PATCH] ci: add prettier check (hopefully it works) Change-Id: pzwzzlwkkpnwkzmyluspymsoltsxntml Signed-off-by: Winter --- .prettierignore | 13 +++++++++++++ .prettierrc | 10 ++++++++++ .tangled/workflows/fmt.yml | 3 +++ flake.nix | 4 ++++ 4 files changed, 30 insertions(+) create mode 100644 .prettierignore create mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..1246c578 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,13 @@ +flake.lock + +# for now, we don't want these formatted, but let's consider it in the future? +*.json +*.md +*.yml +*.yaml +*.jsonc +*.json + +# causes Go template plugin errors: https://github.com/NiklasPor/prettier-plugin-go-template/issues/120 +appview/pages/templates/layouts/repobase.html +appview/pages/templates/repo/tags.html diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..c99d7d5d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "overrides": [ + { + "files": ["*.html"], + "options": { + "parser": "go-template" + } + } + ] +} diff --git a/.tangled/workflows/fmt.yml b/.tangled/workflows/fmt.yml index 9436c60e..e4165eb6 100644 --- a/.tangled/workflows/fmt.yml +++ b/.tangled/workflows/fmt.yml @@ -17,3 +17,6 @@ steps: unformatted=$(gofmt -l .) test -z "$unformatted" || (echo "$unformatted" && exit 1) + - name: "prettier" + command: | + nix develop -c "prettier -c ." diff --git a/flake.nix b/flake.nix index db11dd27..c07d7be2 100644 --- a/flake.nix +++ b/flake.nix @@ -129,6 +129,10 @@ pkgs.redis pkgs.coreutils # for those of us who are on systems that use busybox (alpine) packages'.lexgen + (pkgs.runCommand "prettier-wrapper" {nativeBuildInputs = [pkgs.makeWrapper];} '' + mkdir -p "$out/bin" + makeWrapper ${pkgs.prettier}/bin/prettier "$out/bin/prettier" --add-flags "--plugin=${pkgs.prettier-plugin-go-template}/lib/node_modules/prettier-plugin-go-template/lib/index.js" + '') ]; shellHook = '' mkdir -p appview/pages/static -- 2.43.0