From 21c8cc05c697bdef5450964e73ec7e77e331edf3 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 20 May 2024 23:41:56 +0900 Subject: [PATCH] Replace dprint prettier plugin with yamlfmt --- .github/workflows/lint.yml | 11 +++++++++++ .vscode/extensions.json | 1 + .vscode/settings.json | 6 ++++++ Rakefile | 2 ++ dprint.json | 7 +------ flake.nix | 1 + yamlfmt.yml | 7 +++++++ 7 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 yamlfmt.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b6225d2..b124aad 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,6 +15,17 @@ jobs: with: dprint-version: '0.45.1' # selfup { "regex": "\\d[^']+", "script": "dprint --version | cut -d ' ' -f 2" } + yamlfmt: + timeout-minutes: 15 + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + - name: Install yamlfmt + run: go install github.com/google/yamlfmt/cmd/yamlfmt@v0.12.1 # TODO: Apply selfup after https://github.com/google/yamlfmt/pull/180 + - run: yamlfmt -lint . + typos: timeout-minutes: 15 runs-on: ubuntu-latest diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 23a959e..ee75fed 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -4,6 +4,7 @@ "editorconfig.editorconfig", "tekumara.typos-vscode", "dprint.dprint", + "kachick.vscode-yamlfmt", "jnoortheen.nix-ide" ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 8dbba70..7b93331 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,12 @@ { "editor.defaultFormatter": "dprint.dprint", "editor.formatOnSave": true, + "[yaml]": { + "editor.defaultFormatter": "kachick.vscode-yamlfmt" + }, + "[github-actions-workflow]": { + "editor.defaultFormatter": "kachick.vscode-yamlfmt" + }, "[nix]": { "editor.defaultFormatter": "jnoortheen.nix-ide" }, diff --git a/Rakefile b/Rakefile index 2a25be3..fd3f644 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,7 @@ desc 'Print dependencies' task :deps do sh('ruby --version') sh('dprint --version') + sh('yamlfmt -version') sh('typos --version') end @@ -11,5 +12,6 @@ desc 'Run linters' task :lint do sh('typos . .github .vscode') sh('dprint check') + sh('yamlfmt -lint .') sh('nixpkgs-fmt --check ./*.nix') end diff --git a/dprint.json b/dprint.json index c28245a..b46b72b 100644 --- a/dprint.json +++ b/dprint.json @@ -1,14 +1,9 @@ { "json": {}, "markdown": {}, - "prettier": { - "printWidth": 120, - "singleQuote": true - }, "excludes": ["**/*lock", "lib/**", "doc/**", ".yardoc"], "plugins": [ "https://plugins.dprint.dev/json-0.19.2.wasm", - "https://plugins.dprint.dev/markdown-0.16.4.wasm", - "https://plugins.dprint.dev/prettier-0.39.0.json@896b70f29ef8213c1b0ba81a93cee9c2d4f39ac2194040313cd433906db7bc7c" + "https://plugins.dprint.dev/markdown-0.16.4.wasm" ] } diff --git a/flake.nix b/flake.nix index 94430a6..e32d042 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ ruby_3_2 dprint + yamlfmt nil nixpkgs-fmt typos diff --git a/yamlfmt.yml b/yamlfmt.yml new file mode 100644 index 0000000..417bd4f --- /dev/null +++ b/yamlfmt.yml @@ -0,0 +1,7 @@ +gitignore_excludes: true +line_ending: lf +formatter: + type: basic + retain_line_breaks_single: true + # https://github.com/google/yamlfmt/issues/182 + scan_folded_as_literal: true