
亮点
🌐 Highlights
核心规则中对显式资源管理的支持
🌐 Explicit resource management support in core rules
为了更好地支持 ES2026 JavaScript 中的新特性 显式资源管理,四条核心规则已被更新,包括对 using 和 await using 语法的支持。
🌐 Four core rules have been updated to better support explicit resource management, a new feature in ES2026 JavaScript, including support for using and await using syntax.
当选项为 "never" 时,init-declarations 规则不再报告初始化 using 和 await using 变量,因为这些变量必须初始化。例如:
🌐 The init-declarations rule no longer reports on initializing using and await using variables when the option is "never", because these variables must be initialized. For example:
async function foobar() {
await using quux = getSomething();
}
no-const-assign 规则现在会报告修改 using 和 await using 变量。例如:
🌐 The no-const-assign rule now reports on modifying using and await using variables. For example:
if (foo) {
using a = getSomething();
a = somethingElse;
}
no-loop-func 规则不再报告对 using 和 await using 变量的引用,因为这些变量是常量。例如:
🌐 The no-loop-func rule no longer reports on references to using and await using variables, because these variables are constant. For example:
for (using i of foo) {
var a = function() { return i; }; // OK, all references are referring to block scoped variables in the loop.
a();
}
no-undef-init 规则不再报告初始化为 undefined 的 using 和 await using 变量。例如:
🌐 The no-undef-init rule no longer reports on using and await using variables initialized to undefined. For example:
using foo = undefined;
改进了 RuleTester 对错误位置的输出
🌐 Improved RuleTester output for incorrect locations
[RuleTester](/docs/latest/integrate/nodejs-api#ruletester) 类的 run 方法已得到增强,以指示测试用例中报告的错误位置的多个属性不匹配。例如:
🌐 The run method of the RuleTester class has been enhanced to indicate when multiple properties of a reported error location in a test case do not match. For example:
AssertionError [ERR_ASSERTION]: Actual error location does not match expected error location.
+ actual - expected
{
+ column: 31,
+ endColumn: 32
- column: 32,
- endColumn: 33
}
以前,即使有多个不匹配,输出也只会显示一个属性:
🌐 Previously, the output would only show one property even if there were multiple mismatches:
AssertionError [ERR_ASSERTION]: Error column should be 32
31 !== 32
+ expected - actual
-31
+32
特性
🌐 Features
35cf44c功能:如果不同,则在规则测试器中输出完整的实际位置 (#19904) (ST-DDT)a6a6325功能:在no-loop-func中支持显式资源管理 (#19895) (Milos Djermanovic)4682cdc功能:在no-undef-init中支持显式资源管理 (#19894) (Milos Djermanovic)5848216功能:在init-declarations中支持显式资源管理 (#19893) (Milos Djermanovic)bb370b8功能:在no-const-assign中支持显式资源管理 (#19892) (Milos Djermanovic)
错误修复
🌐 Bug Fixes
07fac6c修复:在写入自动修复结果时遇到 EMFILE 时重试 (#19926) (TKDev7)28cc7ab修复:移除不正确的 RuleContext 类型 (#19910) (Nicholas C. Zakas)
文档
🌐 Documentation
664cb44文档:更新自述文件(GitHub Actions 机器人)40dbe2a文档:修复globalIgnores()代码与文本不匹配的问题 (#19914) (MaoShizhong)5a0069d文档:更新自述文件(GitHub Actions 机器人)fef04b5文档:更新问题处理信息 (#19902) (Nicholas C. Zakas)
杂项
🌐 Chores
