一键导入
react-native-volontariapp-libs
Mandatory use of shared libraries (@volontariapp/shared, @volontariapp/contracts) for types and enums instead of hardcoding values.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Mandatory use of shared libraries (@volontariapp/shared, @volontariapp/contracts) for types and enums instead of hardcoding values.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | React Native Volontariapp Libs |
| description | Mandatory use of shared libraries (@volontariapp/shared, @volontariapp/contracts) for types and enums instead of hardcoding values. |
When developing features, creating interfaces, or handling data types, you must prioritize using the internal NPM libraries rather than redefining types, enums, or hardcoding string values.
This project uses shared monorepo packages installed via npm:
@volontariapp/contracts : Contains all API requests/responses types, entity definitions (Event, UserWeb), and related enums (EventType, EventState, etc.).@volontariapp/shared : Contains shared utilities, authorization roles (UserRoles), and common business logic.If you are evaluating a role, an event state, or a thematic type, ALWAYS import the corresponding enum from the shared libraries.
// ❌ BAD
if (user.role === 'ADMIN') { ... }
if (event.state === 'PUBLISHED') { ... }
// ✅ GOOD
import { UserRoles } from '@volontariapp/shared';
import { EventState } from '@volontariapp/contracts';
if (user.role === (UserRoles.ADMIN as string)) { ... }
if (event.state === EventState.EVENT_STATE_PUBLISHED) { ... }
If an API endpoint returns an entity (e.g. user, event) or expects a specific request payload, use the exact type provided by the contracts. Never create local interfaces like interface MyUser if UserWeb already exists.
// ✅ GOOD
import type { UserWeb, Event, CreateEventRequest } from '@volontariapp/contracts';
const handleCreateEvent = (payload: CreateEventRequest) => { ... }
When using zod alongside react-hook-form, integrate it directly with the shared enums to guarantee your forms match the expected backend contracts natively.
import { z } from 'zod';
import { UserRoles } from '@volontariapp/shared';
import { EventType } from '@volontariapp/contracts';
const schema = z.object({
// Disable eslint deprecation warning if z.nativeEnum is flagged
// eslint-disable-next-line @typescript-eslint/no-deprecated
role: z.nativeEnum(UserRoles),
// eslint-disable-next-line @typescript-eslint/no-deprecated
type: z.nativeEnum(EventType),
});
[!WARNING] Failing to use the shared libraries leads to "The two values in this comparison do not have a shared enum type" errors during TS validation and breaks the single source of truth principle. Always check
@volontariapp/contractsand@volontariapp/sharedbefore creating a new type.
Mandatory rules and components for handling keyboard avoidance smoothly in the React Native app.
How to correctly handle and format protobuf Timestamp dates sent by the API Gateway to prevent "Invalid Date" issues.
Senior-level React Native architecture and patterns for Expo 54 apps.
Strict coding standards, naming conventions, file size limits, and typing rules.
Guidelines for managing server state, queries, and API clients in React Native.
Best practices for implementing forms with React Hook Form and Zod.