ESLint v9.28.0 发布

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

亮点

🌐 Highlights

--pass-on-unpruned-suppressions CLI 选项

🌐 --pass-on-unpruned-suppressions CLI Option

ESLint v9.24.0 引入了批量抑制功能,这是备受期待的功能。当启用批量抑制时,ESLint 会在名为 eslint-suppressions.json 的文件中跟踪先前被抑制的违规情况,确保它们在后续运行中仍被忽略。随着代码库的编辑,其中一些违规可能会被解决,但仍会列在抑制文件中,直到被明确移除。最初的批量抑制草案提议在发现未使用抑制的情况下以退出码 2 退出,但用户请求能够忽略未清理的抑制以获得更大的灵活性。

🌐 ESLint v9.24.0 introduced bulk suppressions, a highly anticipated feature. When bulk suppressions are enabled, ESLint tracks previously suppressed violations in a file called eslint-suppressions.json, ensuring they remain ignored in subsequent runs. As the codebase is edited, some of these violations may be resolved but will still be listed in the suppressions file until explicitly removed. The original bulk suppressions draft proposed exiting with exit code 2 in cases where unused suppressions were found, but users requested the ability to ignore unpruned suppressions for greater flexibility.

在 ESLint v9.28.0 中,这现在成为可能,这要归功于一个新的 CLI 选项。--pass-on-unpruned-suppressions 标志允许 ESLint 跳过不再出现的抑制。当启用此标志时,未使用的抑制不会被报告为错误,也不会影响退出代码。

🌐 With ESLint v9.28.0, this is now possible thanks to a new CLI option. The --pass-on-unpruned-suppressions flag allows ESLint to skip suppressions that no longer occur. When this flag is enabled, unused suppressions are not reported as errors and do not affect the exit code.

核心规则中的 TypeScript 语法支持

🌐 TypeScript Syntax Support in Core Rules

正如在 ESLint v9.23.0 发布博客文章 中宣布的那样,我们正在积极努力将 TypeScript 语法支持添加到核心规则中。

🌐 As announced in the ESLint v9.23.0 release blog post, we are actively working to add TypeScript syntax support to core rules.

ESLint v9.28.0 为另外五个核心规则引入了完整的 TypeScript 语法支持。这些规则是:

🌐 ESLint v9.28.0 introduces full TypeScript syntax support for five more core rules. These rules are:

  • func-style。此规则具有新的 TypeScript 特定选项 "allowTypeAnnotation",并已更新以在 TypeScript 代码中忽略重载的函数声明。
  • no-magic-numbers。此规则有新的 TypeScript 特定选项:"ignoreEnums""ignoreNumericLiteralTypes""ignoreReadonlyClassProperties""ignoreTypeIndexes"
  • no-shadow。此规则有新的 TypeScript 特定选项 "ignoreTypeValueShadow""ignoreFunctionTypeParameterNameValueShadow",并且 "hoist" 选项接受新的、TypeScript 特定的值。
  • no-use-before-define。此规则具有新的 TypeScript 特定选项:"enums""typedefs""ignoreTypeReferences"
  • prefer-arrow-callback.

这些规则现在可以用于检查 TypeScript 文件以及常规 JavaScript 文件。 要检查 TypeScript 代码,请确保使用 @typescript-eslint/parser 或其他兼容的解析器。

🌐 These rules can now be used to lint TypeScript files as well as regular JavaScript. To lint TypeScript code, be sure to use @typescript-eslint/parser, or another compatible parser.

特性

🌐 Features

错误修复

🌐 Bug Fixes

文档

🌐 Documentation

  • 3ec2082 文档:文件配置项中的嵌套数组 (#19799) (Nicholas C. Zakas)
  • 89a65b0 文档:明确配置数组如何应用于文件的子集 (#19788) (Shais Ch)
  • 2ba8a0d 文档:在插件文档中添加 meta.namespace 的描述 (#19798) (Nicholas C. Zakas)
  • 59dd7e6 文档:使用示例更新 func-style (#19793) (Tanuj Kanti)
  • e9129e0 文档:在范围管理器文档中添加全局作用域的 implicit 字段 (#19770) (Milos Djermanovic)
  • 52f5b7a 文档:修复小错误并添加链接 (#19743) (루밀LuMir)
  • 00716a3 文档:事先建议不要使用 no-return-await 规则 (#19727) (Mike DiDomizio)

杂项

🌐 Chores

  • 175b7b8 任务: 升级到 @eslint/js@9.28.0 (#19802) (Francesco Trotta)
  • 844f5a6 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • 62b1c1b 杂务:将 globals 更新到 v16 (#19791) (Nitin Kumar)
  • e8a1cb8 杂务:在 Renovate 中忽略 jiti-v2.0 和 jiti-v2.1 (#19786) (Nitin Kumar)
  • 43d3975 事务: 添加 Copilot 指南文件 (#19753) (Nicholas C. Zakas)
  • 2dfb5eb 测试:更新 SourceCodeTraverser 测试 (#19763) (Milos Djermanovic)
  • 5bc21f9 杂项:将 *.code-workspace 添加到 .gitignore (#19771) (루밀LuMir)
  • f4fa40e 重构:NodeEventGenerator -> SourceCodeTraverser (#19679) (Nicholas C. Zakas)
  • 0f49329 重构:使用服务发出警告 (#19725) (Francesco Trotta)
  • 20a9e59 杂务: 更新依赖 shelljs 至 ^0.10.0 (#19740) (renovate[bot])

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