From 02bac9bd19a20fd10c0e04ae544c31ad65f5e4d9 Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Mon, 20 May 2024 15:26:21 +0900 Subject: [PATCH] Replace dprint prettier plugin with yamlfmt and 3rd-party WASM plugins (#114) * Replace dprint prettier plugin with yamlfmt and 3rd-party WASM plugins * Enable renovatebot for updating dprint plugins --- .github/renovate.json | 10 ++++++++++ .github/workflows/ci.yml | 4 ++++ .vscode/extensions.json | 1 + .vscode/settings.json | 6 ++++++ deno.jsonc | 2 +- dprint.json | 8 ++++---- flake.nix | 1 + src/github-patcher.css | 7 ++++--- src/options.html | 9 +++++---- yamlfmt.yml | 7 +++++++ 10 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 .github/renovate.json create mode 100644 yamlfmt.yml diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..5a1330a --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>kachick/renovate-config-dprint#1.1.0" + ], + "labels": ["dependencies", "renovate"], + "nix": { + "enabled": false + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b838de..4c8cc76 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,10 @@ jobs: with: dprint-version: '0.45.1' # selfup {"extract":"\\d[^']+","replacer":["bash","-c","dprint --version | cut -d ' ' -f 2"]} - uses: crate-ci/typos@v1.21.0 # selfup {"extract":"\\d\\.\\d+\\.\\d+","replacer":["bash","-c","typos --version | cut -d ' ' -f 2"]} + - 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 - uses: denoland/setup-deno@v1 with: deno-version: '1.43.1' # selfup {"extract":"\\d[^']+","replacer":["bash","-c","deno --version | head -n 1 | cut -d ' ' -f 2"]} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 3fdf6f2..a130e2e 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", "denoland.vscode-deno" ] diff --git a/.vscode/settings.json b/.vscode/settings.json index 097b457..f4ca99d 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" + }, "[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }, diff --git a/deno.jsonc b/deno.jsonc index 29f2a6b..4a66361 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -2,7 +2,7 @@ "tasks": { "build": "deno run --quiet --allow-net --allow-read --allow-write --allow-env scripts/build.ts", "clean": "rm -rf ./dist", - "check": "dprint check && typos && deno fmt --check && deno lint && deno check src/*.ts* scripts/*.ts && deno task check:manifest", + "check": "dprint check && typos && deno fmt --check && deno lint && yamlfmt -lint . && deno check src/*.ts* scripts/*.ts && deno task check:manifest", "check:manifest": "deno run scripts/manifestValidator.ts", "stylelint": "deno task cache:stylelint && deno run --node-modules-dir --allow-env --allow-read --allow-sys npm:stylelint@15.10.3/stylelint src/*.css | deno run --allow-sys scripts/checkEmpty.ts", "deps": "deno --version && mogrify --version && dprint --version && typos --version && rg --version", diff --git a/dprint.json b/dprint.json index dfb76d2..dd153cd 100644 --- a/dprint.json +++ b/dprint.json @@ -1,15 +1,15 @@ { "json": {}, "markdown": {}, - "prettier": { - "printWidth": 120, - "singleQuote": true + "malva": { + "quotes": "preferSingle" }, "excludes": ["*.ts*", "dist/", "node_modules/", ".git/", "vendor/"], "plugins": [ "https://plugins.dprint.dev/json-0.19.2.wasm", "https://plugins.dprint.dev/markdown-0.16.4.wasm", "https://plugins.dprint.dev/toml-0.6.1.wasm", - "https://plugins.dprint.dev/prettier-0.39.0.json@896b70f29ef8213c1b0ba81a93cee9c2d4f39ac2194040313cd433906db7bc7c" + "https://plugins.dprint.dev/g-plane/malva-v0.4.0.wasm", + "https://plugins.dprint.dev/g-plane/markup_fmt-v0.8.0.wasm" ] } diff --git a/flake.nix b/flake.nix index 1cb1f3a..65d50fc 100644 --- a/flake.nix +++ b/flake.nix @@ -25,6 +25,7 @@ dprint deno + yamlfmt ripgrep typos diff --git a/src/github-patcher.css b/src/github-patcher.css index 69a4039..0956395 100644 --- a/src/github-patcher.css +++ b/src/github-patcher.css @@ -8,13 +8,14 @@ a[href$='/watchers'] strong, #repo-network-counter, #repo-notifications-counter, /* Do not hide other endpoints like `api/top-langs` */ -a:has(> img[data-canonical-src^='https://github-readme-stats.vercel.app/api?']) -{ +a:has(> img[data-canonical-src^='https://github-readme-stats.vercel.app/api?']) { display: none; } li:has(> a[href$='/followers']), div:has(> h2 a[href$='?tab=achievements']), -aside[aria-label='Explore'] div[aria-label='Explore repositories'] div:has(> svg[aria-label='star']) { +aside[aria-label='Explore'] + div[aria-label='Explore repositories'] + div:has(> svg[aria-label='star']) { display: none !important; } diff --git a/src/options.html b/src/options.html index 4fef324..9c351a3 100644 --- a/src/options.html +++ b/src/options.html @@ -1,4 +1,4 @@ - + @@ -9,9 +9,10 @@
- depop + depop
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