ESLint v9.31.0 发布

我们刚刚发布了 ESLint v9.31.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。

亮点

🌐 Highlights

核心规则中对显式资源管理的支持

🌐 Explicit resource management support in core rules

为了更好地支持 ES2026 JavaScript 中的新特性 显式资源管理,四条核心规则已被更新,包括对 usingawait 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 规则不再报告初始化 usingawait 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 规则现在会报告修改 usingawait 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 规则不再报告对 usingawait 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 规则不再报告初始化为 undefinedusingawait 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

错误修复

🌐 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

  • 3ddd454 任务: 升级到 @eslint/js@9.31.0 (#19935) (Francesco Trotta)
  • d5054e5 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • 0f4a378 杂务:更新 eslint (#19933) (renovate[bot])
  • 76c2340 任务:将 mocha 升级到 v11 (#19917) (루밀LuMir)

最新的 ESLint 新闻、案例研究、教程和资源。

ESLint v10.3.0 发布
1 min read

ESLint v10.3.0 发布

我们刚刚发布了 ESLint v10.3.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。

ESLint v10.2.1 发布
1 min read

ESLint v10.2.1 发布

我们刚刚发布了 ESLint v10.2.1,这是 ESLint 的一个补丁版本升级。本次发布修复了上一版本中发现的几个错误。

ESLint v10.2.0 发布
2 min read

ESLint v10.2.0 发布

我们刚刚发布了 ESLint v10.2.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。