mirror of
https://github.com/Afilmory/afilmory
synced 2026-02-01 22:48:17 +00:00
- Introduced a new markdown file with guidelines for maintaining code quality in TypeScript and React projects. - Emphasized the importance of avoiding code duplication, managing component complexity, and adhering to React best practices. Signed-off-by: Innei <tukon479@gmail.com>
11 lines
573 B
Plaintext
11 lines
573 B
Plaintext
---
|
||
description:
|
||
globs: *.ts,*.tsx
|
||
alwaysApply: false
|
||
---
|
||
你需要考虑代码质量,以下的规则请务必遵守:
|
||
|
||
1. 你要尽可能避免重复代码出现,遇到多次使用的 types 需要提取一个通用 Type;遇到多次使用的组件代码,需要封装一个通用组件。
|
||
2. 你要避免出现逻辑过大的组件,需要使用抽离 hook 或者拆分小组件的方式实现。
|
||
3. 在编写 React 组件时,需要熟练掌握 React 哲学。学会正确使用 Context、拆分组件使得状态下沉等方式解决 React 重渲染问题。
|