ESLint v7.4.0 发布

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

亮点

🌐 Highlights

在 v7.3.0 发布后不久,我们收到 一个问题,指出 eslint-config-airbnb 出现了故障,因为它在规则配置中使用了 InfinityInfinity 本应被 规则的选项模式 禁止,但 ESLint 使用的 JSON 模式验证器 Ajv 中的 一个 bug 错误地允许了在指定 integer 时使用 Infinity。这个问题最终被发现,是因为 v7.3.0 发布中包含了 一个更改,通过序列化规则配置修复了 一个不相关的问题。ESLint 期望规则配置可以被 JSON 序列化,以确保所有支持的 JSON、YAML 和 JS .eslintrc 格式的一致性,并且它在 --cache--print-config 命令行选项中依赖这个属性。

🌐 Shortly after the v7.3.0 release, we received an issue that eslint-config-airbnb was breaking because it used Infinity in a rule config. Infinity should have been forbidden by the rule’s option schema, but a bug in Ajv, the JSON schema validator that ESLint uses, incorrectly allowed Infinity when an integer was specified. This was finally caught because the v7.3.0 release included a change that fixed an unrelated issue by serializing rule configs. ESLint expects rule configs to be JSON-serializable for consistency between all supported JSON, YAML, and JS .eslintrc formats, and it relies on this property in the --cache and --print-config command line options.

eslint-config-airbnb 更新为使用 Number.MAX_SAFE_INTEGER 而不是 Infinity理想解决方案,但会花费太多时间。由于这是唯一报告的问题,并且仅限于 eslint-config-airbnb 而非终端用户配置,我们实现了一个例外,将 Infinity 替换为 Number.MAX_SAFE_INTEGER 并在 v7.3.1 版本中发布,这使我们能够保留无关的错误修复。

🌐 Updating eslint-config-airbnb to use Number.MAX_SAFE_INTEGER instead of Infinity is the ideal solution but would have taken too long. Since this was the only reported issue and isolated to eslint-config-airbnb rather than end-user configs, we implemented an exception that replaced Infinity with Number.MAX_SAFE_INTEGER and released it in v7.3.1, which allowed us to preserve the unrelated bug fix.

在 v7.3.1 版本发布后,我们收到了另一个问题,即一个 eslint-plugin-unicorn 规则 指导用户使用正则表达式实例,而这些实例无法进行 JSON 序列化。与 eslint-config-airbnb 不同,在 eslint-config-airbnb 中不可序列化的值仅限于单个依赖,eslint-plugin-unicorn 的终端用户配置中包含正则表达式,因此修复所有配置是不切实际的。

🌐 After the v7.3.1 release, we received another issue that an eslint-plugin-unicorn rule was directing users to use regular expression instances, which are not JSON-serializable. Unlike eslint-config-airbnb, where the non-serializable value was isolated to a single dependency, end user configs for eslint-plugin-unicorn include regular expressions, so fixing all of them is not practical.

因此,我们将回退原始更改用于 v7.4.0 版本,并将寻找其他解决方案。这将为规则配置包含非 JSON 可序列化值的用户解除常规 linting 的阻塞,尽管在这些情况下,--cache--print-config 命令行选项可能会表现出未定义行为。ESLint 的未来主要版本将强制规则配置只包含 JSON 可序列化的值,我们预计对 RuleTester 的增强将有助于规则作者为此准备他们的模式。

🌐 We’re therefore reverting the original change for the v7.4.0 release and will be finding another solution. This will unblock regular linting for users whose rule configs include non-JSON-serializable values, though the --cache and --print-config command line options may exhibit undefined behavior in those cases. A future major version of ESLint will enforce that rule configs contain only JSON-serializable values, and we anticipate that enhancements to RuleTester will help rule authors prepare their schemas for that.

增强功能

🌐 Enhancements

错误修复

🌐 Bug Fixes

文档

🌐 Documentation

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