ESLint v9.25.1 发布

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

亮点

🌐 Highlights

在 ESLint v9.25.0 中,作为在 no-unused-expressions 规则中添加对 TypeScript 语法支持的一部分,我们对该规则检测指令(例如 "use strict")的方式进行了更改。此更改揭示了该规则存在的假阴性:在使用 ecmaVersion: 3 进行检查时,本应由该规则报告的在 ES5+ 中属于指令的语句,因为 ES3 环境不支持指令,因此它们实际上未被使用。

🌐 In ESLint v9.25.0, as part of adding support for TypeScript syntax in the no-unused-expressions rule, we introduced a change in how this rule detects directives (for example, "use strict"). This change revealed false negatives this rule had: when linting with ecmaVersion: 3, statements that are directives in ES5+ should be reported by this rule, because ES3 environments do not support directives, so they are effectively unused.

虽然 v9.25.0 版本中该规则的行为是正确的,但事实证明此更改会影响那些以 ES3 和 ES5+ 环境指令发布相同代码的项目(问题 #19637)。为了支持此使用场景,v9.25.1 中 no-unused-expressions 规则检测指令的方式已被恢复。该更改将在 v9.26.0 中重新引入,并且 no-unused-expressions 规则的默认行为将与 v9.25.0 相同,但该规则将有一个选项,即使在 ecmaVersion: 3 的情况下也可以忽略指令。

🌐 While the v9.25.0 behavior of this rule is correct, it turned out that this change impacts projects that publish the same code with directives for both ES3 and ES5+ environments (issue #19637). In order to support this use case, the way the no-unused-expressions rule detects directives has been reverted in v9.25.1. The change will be reintroduced in v9.26.0, and the default behavior of the no-unused-expressions rule will be the same as in v9.25.0, but the rule will have an option to ignore directives even with ecmaVersion: 3.

错误修复

🌐 Bug Fixes

杂项

🌐 Chores

  • 1f2b057 杂务:升级 @eslint/js@9.25.1 (#19642) (Milos Djermanovic)
  • 771317f 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)

最新的 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 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。