frontend-typescript-rules-73b661 — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited frontend-typescript-rules-73b661 (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
実装向けの frontend 固有 React/TypeScript ルール: しきい値、境界での型安全性、コンポーネント/状態の設計、エラーハンドリング、プロジェクト規約。
プロジェクト規約を適用する前に、TypeScript、bundler/framework、lint・format、path alias、React Compiler、代表的なコンポーネントの設定を確認する。設定またはリポジトリで確立済みのパターンに裏付けられた規約を確認済みとして扱い、限られた例から導いた結論には推測であることを明記する。競合するパターンによって公開される振る舞い、互換性、コンポーネント境界が変わる場合は作業を止め、必要な情報源または判断を具体的に示す。
設計変更を促すシグナル:
信頼できない型または取得できない型はunknownで受け、型ガードで絞り込む。asは、runtime/frameworkの不変条件によって対象の型が保証される場合にのみ使用し、その不変条件を近くのコメントに記録する。既存の生成コードまたはサードパーティの型宣言に含まれるanyは、ラップすべき境界入力であり、アプリケーションの契約へanyを広げる根拠にはならない。
アプリ内部では React の Props/State は型保証されており unknown は不要。外部境界では必ず unknown で受け、使用前に型ガードで絞り込む: API レスポンス、localStorage/sessionStorage、URL パラメータ、パースした JSON。制御コンポーネントのフォーム入力は React 合成イベントを通じて型安全に保たれる。
const raw: unknown = await (await fetch(url)).json()
if (!isUser(raw)) throw new ValidationError('invalid user')
const user = raw // User に絞り込み済みfunction UserCard({ user, onSelect }: UserCardProps)。propsを関数に直接型付けしてProps契約を明示するuseState ではなく discriminated union の action 型を用いた useReducer にする"use client" 境界の内側に隔離する。ブラウザ専用 API(window、localStorage、イベントハンドラ)はクライアントコンポーネント内に留める。サーバーコンポーネントで呼ぶとレンダリングが壊れるためである。クライアントのみの SPA(例: Vite)では N/A であり、サーバーコンポーネントランタイムが無いプロジェクトではスキップするResult 型で値として表現する。throw は想定外/回復不能なケースに限るcode を持つ基底 AppError を継承する(例: ValidationError, ApiError, NotFoundError)AppError を上位へ伝播する。Error Boundary はレンダリング時のエラーを捕捉しフォールバック UI を表示するuseEffect 内のデータ取得は、順序が入れ替わった応答とアンマウント後の状態更新に対してガードする。具体的には、AbortController か mounted フラグで stale な結果を中断・無視するか、キャンセルと重複排除を行うサーバー状態ライブラリ(React Query/SWR)を使う。try-catch だけではこれをカバーできないtype Result<T, E> = { ok: true; value: T } | { ok: false; error: E }
class AppError extends Error {
constructor(message: string, readonly code: string, readonly statusCode = 500) {
super(message); this.name = this.constructor.name
}
}Error Boundary — class component が必要となる唯一の箇所:
class ErrorBoundary extends React.Component<{ children: React.ReactNode; fallback: React.ReactNode }, { hasError: boolean }> {
state = { hasError: false }
static getDerivedStateFromError() { return { hasError: true } }
render() { return this.state.hasError ? this.props.fallback : this.props.children }
}import.meta.env.VITE_*、Next.jsの公開変数はprocess.env.NEXT_PUBLIC_*、CRAはprocess.env.REACT_APP_*。フロントエンドのバンドルには公開設定だけを含め、シークレットはサーバー側の境界内に置くbuild スクリプトでプロジェクトの予算に対して監視する。React.lazy + Suspense でコード分割する。再レンダリングを最小化する状態構造にする。メモ化: React Compiler が有効なときはそれに任せる。手動の React.memo/useMemo/useCallback は、プロファイラの実測または参照同一性の必要性で裏付けられる場合に限る(実測されたボトルネック、またはサードパーティ API や effect 依存に対する安定した参照同一性)PascalCase、変数/関数は camelCase、hook は use 接頭辞、定数は SCREAMING_SNAKE_CASEtsconfig、lint設定、代表的なファイルから確認したaliasとimport順序に従う。src/からの絶対pathは設定済みのaliasが対応している場合にのみ使用する~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.