Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/content/reference/eslint-plugin-react-hooks/lints/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@ title: config

<Intro>

Validates the compiler [configuration options](/reference/react-compiler/configuration).
验证编译器 [配置选项](/reference/react-compiler/configuration)

</Intro>

## Rule Details {/*rule-details*/}
## 规则详情 {/*rule-details*/}

React Compiler accepts various [configuration options](/reference/react-compiler/configuration) to control its behavior. This rule validates that your configuration uses correct option names and value types, preventing silent failures from typos or incorrect settings.
React 编译器接受各种 [配置选项](/reference/react-compiler/configuration) 来控制其行为。此规则验证你的配置使用了正确的选项名称和值类型,防止因拼写错误或错误设置而导致的静默失败。

### Invalid {/*invalid*/}
### 无效的 {/*invalid*/}

Examples of incorrect code for this rule:
此规则的错误代码示例:

```js
// ❌ Unknown option name
// ❌ 未知的选项名称
module.exports = {
plugins: [
['babel-plugin-react-compiler', {
compileMode: 'all' // Typo: should be compilationMode
compileMode: 'all' // 拼写错误:应该是 compilationMode
}]
]
};

// ❌ Invalid option value
// ❌ 无效的选项值
module.exports = {
plugins: [
['babel-plugin-react-compiler', {
compilationMode: 'everything' // Invalid: use 'all' or 'infer'
compilationMode: 'everything' // 无效:使用 'all' 'infer'
}]
]
};
```

### Valid {/*valid*/}
### 有效的 {/*valid*/}

Examples of correct code for this rule:
此规则的正确代码示例:

```js
// ✅ Valid compiler configuration
// ✅ 有效的编译器配置
module.exports = {
plugins: [
['babel-plugin-react-compiler', {
Expand All @@ -52,38 +52,38 @@ module.exports = {
};
```

## Troubleshooting {/*troubleshooting*/}
## 故障排除 {/*troubleshooting*/}

### Configuration not working as expected {/*config-not-working*/}
### 配置未按预期工作 {/*config-not-working*/}

Your compiler configuration might have typos or incorrect values:
你的编译器配置可能有拼写错误或错误的值:

```js
// ❌ Wrong: Common configuration mistakes
// ❌ 错误:常见的配置错误
module.exports = {
plugins: [
['babel-plugin-react-compiler', {
// Typo in option name
// 选项名称拼写错误
compilationMod: 'all',
// Wrong value type
// 错误的值类型
panicThreshold: true,
// Unknown option
// 未知选项
optimizationLevel: 'max'
}]
]
};
```

Check the [configuration documentation](/reference/react-compiler/configuration) for valid options:
查看 [配置文档](/reference/react-compiler/configuration) 了解有效选项:

```js
// ✅ Better: Valid configuration
// ✅ 更好:有效的配置
module.exports = {
plugins: [
['babel-plugin-react-compiler', {
compilationMode: 'all', // or 'infer'
panicThreshold: 'none', // or 'critical_errors', 'all_errors'
// Only use documented options
compilationMode: 'all', // 'infer'
panicThreshold: 'none', // 'critical_errors''all_errors'
// 只使用文档中记录的选项
}]
]
};
Expand Down