Files
afilmory/.cursor/rules/code-quality.mdc
Innei 123bd9bf9e 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>
2025-06-22 23:02:34 +08:00

11 lines
573 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description:
globs: *.ts,*.tsx
alwaysApply: false
---
你需要考虑代码质量,以下的规则请务必遵守:
1. 你要尽可能避免重复代码出现,遇到多次使用的 types 需要提取一个通用 Type遇到多次使用的组件代码需要封装一个通用组件。
2. 你要避免出现逻辑过大的组件,需要使用抽离 hook 或者拆分小组件的方式实现。
3. 在编写 React 组件时,需要熟练掌握 React 哲学。学会正确使用 Context、拆分组件使得状态下沉等方式解决 React 重渲染问题。