Skip to content

自动修复

🌐 Automatic fixes

Oxlint 可以自动修复一些 lint 违规。只有在使用相关 CLI 标志时,才会应用自动修复。你可以选择何时应用它们。

🌐 Oxlint can automatically fix some lint violations. Automatic fixes are only applied when passing the relevant CLI flags. You choose when to apply them.

在代码编辑器集成(如 VS Code)中,自动修复作为“代码操作”提供,你可以在编辑器中应用它们。

🌐 In the code editor integrations (such as VS Code), automatic fixes are exposed as "code actions" that you can apply in-editor.

安全修复

🌐 Safe fixes

安全修复是不会改变程序行为的更改。

🌐 Safe fixes are changes that do not alter program behavior.

应用安全修复:

🌐 Apply safe fixes:

bash
oxlint --fix

建议

🌐 Suggestions

建议是可能会改变行为或可能不符合你意图的修改。

🌐 Suggestions are changes that may alter behavior or may not match your intent.

应用建议:

🌐 Apply suggestions:

bash
oxlint --fix-suggestions

危险的修复方法

🌐 Dangerous fixes

危险的修复是可能会破坏你代码的激进更改。

🌐 Dangerous fixes are aggressive changes that may break your code.

应用危险修复:

🌐 Apply dangerous fixes:

bash
oxlint --fix-dangerously

组合修复模式

🌐 Combining fix modes

你可以结合安全修复和建议:

🌐 You can combine safe fixes and suggestions:

bash
oxlint --fix --fix-suggestions

你也可以包括危险的修复:

🌐 You can also include dangerous fixes:

bash
oxlint --fix --fix-suggestions --fix-dangerously

规则支持

🌐 Rule support

并非所有规则都提供修复。一些规则支持安全修复,一些提供建议,还有一些尚未提供修复。

🌐 Not all rules provide fixes. Some rules support safe fixes, some provide suggestions, and some do not provide fixes yet.

如果一个规则缺少修复程序,欢迎贡献。

🌐 If a rule is missing a fixer, contributions are welcome.

类型感知的代码检查和修复

🌐 Type-aware linting and fixes

类型感知的代码检查 需要先构建项目。

启用类型感知的代码检查后,你可以应用安全修复:

🌐 You can apply safe fixes with type-aware linting enabled:

bash
oxlint --type-aware --fix