Loading...
Loading...
Compare original and translation side by side
undefinedundefined
**Magic Values**
```bash
**魔法值**
```bash
**Empty Catch Blocks**
```bash
ast-grep -p 'try { $$$ } catch ($E) { }' --lang jsast-grep -p 'console.log($$$)' --lang js
ast-grep -p 'console.debug($$$)' --lang js
ast-grep -p 'console.warn($$$)' --lang jsast-grep -p 'var $VAR = $$$' --lang js
**空Catch块**
```bash
ast-grep -p 'try { $$$ } catch ($E) { }' --lang jsast-grep -p 'console.log($$$)' --lang js
ast-grep -p 'console.debug($$$)' --lang js
ast-grep -p 'console.warn($$$)' --lang jsast-grep -p 'var $VAR = $$$' --lang jsundefinedundefined
```bash
```bash
**Missing Keys in v-for**
```bash
**v-for 缺失Key**
```bash
**Options API in Composition API Codebase**
```bash
**组合式API代码库中使用选项式API**
```bash
**Reactive State Issues**
```bash
**响应式状态问题**
```bashundefinedundefinedanyast-grep -p ': any' --lang ts
ast-grep -p 'as any' --lang ts
ast-grep -p '<any>' --lang tsast-grep -p '$VAR!' --lang ts
ast-grep -p '$VAR!.$PROP' --lang tsast-grep -p '$VAR as $TYPE' --lang tsundefinedanyast-grep -p ': any' --lang ts
ast-grep -p 'as any' --lang ts
ast-grep -p '<any>' --lang tsast-grep -p '$VAR!' --lang ts
ast-grep -p '$VAR!.$PROP' --lang tsast-grep -p '$VAR as $TYPE' --lang tsundefinedundefinedundefinedundefinedundefined
**Nested Callbacks (Pyramid of Doom)**
```bash
ast-grep -p '$F1($$$, function($$$) { $F2($$$, function($$$) { $F3($$$, function($$$) { $$$ }) }) })' --lang jsundefined
**嵌套回调(厄运金字塔)**
```bash
ast-grep -p '$F1($$$, function($$$) { $F2($$$, function($$$) { $F3($$$, function($$$) { $$$ }) }) })' --lang jsundefinedundefinedundefinedundefinedundefined
**Deep Nesting**
```bash
**深层嵌套**
```bash
**Large Parameter Lists**
```bash
ast-grep -p 'function $NAME($A, $B, $C, $D, $E, $$$)' --lang jsundefined
**过长参数列表**
```bash
ast-grep -p 'function $NAME($A, $B, $C, $D, $E, $$$)' --lang jsundefinedundefinedundefinedundefinedundefined
**Missing Dependencies in useEffect**
```bash
ast-grep -p 'useEffect(() => { $$$ }, [])' --lang jsx
**useEffect 缺失依赖项**
```bash
ast-grep -p 'useEffect(() => { $$$ }, [])' --lang jsx
**Inline Functions in JSX**
```bash
ast-grep -p '<$COMPONENT onClick={() => $$$} />' --lang jsx
ast-grep -p '<$COMPONENT onChange={() => $$$} />' --lang jsx
**JSX中的内联函数**
```bash
ast-grep -p '<$COMPONENT onClick={() => $$$} />' --lang jsx
ast-grep -p '<$COMPONENT onChange={() => $$$} />' --lang jsxast-grep -p 'addEventListener($EVENT, $HANDLER)' --lang jsast-grep -p 'addEventListener($EVENT, $HANDLER)' --lang js
**setInterval Without Cleanup**
```bash
ast-grep -p 'setInterval($$$)' --lang js
**未清理的setInterval**
```bash
ast-grep -p 'setInterval($$$)' --lang js
**Large Arrays in Computed/Memos**
```bash
ast-grep -p 'computed(() => $ARRAY.filter($$$))' --lang js
ast-grep -p 'useMemo(() => $ARRAY.filter($$$), [$$$])' --lang jsx
**计算属性/Memo中的大型数组**
```bash
ast-grep -p 'computed(() => $ARRAY.filter($$$))' --lang js
ast-grep -p 'useMemo(() => $ARRAY.filter($$$), [$$$])' --lang jsxast-grep -p 'eval($$$)' --lang js
ast-grep -p 'new Function($$$)' --lang jsast-grep -p '$ELEM.innerHTML = $$$' --lang js
ast-grep -p 'dangerouslySetInnerHTML={{ __html: $$$ }}' --lang jsxast-grep -p "apiKey: '$$$'" --lang js
ast-grep -p "password = '$$$'" --lang js
ast-grep -p "secret: '$$$'" --lang jsast-grep -p '"SELECT * FROM " + $VAR' --lang js
ast-grep -p '`SELECT * FROM ${$VAR}`' --lang jsast-grep -p 'eval($$$)' --lang js
ast-grep -p 'new Function($$$)' --lang jsast-grep -p '$ELEM.innerHTML = $$$' --lang js
ast-grep -p 'dangerouslySetInnerHTML={{ __html: $$$ }}' --lang jsxast-grep -p "apiKey: '$$$'" --lang js
ast-grep -p "password = '$$$'" --lang js
ast-grep -p "secret: '$$$'" --lang jsast-grep -p '"SELECT * FROM " + $VAR' --lang js
ast-grep -p '`SELECT * FROM ${$VAR}`' --lang jsast-grep -p 'except: $$$' --lang pyast-grep -p 'def $FUNC($ARG=[])' --lang py
ast-grep -p 'def $FUNC($ARG={})' --lang pyast-grep -p 'global $VAR' --lang pyundefinedast-grep -p 'except: $$$' --lang pyast-grep -p 'def $FUNC($ARG=[])' --lang py
ast-grep -p 'def $FUNC($ARG={})' --lang pyast-grep -p 'global $VAR' --lang pyundefinedundefinedundefined1. **Language Detection Agent** (Explore)
- Detect project languages and frameworks
- Identify relevant file patterns
2. **JavaScript/TypeScript Agent** (code-analysis or Explore)
- JS anti-patterns
- TypeScript quality issues
- Async/Promise patterns
3. **Framework-Specific Agent** (code-analysis or Explore)
- Vue 3 anti-patterns (if Vue detected)
- React anti-patterns (if React detected)
- Pinia/Redux patterns (if detected)
4. **Security Agent** (security-audit)
- Security concerns
- Hardcoded values
- Injection risks
5. **Complexity Agent** (code-analysis or Explore)
- Code complexity metrics
- Long functions
- Deep nesting
6. **Python Agent** (if Python detected)
- Python anti-patterns
- Type annotation issues1. **语言检测Agent** (Explore)
- Detect project languages and frameworks
- Identify relevant file patterns
2. **JavaScript/TypeScript Agent** (code-analysis or Explore)
- JS anti-patterns
- TypeScript quality issues
- Async/Promise patterns
3. **框架专属Agent** (code-analysis or Explore)
- Vue 3 anti-patterns (if Vue detected)
- React anti-patterns (if React detected)
- Pinia/Redux patterns (if detected)
4. **安全Agent** (security-audit)
- Security concerns
- Hardcoded values
- Injection risks
5. **复杂度Agent** (code-analysis or Explore)
- Code complexity metrics
- Long functions
- Deep nesting
6. **Python Agent** (if Python detected)
- Python anti-patterns
- Type annotation issuesid: no-empty-catch
language: JavaScript
severity: warning
message: Empty catch block suppresses errors silently
note: |
Empty catch blocks hide errors and make debugging difficult.
Either log the error, handle it specifically, or re-throw.
rule:
pattern: try { $$$ } catch ($E) { }
fix: |
try { $$$ } catch ($E) {
console.error('Error:', $E);
throw $E;
}
files:
- 'src/**/*.js'
- 'src/**/*.ts'
ignores:
- '**/*.test.js'
- '**/node_modules/**'id: no-empty-catch
language: JavaScript
severity: warning
message: Empty catch block suppresses errors silently
note: |
Empty catch blocks hide errors and make debugging difficult.
Either log the error, handle it specifically, or re-throw.
rule:
pattern: try { $$$ } catch ($E) { }
fix: |
try { $$$ } catch ($E) {
console.error('Error:', $E);
throw $E;
}
files:
- 'src/**/*.js'
- 'src/**/*.ts'
ignores:
- '**/*.test.js'
- '**/node_modules/**'id: no-props-mutation
language: JavaScript
severity: error
message: Never mutate props directly - use emit or local copy
rule:
all:
- pattern: props.$PROP = $VALUE
- inside:
kind: function_declaration
note: |
Props should be treated as immutable. To modify data:
1. Emit an event to parent: emit('update:propName', newValue)
2. Create a local ref: const local = ref(props.propName)id: no-props-mutation
language: JavaScript
severity: error
message: Never mutate props directly - use emit or local copy
rule:
all:
- pattern: props.$PROP = $VALUE
- inside:
kind: function_declaration
note: |
Props should be treated as immutable. To modify data:
1. Emit an event to parent: emit('update:propName', newValue)
2. Create a local ref: const local = ref(props.propName)/code:antipatterns/code:antipatterns| Severity | Description | Examples |
|---|---|---|
| Critical | Security vulnerabilities, data loss risk | eval(), SQL injection, hardcoded secrets |
| High | Bugs, incorrect behavior | Props mutation, unhandled promises, empty catch |
| Medium | Maintainability issues | Magic numbers, deep nesting, large functions |
| Low | Style/preference | var usage, console.log, inline functions |
| 严重程度 | 描述 | 示例 |
|---|---|---|
| 关键 | 安全漏洞、数据丢失风险 | eval()、SQL注入、硬编码密钥 |
| 高 | 缺陷、行为异常 | Props修改、未处理Promise、空Catch块 |
| 中 | 可维护性问题 | 魔法值、深层嵌套、长函数 |
| 低 | 风格/偏好问题 | var使用、console.log、内联函数 |