You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+63-8Lines changed: 63 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
This is the Ant Design (antd) repository - a React component library with enterprise-class UI design language, widely used for building professional web applications.
4
4
5
+
> For deeper, project-wide conventions (demo/test import rules, documentation format, changelog rules, PR templates, etc.), see [`CLAUDE.md`](../CLAUDE.md) at the repository root. This file is a concise, suggestion-time reference designed to keep AI tools from hallucinating non-existent components or APIs.
6
+
5
7
## Project Context
6
8
7
9
-**Framework**: TypeScript + React (compatible with React 16-19)
@@ -10,6 +12,54 @@ This is the Ant Design (antd) repository - a React component library with enterp
10
12
-**Design System**: Follows Ant Design specifications
11
13
-**Internationalization**: Full i18n support
12
14
15
+
## Authoritative Component List
16
+
17
+
The following are the **only** top-level exports of `antd`. Do **not** invent components outside this list (e.g. `antd` does not export `Container`, `Stack`, `Heading`, `Box`, `Sidebar`, `Navbar`, `IconButton`, etc.).
Function exports (lowercase): `message`, `notification`, `theme`, `version`, `unstableSetRender`.
22
+
23
+
When in doubt, verify against `components/index.ts` (the source of truth for public exports). Icons live in a **separate** package: `@ant-design/icons` — never import icons from `antd`.
Internally these are flagged via `warning.deprecated(...)` and `@deprecated` JSDoc tags; check the component's `interface.ts` / `index.tsx` if unsure.
62
+
13
63
## Code Standards & Best Practices
14
64
15
65
### TypeScript Requirements
@@ -62,8 +112,7 @@ This is the Ant Design (antd) repository - a React component library with enterp
62
112
- Use `@ant-design/cssinjs` for all styling
63
113
- Place component styles in `style/` directory
64
114
- Generate styles with functions named `gen[ComponentName]Style`
65
-
- Use design tokens from the Ant Design token system
66
-
- Never hardcode colors, sizes, or spacing values
115
+
- Use design tokens from the Ant Design token system (read tokens via the `theme.useToken()` hook, or `token` argument inside style functions) — never hardcode colors, sizes, or spacing values
67
116
- Support both light and dark themes
68
117
- Use CSS logical properties for RTL support (e.g., `margin-inline-start` instead of `margin-left`)
69
118
- Respect `prefers-reduced-motion` for animations
@@ -82,16 +131,22 @@ This is the Ant Design (antd) repository - a React component library with enterp
82
131
- Target 100% test coverage
83
132
- Place tests in `__tests__` directory as `index.test.tsx` or `componentName.test.tsx`
84
133
- Include snapshot tests for UI components
134
+
- Inside `components/**/__tests__/` use **relative** paths (`../`, `../../_util/...`) — never `antd`, `antd/es/*`, or path aliases. See [`CLAUDE.md`](../CLAUDE.md) for the full rule.
85
135
86
136
### Demo & Documentation
87
137
88
138
- Keep demo code concise and copy-pasteable
89
139
- Focus each demo on a single feature
90
-
- Provide both English and Chinese documentation
140
+
- Provide both English and Chinese documentation (`index.en-US.md` and `index.zh-CN.md`)
141
+
- Inside `components/**/demo/` use **absolute** imports (`antd`, `antd/es/*`, `antd/locale/*`) — never relative paths to component internals. The semantic demos (`_semantic*.tsx`) are an exception. See [`CLAUDE.md`](../CLAUDE.md) for the full rule.
- Prefer antd built-in components over external dependencies
94
145
146
+
### Type Checks (Utility)
147
+
148
+
Prefer the helpers in `components/_util/is.ts` (`isNumber`, `isString`, `isPlainObject`, `isFunction`, `isThenable`, `isPrimitive`, `isNonNullable`) over inline `typeof` / `instanceof` checks when the helper covers the case.
149
+
95
150
### API Documentation Format
96
151
97
152
When documenting component APIs, use this table structure:
@@ -101,21 +156,21 @@ When documenting component APIs, use this table structure:
101
156
- Number defaults as literal values: `0`, `100`
102
157
- No default value: `-`
103
158
- Descriptions start with capital letter, no ending period
104
-
- Sort API properties alphabetically
159
+
- Sort API properties alphabetically (ignoring common props like `className`, `style`; place event callbacks last)
105
160
106
161
### Internationalization
107
162
108
163
- Locale configuration files use pattern: `locale_COUNTRY.ts` (e.g., `zh_CN.ts`)
109
164
- Use `useLocale` hook from `components/locale/index.tsx`
110
-
- When modifying locale strings, update ALL language files
165
+
- When modifying locale strings, update ALL language files under `components/locale/`
111
166
- Locale content should be plain strings with `${}` placeholders for variables
112
167
113
168
### File Organization
114
169
115
-
- Components in `components/[component-name]/` directory
116
-
- Demos in `components/[component-name]/demo/` as `.tsx` files
0 commit comments