Files
antd-admin/apps/with-lingui/.github/instructions/refactor.instructions.md
T
zuiidea c5221c71be feat(with-lingui): orders CRUD, shared hooks, auth refresh, and docs
- Add second sample resource (orders): API, schemas, MSW, routes, menu, Lingui, and E2E.

- Introduce useCrudToasts, useUrlSearchState, useTableFitHeight; extend useResourceCRUD with optimistic updates; add Vitest coverage for hooks and createHandler.

- Implement token refresh in http layer, RouteError, and new E2E specs (auth-refresh, rbac, url-state).

- Replace gen-resource codegen with English add-resource.instructions.md; fix Copilot instruction YAML in with-lingui and basic.

- Add with-lingui CI workflow, Cursor thin rules, optimization plan doc, and refresh README/AGENTS.

- Bump packages/create and lockfile where applicable.

Made-with: Cursor
2026-04-27 14:47:55 +08:00

1.5 KiB

applyTo, description
applyTo description
src/**/*.{ts,tsx} Use when refactoring existing code for deduplication, modularization, naming cleanup, or maintainability improvements without behavior changes. Keywords: refactor, cleanup, simplify, deduplicate, maintainability.

Refactor Instructions

Purpose

Reduce duplication while preserving behavior and public contracts.

Do

  • Keep refactors incremental and scoped to one concern per change.
  • Prefer extracting shared utilities/hooks/components over large rewrites.
  • Preserve existing external behavior and route/store contracts.
  • Keep diffs reviewable with minimal unrelated formatting churn.
  • Add or update lightweight comments only when logic is non-obvious.

Do Not

  • Do not change runtime behavior unless explicitly requested.
  • Do not rename broadly across the codebase without clear benefit.
  • Do not delete tests that still cover unique critical scenarios.
  • Do not introduce large dependencies for minor convenience; prefer composition or small utilities.

Considerations

  • Bundle: Main app chunk is ~135KB (gzip ~41KB). Ant Design (vendor-antd) and TanStack (vendor-tanstack) are in separate chunks for parallel loading. Avoid adding large UI libraries when Ant Design covers the need.
  • Type safety: Keep validations at API boundaries (Zod schemas) rather than adding more runtime checks throughout the app.

Validation

  • Confirm no new diagnostics in touched files.
  • Run: pnpm exec vp check --no-fmt
  • For significant changes, verify bundle size impact: pnpm run build 2>&1 | grep "kB"