-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Improve code]: lib/* 手動formatter・Linter対応 #84
Conversation
ひとまず |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応ありがとうございます!確認・必要に応じて対応お願いします。
エラーの出し方(エラーハンドリングの際に返却するe.name
とe.description
の値)については明確にどうするかをまだ決めていなかったので、いったんはこのままにしておきます。
const PageCreationOutputZod = z.object({ | ||
uri: z.string(), | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
気づいていませんでした... Zod接頭辞 + [型名]
で統一しておきますね
astro/src/lib/api/types.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astro/src/pages/api/getOgpMeta.ts
Outdated
const errorObject: errorResponse & { html: string } = { | ||
type: "error", | ||
error: name, | ||
message: msg, | ||
status: 500, | ||
html: responseHTML, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一時期テストに使っていたコードが残ってしまっていたみたいです...
html: string
の戻り値を消していただきたいです。作業範囲的に対象外なので恐縮ですが、よろしくお願いいたします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応しました!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astro/src/lib/pagedbAPI/getIds.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
astro/src/lib/pagedbAPI/getPage.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getPage.tsの方に埋め込む形になったと思うので、消してしまいましょうか。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応しました!
astro/src/pages/posts/[slug].astro
Outdated
|
||
if (typeof getpage_res?.error !== "undefined" && getpage_res.error !== "") { | ||
if ("error" in getPageResult && typeof getPageResult?.error !== "undefined" && getPageResult.error !== "") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
作業範囲的に対象外の修正なので恐縮です。getPageAPIはskyshare定義のAPIなので、戻り型の検証は型特定部分だけで良いと思いました。getPage.ts
を見る限り、エラーの場合は必ずerror
とmessage
を持つレスポンスを行うためです。
なので条件式は("error" in getPageResult)
でもいいかもと思っています、ご意見伺いたいです。
((typeof getpage_res?.error !== "undefined" && getpage_res.error !== "")
という回りくどい書き方をしていたのは、原本を作成した @nkte8 がin
演算子を知らなかったためです...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
了解です!
対応しました
Deploying skyshare with
|
Latest commit: |
62e71ac
|
Status: | ✅ Deploy successful! |
Preview URL: | https://f77f46cd.skyshare.pages.dev |
Branch Preview URL: | https://preview-issue-58.skyshare.pages.dev |
@nkte8 こちらで一度、方針を伝えていただけるとありがたいです! |
上について、#83 (comment) での議論通り、
|
こちらの件ですが、あまり良い実装例が思い浮かばず...すみません。 @nkte8 // PageDeleteButton.tsx(32行目)
if (!("error" in resDeletePage) &&
resDeletePage.result === "ok") {
/* ... */
} else {
let e: Error = new Error((resDeletePage as typeof etype).message)
/* ... */
} ここで条件式を
の3つで場合分けをする方針で進めましょうか? |
@zeke 確認ありがとうございます!
承知です!
ここなんですけど、そもそも元の処理が以下のようになっています。
このAPIだいぶ昔に書いたのですが、多分レスポンス自体に意味はなさそうなんですよね...エラーが発生しなかった場合は必ずresponse 200で、 ので、 |
@nkte8 返信ありがとうございます! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
対応ありがとうございました!マージします
* [Improve code]: pages/* 手動formatter・Linter対応 (#77) * 🚨 未使用の引数`error`の名前にアンダースコアを追加 * 🚨 テンプレートリテラル内のURL型をstring型に変換 * 🎨 astro/src/pagesにPrettierを適用 * 🎨 astro/src/components/*.astroにPrettierを適用 (#76) * 🎨 astro/src/layoutsにPrettierを適用 (#80) * [Improve code]: utils/atproto_api/* 手動formatter・Linter対応 (#81) * 🚨 astro/src/utils/atproto_apiに`eslint . --fix`を実行 * 🎨 astro/src/utils/atproto_api/models/*にPrettierを適用 * 🎨 astro/src/utils/atproto_api/*にPrettierを適用 * ✏️ searchの誤字を修正 * 🏷️ imageの$typeを"blob"のみに限定 * 🚨 暫定的に、astro/src/utils/atproto_api以下のレスポンスを、as構文で型付け * 🎨 astro/src/utils/atproto_api/*.tsにPrettierを適用 * 🏷️ uploadBlobの戻り値の型情報を分割 * [Improve code]: astro/src/components/Client/bsky/* 手動formatter・Linter対応 (#83) * 🚨 astro/src/components/Client/bsky/にESLintの--fixオプションを適用 * 🔒️ target="_blank"付のタグの脆弱性対策を追加 詳細は下記を確認してください。 https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-target-blank.md * 🚨 readDrafts()が常にtruthyな値を返すようなので、OR演算子を削除 * 🏷️ atproto_apiの型定義変更に伴い、既存の実装の型情報を更新 * 🚨 Promise<void>を返す関数にvoidキーワードを追加 * 🚨 バッククォートで囲われたダブルクォートのエスケープを解除 * ✏️ identifierの綴りを修正 * 🚨 map()で繰り返し出力されるコンポーネントに、key属性を追加 * 🚨 使用されないエラー変数にアンダースコアを追加 * 🏷️ atproto_apiの型定義変更に伴い、既存の実装の型情報を更新 * 🎨 astro/src/components/Client/bskyにPrettierを適用 * ✏️ `LoginForm`の注意文言に、環境変数の`servicename`を用いるよう変更 * 💬 エラー処理後の型アサーションを解説するコメントを追記 * 🥅 使用されていないエラー変数名をアンダースコアのみに変更 * 🚨 エラー型の判定を`"error" in val`形式で統一 * ♻️ 変数定義と値の代入を凝集化 * 🚨 エラー型の判定を`"error" in val`形式で統一 * 🏷️ 型アサーションを用いない実装に変更 * 🔥 不要になったimport文を削除 * 🎨 astro/src/components/Client/bsky/*にPrettierを適用 * ESLint修正漏れの修正 --------- Co-authored-by: nekono <[email protected]> * [Improve code]: src/utils/*.ts 手動formatter・Linter対応 (#78) * 🚨 browser-image-compressionエラー処理のリンティングエラーを修正 * 🎨 astro/src/utils/*.tsにPrettierを適用 * ✏️ searchの綴りを修正 * ✨ useLocalStorage.tsにzodによる型チェックを実装 * 🏷️ Zodオブジェクトをタグ、下書きに各々定義 * ➕ 依存関係にZodを追加 * 🏷️ Zodオブジェクトから型情報を定義 & 実際の使用方法に即した型名に変更 * [Improve code]: lib/* 手動formatter・Linter対応 (#84) * 🚨 astro/src/libにESLintのfixオプションを適用 * 🚨 Astroの環境変数をstring型とみなす記述を追加 * 🚨 nullish判定を明確化 * 💬 コメントの空白を半角に変更 * 🏷️ 変数の型情報を明記 * 🎨 astro/src/libにPrettierを適用 * ✏️ ファイル名getIdの綴りを修正 * ✏️ ファイル名変更に伴いimport文を修正 * 🏷️ Astro API用の型をZodで再定義 * 🦺 APIレスポンス取得箇所にバリデーションチェックを追加 * 🏷️ モジュール外で型の名前が重複しないよう変更 * 🩹 APIレスポンス処理時の型エラーに関する文言を修正 * 🏷️ API呼び出し箇所の型定義更新に伴い、エラー判定箇所を修正 * 🥅 getOgpMetaエラー時のステータス番号を定義 * ✏️ Zodオブジェクトの命名規則を統一 * 🥅 エラーレスポンスからhtmlを削除 * 🔥 使用されていないレスポンス型定義用のJSONを削除 * 🥅 エラー型判定の実装を改善 * 🥅 エラー型の判定を`"error" in val`形式で統一 * ⚰️ 使用されていない変数を削除 * ⚰️ 不要になった行を削除 * ➕ 依存関係にZodを追加 * 🥅 エラー型の判定ロジックを変更 & 型アサーション削除 * 🔥 不要になったインポート行を削除 * API応答を待機するコードを追加 (#92) * 🔥 ヘッドブランチを`preview/*`に制限するコードを削除 * 🎨 変数の定義順と使用順を統一 * 💬 分かりやすいコメントに変更 * ✨ ベースブランチに`hotfix/*`が指定できるように修正 --------- Co-authored-by: nekono <[email protected]>
Resolves #58
本PRで行われた変更
const
宣言を追加 (6c056c3)Nullish
判定を明記 (08cb5fe)Prettier
によるコードの整形 (*.tsx, *.astroの変更なし)getId
の綴りを修正 (e5835ec)pagedbAPI
のレスポンスに用いられる型名が、モジュール間で重複しないよう変更 (bad010e)getOgpMeta
エラー時のレスポンス処理で不足していたstatus
を追加 (dcaed42)