tsconfig / prettier 設定を最厳格化#372
Merged
Merged
Conversation
@tsconfig/strictest と重複しない範囲で TypeScript 6.0 が提供する最厳格化フラグを 全て有効化。erasableSyntaxOnly / verbatimModuleSyntax / isolatedDeclarations / noUncheckedSideEffectImports に加え、デフォルト値の項目も明示化して将来の挙動 変更に備える。tsc は 0 errors で通過。
Owner
Author
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
- 削除: rangeStart / rangeEnd / filepath (CLI専用で設定ファイルでは無効) - 削除: vueIndentScriptAndStyle / jsxSingleQuote (フレームワーク無関係) - 厳格化: endOfLine "auto" → "lf" - 厳格化: trailingComma "es5" → "all" (Prettier 3.0 デフォルト) - 厳格化: htmlWhitespaceSensitivity "ignore" → "strict" - 厳格化: proseWrap "never" → "always" - 新規: singleAttributePerLine: true (HTML属性を縦並びに) - 新規: bracketSameLine / embeddedLanguageFormatting / objectWrap / experimentalOperatorPosition を明示化(将来のデフォルト変更耐性) .prettierignore を新設し pnpm-lock.yaml / src/js/ を対象外に。 prettier --write で eslint.config.mjs / src/index.html / dependabot-auto-merge.yml(PR #365由来の既存未整形) を整形。 prettier --check と tsc --noEmit はともに 0 errors。
prettier --write の末尾の "." を削除し、lint-staged が渡す 変更ファイルだけを整形する正しい形式に修正。glob を ファイル種別ごとに分割し、否定 glob !(pnpm-lock) で pnpm-lock.yaml をビルトイン除外。設定ファイルを1つ削減。 副次効果: - ESLint も "." 廃止で変更ファイルのみ lint (二重走査解消) - .github/ 配下の yml と md も自動整形対象に拡大 - ルート直下の yaml (pnpm-lock を除く) も対象に
printWidth: 1000 配下では Prettier が >- 折り畳みスカラーの中身を 1行に統合してしまうため、可読性のために && ごとに改行していた if 句が 潰されていた。# prettier-ignore コメントで該当ブロックだけ整形対象外にし、 YAML 意味論(>- = 改行→空白)と GitHub Actions の評価互換性を保ったまま、 ソース上の改行を維持する。
strict は閉じタグの > を独立行に切り出す独特なフォーマットを生み、 diff/可読性ともに代償が大きかった。デフォルトの css に戻して 通常の <tag>\n text\n</tag> 形式へ。singleAttributePerLine: true は 維持し、属性縦並びの厳格化は引き続き有効。
属性縦並びは diff の読みやすさを得る代わりに HTML 全体が縦に 長くなり、初見の可読性を損なう側面が大きかった。デフォルトの false に戻して属性横並びに復帰。src/index.html は main と同形に 戻る。デフォルト値の明示化方針は維持。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
変更1: tsconfig 厳格化(49d25d5)
追加した厳格化(4項目)
デフォルト値の明示化(4項目/将来の挙動変更耐性)
変更2: Prettier 厳格化(2b0fd2f, b0d5f7d, 7a21048)
削除(CLI専用 / プロジェクト無関係)
厳格化(既存設定の変更)
新規追加(デフォルト値の明示化/将来耐性)
既存問題の解消と維持
変更3: lint-staged glob 整理+.prettierignore 廃止(c0932b7)
Before(問題点)
```json
"lint-staged": {
"src/ts/*.ts": [
"pnpm exec eslint . --fix",
"pnpm exec prettier --write ."
]
}
```
After
```json
"lint-staged": {
".{ts,mjs,cjs}": ["pnpm exec eslint --fix", "pnpm exec prettier --write"],
".{html,css,json,md}": ["pnpm exec prettier --write"],
"!(pnpm-lock).{yml,yaml}": ["pnpm exec prettier --write"]
}
```
除外した項目(理由付き)
tsconfig
prettier
Test plan