
亮点
🌐 Highlights
新规则 preserve-caught-error
🌐 New Rule preserve-caught-error
核心中已添加了一条新规则:preserve-caught-error。
🌐 One new rule has been added to the core: preserve-caught-error.
此规则在 catch 块内抛出新错误时强制使用 cause 属性。
🌐 This rule enforces the use of the cause property when throwing a new error inside a catch block.
这个规则的错误代码示例:
🌐 An example of incorrect code for this rule:
/* eslint preserve-caught-error: "error" */
try {
// ...
} catch (error) {
throw new Error("Something went wrong");
}
这个规则的正确代码示例:
🌐 An example of correct code for this rule:
/* eslint preserve-caught-error: "error" */
try {
// ...
} catch (error) {
throw new Error("Something went wrong", { cause: error });
}
其他显著变化
🌐 Other notable changes
no-empty-function和no-empty-static-block规则现在提供建议,当函数或类的静态块故意为空时,添加/* empty */注释。- 现在
no-empty规则允许在主体内包含注释的空switch语句。
特性
🌐 Features
42761fa功能:实现 no-empty-function 的建议 (#20057) (jaymarvelz)102f444功能:实现对 no-empty-static-block 的建议 (#20056) (jaymarvelz)e51ffff功能:添加preserve-caught-error规则 (#19913) (Amnish Singh Arora)
错误修复
🌐 Bug Fixes
10e7ae2修复:更新不可克隆选项的错误信息 (#20059) (soda-sorcery)bfa4601修复:在 no-empty 规则中忽略带有注释的空 switch 语句 (#20045) (jaymarvelz)dfd11de修复:向测试用例类型添加before和after(#20049) (Francesco Trotta)dabbe95修复:纠正no-restricted-imports规则的类型 (#20034) (Milos Djermanovic)ea789c7修复:no-loss-of-precision 对大写指数的误报 (#20032) (sethamus)
文档
🌐 Documentation
[d265515](https://github.com/eslint/eslint/commit/d265515642f65246bcd45c17979f67c2afb12f95)文档:改进措辞 - 将获取入门部分的“if”改为“even if”(#20074)(jjangga0214)a355a0e文档:在no-var文档页面 (#20064) 中反转比较逻辑 (OTonGitHub)5082fc2文档:更新自述文件(GitHub Actions 机器人)99cfd7e文档:在规则弃用文档中添加缺失的“the”(#20050)(Josh Goldberg ✨)6ad8973文档:更新--no-ignore和--ignore-pattern文档 (#20036) (Francesco Trotta)8033b19文档:为--no-config-lookup添加文档 (#20033) (Francesco Trotta)
杂项
🌐 Chores
da87f2f杂务:升级 @eslint/js@9.35.0 (#20077) (Milos Djermanovic)af2a087事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)7055764测试:移除tests/lib/eslint/eslint.config.js(#20065) (Milos Djermanovic)84ffb96杂项:更新@eslint-community/eslint-utils(#20069) (Francesco Trotta)d5ef939重构:移除规则中已弃用的context.parserOptions使用 (#20060) (sethamus)1b3881d任务:删除多余的词 (#20058) (pxwanglu)
