refactor: コーディング規約に合わせて全体を書き換える - #8
Open
tatuharu wants to merge 1 commit into
Open
Conversation
三項演算子 `?:` / オプショナルチェーン `?.` / null合体演算子 `??` の使用を
やめ、条件分岐は if/else で明示する。条件文・ループ・重要なメソッド呼び出しに
処理の意図を説明する日本語コメントを付けた。
acorn で全ファイルを走査して機械的に洗い出し、三項演算子 65箇所・
オプショナルチェーン 96箇所・null合体 2箇所を展開している。あわせて
JSX の `{x && ...}` による条件描画も描画前に if/else で組み立てる形へ直し、
波括弧を省略していた if には波括弧を付けた。
そのまま展開すると読みにくくなる箇所はヘルパーへ切り出した。
- api.js: errorCodeOf() … LoginPage / SettingsPage で重複していた
`err?.payload?.error` を共通化
- RoomPage.jsx: isOkResponse() / responseErrorCode() … `response?.ok` が
12箇所あったため。4重ネストの三項だった座席パネルは
buildSeatActions() に切り出す
- room-do.js: readyFlags() … `game.ready?.black` が4箇所
- index.js: readTrimmed() / readPassword() …
`typeof x === "string" ? x.trim() : ""` が6箇所
shadcn/ui の生成物(client/src/components/ui, client/src/lib/utils.js)は
再生成のたびに差分が壊れるため対象外とした。button.jsx に三項演算子が
1箇所残っている。
作業中だった CPU AI の反復深化・分割探索まわりの変更(ai.js / game.js /
README.md / wrangler.jsonc)も同じファイルに混在しているため一緒に含めた。
eslint / vite build / worker 全ファイルの node --check に加え、ゲームロジックと
AI のスモークテスト(正規化・着手・4目/5目判定・分割探索・難易度解決など
37項目)を書いて確認した。
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
yonmoque | 1028189 | Aug 28 2026, 05:50 AM |
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.
概要
全プロジェクト共通のコーディング規約に合わせて、このリポジトリの自作コードを書き換えました。
?:/ オプショナルチェーン?./ null合体演算子??の使用をやめるif/elseで明示する(短縮記法で代替しない)変更内容
acorn で全ファイルを走査して機械的に洗い出し、以下を展開しました。
?:?.??あわせて、JSX の
{x && ...}による条件描画を描画前にif/elseで組み立てる形へ直し、波括弧を省略していたifに波括弧を付けています。そのまま展開すると読みにくくなる箇所はヘルパーへ切り出しました。
api.js:errorCodeOf()… LoginPage / SettingsPage で重複していたerr?.payload?.errorを共通化RoomPage.jsx:isOkResponse()/responseErrorCode()…response?.okが12箇所あったため。4重ネストの三項だった座席パネルはbuildSeatActions()に切り出しroom-do.js:readyFlags()…game.ready?.blackが4箇所index.js:readTrimmed()/readPassword()…typeof x === "string" ? x.trim() : ""が6箇所対象外
shadcn/ui の生成物(
client/src/components/ui,client/src/lib/utils.js)は再生成のたびに差分が壊れるため対象外としました。button.jsxに三項演算子が1箇所残っています。同梱している変更
作業中だった CPU AI の反復深化・分割探索まわりの変更(
ai.js/game.js/README.md/wrangler.jsonc)も、同じファイル内で混在していて分離できないため一緒に含めています。動作確認
eslint… パスvite build… 成功node --check… パス