
亮点
🌐 Highlights
在 v7.3.0 发布后不久,我们收到 一个问题,指出 eslint-config-airbnb 出现了故障,因为它在规则配置中使用了 Infinity。Infinity 本应被 规则的选项模式 禁止,但 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
ff5317e更新:改进 array-callback-return 报告信息 (#13395) (Philip (flip) Kromer)51e42ec更新:为 camelcase 规则添加 “ignoreGlobals” 选项(修复 #11716)(#12782) (David Gasperoni)0655f66更新:在 arrow-body-style 中改进报告位置(参考 #12334)(#13424)(YeonJuan)d53d69a更新:prefer-regex-literal 检测正则表达式字面量(修复 #12840)(#12842) (Mathias Schreck)004adae更新:将 id-blacklist 重命名为 id-denylist(修复 #13407)(#13408)(Kai Cataldo)
错误修复
🌐 Bug Fixes
ada2c89修复:在 arrow-parens 中支持 TypeScript 泛型(修复 #12570)(#13451) (Milos Djermanovic)89ee01e修复:还原配置克隆(修复 #13447)(#13449)(薛定谔的猫)3f51930修复:no-extra-parens 中的带成员的新误报 (修复 #12740) (#13375) (YeonJuan)825a5b9修复:澄清关于隐式忽略行为的文档(修复 #12348) (#12600) (Scott Hardin)
文档
🌐 Documentation
f21bad2文档:修复 [never] 在 multiline-ternary 中的描述(修复 #13368)(#13452)(Milos Djermanovic)0a463db文档:修复 no-multiple-empty-lines 示例(修复 #13432)(#13433)(Milos Djermanovic)
