前端代码审查
- 作者仓库星标 149,183
- 作者仓库 langflow
- 领域
- 人工智能
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @langflow-ai · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 即装即用
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- Node.js
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Frontend Code Review
## When to use this skill
Use this skill whenever the user asks to **review, analyze, or improve** frontend code (`.tsx`, `.ts`, `.js` files) under the `src/frontend/` directory. Supports the following review modes:
1. **Pending-change review** -- inspect staged or working-tree files slated for commit and flag checklist violations before submission.
2. **File-targeted review** -- review the specific file(s) the user names and report the relevant checklist findings.
Do NOT use this skill when:
- The request is about backend code (`.py` files under `src/backend/`).
- The user is not asking for a review/analysis/improvement of frontend code.
- The scope is outside `src/frontend/` (unless the user explicitly asks to review frontend-related changes elsewhere).
## How to use this skill
Follow these steps when using this skill:
1. **Identify the review mode** (pending-change vs file-targeted) based on the user's input. Keep the scope tight: review only what the user provided or explicitly referenced.
2. Follow the rules defined in the **Checklist** to perform the review. If no checklist rule matches, apply **General Review Rules** as a fallback.
3. Compose the final output strictly following the **Required Output Format**.
Notes when using this skill:
- Always include actionable fixes or suggestions (including possible code snippets).
- Use `File:Line` references when a file path and line numbers are available; otherwise, use the most specific identifier you can.
- The Langflow frontend uses React 19, TypeScript 5.4, Vite 7 with SWC, Zustand for state management, TanStack React Query for server state, @xyflow/react v12 for graph visualization, Radix UI + shadcn-ui components, Tailwind CSS v3, and Biome for linting/formatting.
## Checklist
- **Code quality**: For any reviewed file, follow [references/code-quality.md](references/code-quality.md) to check styling conventions, TypeScript usage, Biome compliance, and component patterns.
- **Performance**: If the review scope involves React components, hooks, Zustand stores, React Query usage, or @xyflow/react node rendering, follow [references/performance.md](references/performance.md) to check for re-render issues, memoization, and data flow patterns.
- **Business logic**: If the review scope involves custom nodes (GenericNode), flow state, API calls, the component system, global variables, or the inspection panel, follow [references/business-logic.md](references/business-logic.md) to check for Langflow-specific correctness.
## General Review Rules
### 1. Security Review
Check for:
- XSS vulnerabilities (dangerouslySetInnerHTML, unescaped user input)
- Sensitive data exposure in client-side code
- Insecure direct object references in API calls
- Hardcoded secrets, tokens, or API keys
### 2. Accessibility Review
Check for:
- Missing aria labels on interactive elements
- Keyboard navigation support
- Proper use of semantic HTML elements
- Color contrast issues in custom styling
### 3. Code Quality Review
Check for:
- Code duplication (DRY violations — extract at 3+ identical usages)
- Functions/components doing too much (SRP violations — if you need "and" to describe it, split it)
- Deep nesting or complex conditionals (prefer early returns and guard clauses)
- Magic numbers/strings without named constants
- Poor naming: generic names (`data`, `result`, `temp`), missing verb prefixes on functions, missing `is`/`has`/`can`/`should` prefixes on booleans
- Missing error handling or error boundaries
- Incomplete TypeScript type coverage (no `any`, no `as any` casts)
- Comments that explain WHAT instead of WHY
- Commented-out code (use version control)
- Boolean parameters that switch component behavior (use two components instead)
- Mutable patterns where `const` or immutable alternatives exist
- Production files exceeding ~500 lines (red flag at 600+)
- `console.log` in production code (Biome flags this)
### 4. Testing Impact Review
Check for:
- Changes to data-testid attributes that may break E2E tests
- Modified component interfaces that require test updates
- New interactive elements missing data-testid attributes
### 5. Pre-Commit Verification
For pending-change reviews, verify:
- `npm run format` (Biome formatter) — zero diffs
- `npm run lint` (Biome linter) — zero errors
- `npm test` (Jest) — zero failures
## Required Output Format
When this skill is invoked, the response must exactly follow one of the two templates:
### Template A (any findings)
```markdown
# Code Review
Found <N> urgent issues that need to be fixed:
## 1. <brief description of issue>
FilePath: <path> line <line>
<relevant code snippet or pointer>
### Suggested fix
<brief description of suggested fix with code example>
---
... (repeat for each urgent issue) ...
Found <M> suggestions for improvement:
## 1. <brief description of suggestion>
FilePath: <path> line <line>
<relevant code snippet or pointer>
### Suggested fix
<brief description of suggested fix with code example>
---
... (repeat for each suggestion) ...
```
- If there are no urgent issues, omit that section. If there are no suggestions, omit that section.
- If the issue count exceeds 10, summarize as "10+ urgent issues" or "10+ suggestions" and output only the first 10 items.
- Do not compress the blank lines between sections; keep them as-is for readability.
- If Template A is used (there are issues to fix) and at least one issue requires code changes, append a brief follow-up question after the structured output asking whether the user wants the suggested fixes applied. For example: "Would you like me to apply the suggested fixes to address these issues?"
### Template B (no issues)
```markdown
## Code Review
No issues found.
```
章节与文件索引
按说明文件中的顺序排列。
何时使用该技能
如何使用这个技能
清单
1. 安全审查
2. 无障碍审查
文件/命令 -> .tsx · .ts · .js · src/frontend/ · .py · src/backend/ · File:Line · data
内容校验值 -> 0634b3de51d9
当前原文的自动摘译,尚未人工审校。
何时使用该技能
每当用户要求查看、分析或改进
src/frontend/目录下的前端代码(.tsx、.ts、.js文件)时,请使用此技能。支持以下审核模式: 待更改审核 - 在提交之前检查预定提交的暂存文件或工作树文件并标记检查表违规情况。文件目标审查——审查用户名的特定文件并报告相关检查表结果。如何使用这个技能
使用此技能时请遵循以下步骤: 根据用户的输入确定审阅模式(待更改与文件目标)。保持范围严格:仅审查用户提供或明确引用的内容。请遵循检查表中定义的规则来执行审核。如果没有匹配的清单规则,则应用一般审核规则作为后备。严格按照所需的输出格式撰写最终输出。
清单
代码质量:对于任何经过审查的文件,请按照references/code-quality.md 来检查样式约定、TypeScript 使用情况、Biome 合规性和组件模式。性能:如果审查范围涉及 React 组件、钩子、Zustand 存储、React Query 使用或 @xyflow/react 节点渲染,请按照references/performance.md 检查重新渲染问题、记忆和数据流模式。业务逻辑:如果审核范围涉及自定义节点(GenericNode)、流状态、API 调用、组件系统、全局变量或检查面板,请按照references/business-logic.md 检查特定于Langflow 的正确性。
1. 安全审查
检查: XSS 漏洞(dangerouslySetInnerHTML、未转义的用户输入) 客户端代码中的敏感数据暴露 API 调用中不安全的直接对象引用 硬编码的机密、令牌或 API 密钥
2. 无障碍审查
检查: 交互元素上缺少 aria 标签 键盘导航支持 正确使用语义 HTML 元素 自定义样式中的颜色对比度问题