feat: add code quality rules for TypeScript and React components

- 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>
This commit is contained in:
Innei
2025-06-22 23:02:34 +08:00
parent 8c962dfd24
commit 123bd9bf9e

View File

@@ -0,0 +1,10 @@
---
description:
globs: *.ts,*.tsx
alwaysApply: false
---
你需要考虑代码质量,以下的规则请务必遵守:
1. 你要尽可能避免重复代码出现,遇到多次使用的 types 需要提取一个通用 Type遇到多次使用的组件代码需要封装一个通用组件。
2. 你要避免出现逻辑过大的组件,需要使用抽离 hook 或者拆分小组件的方式实现。
3. 在编写 React 组件时,需要熟练掌握 React 哲学。学会正确使用 Context、拆分组件使得状态下沉等方式解决 React 重渲染问题。