From ff0db1fbf9c58a51e63ebe4dc7d4249f1d0e213a Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 04:49:20 +0000 Subject: [PATCH 1/5] Add Prettier formatter with shell script support - Add Prettier and prettier-plugin-sh for unified formatting - Configure formatting for JSON, YAML, Markdown, and Shell scripts - Enable pre-commit hooks for format checking via lefthook - Add npm scripts for formatting and format checking - Format existing files with Prettier --- .prettierrc.json | 9 ++++ AGENTS.md | 1 + home/dot_claude/commands/create-pr.md | 2 +- home/dot_claude/commands/draft-pr.md | 10 ++-- home/dot_zsh.d/dev-tools.zsh | 2 +- home/dot_zsh.d/fzf.zsh | 8 +-- lefthook.yml | 11 ++-- package-lock.json | 74 ++++++++++++++++++++++++++- package.json | 10 +++- 9 files changed, 107 insertions(+), 20 deletions(-) create mode 100644 .prettierrc.json diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..7bdab7d --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "semi": false, + "singleQuote": false, + "trailingComma": "none", + "printWidth": 100, + "tabWidth": 2, + "proseWrap": "preserve", + "plugins": ["prettier-plugin-sh"] +} diff --git a/AGENTS.md b/AGENTS.md index 5c2f3f6..8135741 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,6 +5,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Repository Overview This is a dotfiles repository managed by **chezmoi**. Chezmoi uses special file naming conventions: + - `dot_` prefix → `.` (e.g., `dot_zshrc` → `~/.zshrc`) - `.tmpl` suffix → Template files processed with variables (e.g., `dot_gitconfig.tmpl`) diff --git a/home/dot_claude/commands/create-pr.md b/home/dot_claude/commands/create-pr.md index cb6fa64..04b6e3b 100644 --- a/home/dot_claude/commands/create-pr.md +++ b/home/dot_claude/commands/create-pr.md @@ -68,7 +68,7 @@ argument-hint: "[オプション: PR作成時の追加指示]" - ベースブランチをもとにPRを作成: ```bash - gh pr create --base <ベースブランチ> --title "$(head -n1 PR.md)" --body "$(tail -n+2 PR.md)" + gh pr create --base "$(head -n1 PR.md)" --body "$(tail -n+2 PR.md)" < ベースブランチ > --title ``` - PR URLを表示 diff --git a/home/dot_claude/commands/draft-pr.md b/home/dot_claude/commands/draft-pr.md index b83fa48..cbb74c6 100644 --- a/home/dot_claude/commands/draft-pr.md +++ b/home/dot_claude/commands/draft-pr.md @@ -30,9 +30,9 @@ PRに含めるコミットがあるか確認 ### 2. **既存のPR.mdの確認** `PR.md`が既に存在する場合: - その内容を読み取る - ユーザーに上書きするか編集するか尋ねる(AskUserQuestionを使用) - 既存のものを保持したい場合は終了 +その内容を読み取る +ユーザーに上書きするか編集するか尋ねる(AskUserQuestionを使用) +既存のものを保持したい場合は終了 - `PR.md`が存在しない場合: - 生成を進める @@ -41,7 +41,7 @@ PRに含めるコミットがあるか確認 - ユーザーの過去のPRを検索: `gh pr list --author @me --state merged --limit 10` - ユーザーに過去のPRがある場合: - 最近の2-3件のPRの詳細を取得 + 最近の2-3件のPRの詳細を取得 - 分析: タイトル形式、説明構造、使用言語 - PR説明の書き方のパターンを記録 @@ -55,7 +55,7 @@ PRテンプレートを確認: `.github/pull_request_template.md`または類似 - `git log <ベースブランチ>..HEAD --pretty=format:"%s"` - ファイル変更を取得: - `git diff <ベースブランチ>..HEAD --stat` +`git diff <ベースブランチ>..HEAD --stat` - `git diff <ベースブランチ>..HEAD`(詳細な変更用) diff --git a/home/dot_zsh.d/dev-tools.zsh b/home/dot_zsh.d/dev-tools.zsh index 20fa86b..448b4a4 100644 --- a/home/dot_zsh.d/dev-tools.zsh +++ b/home/dot_zsh.d/dev-tools.zsh @@ -15,4 +15,4 @@ export NI_DEFAULT_AGENT="pnpm" export NI_GLOBAL_AGENT="pnpm" # Code editor -export VISUAL="code" \ No newline at end of file +export VISUAL="code" diff --git a/home/dot_zsh.d/fzf.zsh b/home/dot_zsh.d/fzf.zsh index bb33279..5e827ae 100644 --- a/home/dot_zsh.d/fzf.zsh +++ b/home/dot_zsh.d/fzf.zsh @@ -16,9 +16,9 @@ export FZF_CTRL_T_OPTS=" # Ctrl+R - History Search function fzf-select-history() { - BUFFER=$(history -n -r 1 | fzf --query "$LBUFFER") - CURSOR=$#BUFFER - zle reset-prompt + BUFFER=$(history -n -r 1 | fzf --query "$LBUFFER") + CURSOR=$#BUFFER + zle reset-prompt } zle -N fzf-select-history -bindkey '^r' fzf-select-history \ No newline at end of file +bindkey '^r' fzf-select-history diff --git a/lefthook.yml b/lefthook.yml index b832d44..5bb6f40 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -15,8 +15,9 @@ pre-push: exit 1 fi -# pre-commit: -# TODO: formatting checks -# parallel: true -# jobs: -# - run: +pre-commit: + parallel: true + commands: + format-check: + glob: "*.{json,yml,yaml,md,sh,zsh}" + run: npx prettier --check {staged_files} diff --git a/package-lock.json b/package-lock.json index c318eca..f5f67f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,14 @@ { - "name": "dotfiles_chezmoi", + "name": "dotfiles", "lockfileVersion": 3, "requires": true, "packages": { "": { + "name": "dotfiles", "devDependencies": { - "lefthook": "^2.0.3" + "lefthook": "2.0.3", + "prettier": "^3.4.2", + "prettier-plugin-sh": "^0.14.0" } }, "node_modules/lefthook": { @@ -170,6 +173,73 @@ "os": [ "win32" ] + }, + "node_modules/mvdan-sh": { + "version": "0.10.1", + "resolved": "https://registry.npmjs.org/mvdan-sh/-/mvdan-sh-0.10.1.tgz", + "integrity": "sha512-kMbrH0EObaKmK3nVRKUIIya1dpASHIEusM13S4V1ViHFuxuNxCo+arxoa6j/dbV22YBGjl7UKJm9QQKJ2Crzhg==", + "deprecated": "See https://github.com/mvdan/sh/issues/1145", + "dev": true, + "license": "BSD-3-Clause" + }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/prettier-plugin-sh": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/prettier-plugin-sh/-/prettier-plugin-sh-0.14.0.tgz", + "integrity": "sha512-hfXulj5+zEl/ulrO5kMuuTPKmXvOg0bnLHY1hKFNN/N+/903iZbNp8NyZBTsgI8dtkSgFfAEIQq0IQTyP1ZVFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "mvdan-sh": "^0.10.1", + "sh-syntax": "^0.4.1" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + }, + "peerDependencies": { + "prettier": "^3.0.3" + } + }, + "node_modules/sh-syntax": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/sh-syntax/-/sh-syntax-0.4.2.tgz", + "integrity": "sha512-/l2UZ5fhGZLVZa16XQM9/Vq/hezGGbdHeVEA01uWjOL1+7Ek/gt6FquW0iKKws4a9AYPYvlz6RyVvjh3JxOteg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" } } } diff --git a/package.json b/package.json index d006f3f..3f0588a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,12 @@ { "name": "dotfiles", + "scripts": { + "format": "prettier --write '**/*.{json,yml,yaml,md,sh,zsh}'", + "format:check": "prettier --check '**/*.{json,yml,yaml,md,sh,zsh}'" + }, "devDependencies": { - "lefthook": "2.0.3" + "lefthook": "2.0.3", + "prettier": "^3.4.2", + "prettier-plugin-sh": "^0.14.0" } -} \ No newline at end of file +} From 37315a04151100494153be24eca1501c25d90b46 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 04:54:27 +0000 Subject: [PATCH 2/5] Replace prettier-plugin-sh with shfmt + shellcheck - Remove prettier-plugin-sh (deprecated dependency) - Use shfmt for shell script formatting - Add shellcheck for shell script linting - Update lefthook pre-commit hooks with separate checks: - Prettier: JSON, YAML, Markdown - shfmt: Shell script formatting - shellcheck: Shell script linting (with fallback) - Update npm scripts for new formatter setup --- .prettierrc.json | 3 +-- lefthook.yml | 10 +++++++-- package-lock.json | 54 +---------------------------------------------- package.json | 7 +++--- 4 files changed, 13 insertions(+), 61 deletions(-) diff --git a/.prettierrc.json b/.prettierrc.json index 7bdab7d..a064b78 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -4,6 +4,5 @@ "trailingComma": "none", "printWidth": 100, "tabWidth": 2, - "proseWrap": "preserve", - "plugins": ["prettier-plugin-sh"] + "proseWrap": "preserve" } diff --git a/lefthook.yml b/lefthook.yml index 5bb6f40..5ea89a9 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -18,6 +18,12 @@ pre-push: pre-commit: parallel: true commands: - format-check: - glob: "*.{json,yml,yaml,md,sh,zsh}" + prettier-check: + glob: "*.{json,yml,yaml,md}" run: npx prettier --check {staged_files} + shfmt-check: + glob: "*.{sh,zsh,bash}" + run: shfmt -d -i 2 {staged_files} + shellcheck: + glob: "*.{sh,zsh,bash}" + run: shellcheck {staged_files} || echo "⚠️ shellcheck not found, skipping lint check" diff --git a/package-lock.json b/package-lock.json index f5f67f3..7f84561 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,8 +7,7 @@ "name": "dotfiles", "devDependencies": { "lefthook": "2.0.3", - "prettier": "^3.4.2", - "prettier-plugin-sh": "^0.14.0" + "prettier": "^3.4.2" } }, "node_modules/lefthook": { @@ -174,14 +173,6 @@ "win32" ] }, - "node_modules/mvdan-sh": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/mvdan-sh/-/mvdan-sh-0.10.1.tgz", - "integrity": "sha512-kMbrH0EObaKmK3nVRKUIIya1dpASHIEusM13S4V1ViHFuxuNxCo+arxoa6j/dbV22YBGjl7UKJm9QQKJ2Crzhg==", - "deprecated": "See https://github.com/mvdan/sh/issues/1145", - "dev": true, - "license": "BSD-3-Clause" - }, "node_modules/prettier": { "version": "3.6.2", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", @@ -197,49 +188,6 @@ "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" } - }, - "node_modules/prettier-plugin-sh": { - "version": "0.14.0", - "resolved": "https://registry.npmjs.org/prettier-plugin-sh/-/prettier-plugin-sh-0.14.0.tgz", - "integrity": "sha512-hfXulj5+zEl/ulrO5kMuuTPKmXvOg0bnLHY1hKFNN/N+/903iZbNp8NyZBTsgI8dtkSgFfAEIQq0IQTyP1ZVFQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "mvdan-sh": "^0.10.1", - "sh-syntax": "^0.4.1" - }, - "engines": { - "node": ">=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - }, - "peerDependencies": { - "prettier": "^3.0.3" - } - }, - "node_modules/sh-syntax": { - "version": "0.4.2", - "resolved": "https://registry.npmjs.org/sh-syntax/-/sh-syntax-0.4.2.tgz", - "integrity": "sha512-/l2UZ5fhGZLVZa16XQM9/Vq/hezGGbdHeVEA01uWjOL1+7Ek/gt6FquW0iKKws4a9AYPYvlz6RyVvjh3JxOteg==", - "dev": true, - "license": "MIT", - "dependencies": { - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, - "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, - "license": "0BSD" } } } diff --git a/package.json b/package.json index 3f0588a..c9e554b 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,11 @@ { "name": "dotfiles", "scripts": { - "format": "prettier --write '**/*.{json,yml,yaml,md,sh,zsh}'", - "format:check": "prettier --check '**/*.{json,yml,yaml,md,sh,zsh}'" + "format": "prettier --write '**/*.{json,yml,yaml,md}' && shfmt -w -i 2 home/**/*.zsh", + "format:check": "prettier --check '**/*.{json,yml,yaml,md}' && shfmt -d -i 2 home/**/*.zsh && shellcheck home/**/*.zsh" }, "devDependencies": { "lefthook": "2.0.3", - "prettier": "^3.4.2", - "prettier-plugin-sh": "^0.14.0" + "prettier": "^3.4.2" } } From fb455bbe57e47a0e6ba74cd15374c8972f83943b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 05:01:00 +0000 Subject: [PATCH 3/5] Add concurrently for parallel formatter execution - Add concurrently package for running formatters in parallel - Update format and format:check scripts to use concurrent execution - Add individual scripts for each formatter/checker: - format:prettier, format:shell - check:prettier, check:shfmt, check:shellcheck - Improve performance by running checks in parallel --- package-lock.json | 315 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 10 +- 2 files changed, 323 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7f84561..b000af3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,10 +6,174 @@ "": { "name": "dotfiles", "devDependencies": { + "concurrently": "^9.1.1", "lefthook": "2.0.3", "prettier": "^3.4.2" } }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/concurrently": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-9.2.1.tgz", + "integrity": "sha512-fsfrO0MxV64Znoy8/l1vVIjjHa29SZyyqPgQBwhiDcaW8wJc2W3XWVOGx4M3oJBnv/zdUZIIp1gDeS98GzP8Ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "chalk": "4.1.2", + "rxjs": "7.8.2", + "shell-quote": "1.8.3", + "supports-color": "8.1.1", + "tree-kill": "1.2.2", + "yargs": "17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "license": "ISC", + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/lefthook": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/lefthook/-/lefthook-2.0.3.tgz", @@ -188,6 +352,157 @@ "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rxjs": { + "version": "7.8.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.2.tgz", + "integrity": "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/shell-quote": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", + "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "dev": true, + "license": "0BSD" + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=10" + } + }, + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.1.1" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=12" + } } } } diff --git a/package.json b/package.json index c9e554b..b2d4fae 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,16 @@ { "name": "dotfiles", "scripts": { - "format": "prettier --write '**/*.{json,yml,yaml,md}' && shfmt -w -i 2 home/**/*.zsh", - "format:check": "prettier --check '**/*.{json,yml,yaml,md}' && shfmt -d -i 2 home/**/*.zsh && shellcheck home/**/*.zsh" + "format": "concurrently --group \"prettier --write '**/*.{json,yml,yaml,md}'\" \"shfmt -w -i 2 home/**/*.zsh\"", + "format:check": "concurrently --group \"prettier --check '**/*.{json,yml,yaml,md}'\" \"shfmt -d -i 2 home/**/*.zsh\" \"shellcheck home/**/*.zsh || exit 0\"", + "format:prettier": "prettier --write '**/*.{json,yml,yaml,md}'", + "format:shell": "shfmt -w -i 2 home/**/*.zsh", + "check:prettier": "prettier --check '**/*.{json,yml,yaml,md}'", + "check:shfmt": "shfmt -d -i 2 home/**/*.zsh", + "check:shellcheck": "shellcheck home/**/*.zsh || exit 0" }, "devDependencies": { + "concurrently": "^9.1.1", "lefthook": "2.0.3", "prettier": "^3.4.2" } From e624bd7381743e2106dfc5d661d5f18415791004 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 05:09:39 +0000 Subject: [PATCH 4/5] Refactor lefthook to use npm scripts - Add lint:prettier, lint:shfmt, lint:shellcheck to package.json - Update lefthook.yml to call npm run instead of direct commands - Centralize command definitions in npm scripts for better maintainability - Replace npx prettier with npm run lint:prettier --- lefthook.yml | 6 +++--- package.json | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lefthook.yml b/lefthook.yml index 5ea89a9..a7a64e3 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -20,10 +20,10 @@ pre-commit: commands: prettier-check: glob: "*.{json,yml,yaml,md}" - run: npx prettier --check {staged_files} + run: npm run lint:prettier -- {staged_files} shfmt-check: glob: "*.{sh,zsh,bash}" - run: shfmt -d -i 2 {staged_files} + run: npm run lint:shfmt -- {staged_files} shellcheck: glob: "*.{sh,zsh,bash}" - run: shellcheck {staged_files} || echo "⚠️ shellcheck not found, skipping lint check" + run: npm run lint:shellcheck -- {staged_files} || echo "⚠️ shellcheck not found, skipping lint check" diff --git a/package.json b/package.json index b2d4fae..37a18bb 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,10 @@ "format:shell": "shfmt -w -i 2 home/**/*.zsh", "check:prettier": "prettier --check '**/*.{json,yml,yaml,md}'", "check:shfmt": "shfmt -d -i 2 home/**/*.zsh", - "check:shellcheck": "shellcheck home/**/*.zsh || exit 0" + "check:shellcheck": "shellcheck home/**/*.zsh || exit 0", + "lint:prettier": "prettier --check", + "lint:shfmt": "shfmt -d -i 2", + "lint:shellcheck": "shellcheck" }, "devDependencies": { "concurrently": "^9.1.1", From 1a810dcc8886e8c503f9346f134af4ea8b4427f9 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 12:54:02 +0000 Subject: [PATCH 5/5] Add VSCode format on save configuration - Add .vscode/settings.json with formatOnSave enabled - Configure Prettier for JSON, YAML, Markdown - Configure shell-format for shell scripts - Add .vscode/extensions.json with recommended extensions - Update README with setup instructions and tool installation --- .vscode/extensions.json | 3 +++ .vscode/settings.json | 20 ++++++++++++++++++ README.md | 45 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..249173c --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["esbenp.prettier-vscode", "foxundermoon.shell-format", "timonwong.shellcheck"] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..846867d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,20 @@ +{ + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode", + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[jsonc]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[yaml]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[markdown]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[shellscript]": { + "editor.defaultFormatter": "foxundermoon.shell-format" + }, + "shellformat.flag": "-i 2" +} diff --git a/README.md b/README.md index 9f33cb0..001cfef 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,48 @@ ## 📝 About This is nyatinte's private dotfiles repository, managed with [chezmoi](https://www.chezmoi.io/) for consistent configuration across multiple machines. + +## 🚀 Setup + +### Prerequisites + +Install the following tools: + +```bash +# Install npm dependencies (Prettier, concurrently, lefthook) +npm install + +# Install shfmt (shell script formatter) +go install mvdan.cc/sh/v3/cmd/shfmt@latest + +# Install shellcheck (shell script linter) +# macOS +brew install shellcheck + +# Ubuntu/Debian +apt-get install shellcheck + +# Other: https://github.com/koalaman/shellcheck#installing +``` + +### VSCode Extensions + +Install recommended extensions for automatic formatting: + +- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) +- [shell-format](https://marketplace.visualstudio.com/items?itemName=foxundermoon.shell-format) +- [ShellCheck](https://marketplace.visualstudio.com/items?itemName=timonwong.shellcheck) + +## 🔧 Usage + +```bash +# Format all files +npm run format + +# Check formatting (CI) +npm run format:check + +# Format specific types +npm run format:prettier # JSON, YAML, Markdown +npm run format:shell # Shell scripts +```