ESLint v9.18.0 发布

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

亮点

🌐 Highlights

稳定的 TypeScript 配置文件支持

🌐 Stable TypeScript configuration file support

在上一年的八月,ESLint 作为实验性功能推出了对 TypeScript 配置文件的支持。为了使用像 eslint.config.ts 这样的 TypeScript 配置文件,用户必须在命令行中指定 unstable_ts_config 标志,例如:

🌐 In August of the previous year, ESLint launched support for TypeScript configuration files as an experimental feature. In order to use a TypeScript configuration file like eslint.config.ts, users had to specify the unstable_ts_config flag in the command line, e.g.

npx eslint --flag unstable_ts_config

经过数月的试验期,在此期间没有收到具体投诉,仅进行了少量调整,我们已决定正式将对 TypeScript 配置文件的支持作为一个稳定功能实现。 从 ESLint v9.18.0 起,扩展名为 .ts.mts.cts 的 TypeScript 配置文件可以像常规 JavaScript 配置文件一样使用。 如果你正在从以前版本的 ESLint 升级,请确保从命令中移除 unstable_ts_config 标志。

🌐 Following an experimental period of several months, during which there were no specific complaints and only minor adjustments, we have made the decision to officially implement support for TypeScript configuration files as a stable feature. Starting with ESLint v9.18.0, TypeScript configuration files with extensions .ts, .mts and .cts can be used like regular JavaScript configuration files. If you are upgrading from a previous version of ESLint, be sure to remove the unstable_ts_config flag from the command.

请注意,为了在 Node.js 中使用 TypeScript 配置文件,你仍然需要安装版本为 2.0 或更高的 jiti。 对于 Deno 和 Bun,则不需要额外的依赖。 有关此功能的更多信息,请参阅关于 TypeScript 配置文件 的文档。

🌐 Note that in order to use a TypeScript configuration file in Node.js, you still need to have jiti installed in version 2.0 or higher. For Deno and Bun, no additional dependency is necessary. See the documentation about TypeScript Configuration Files for more information about this feature.

no-shadow-restricted-names 检查导入和类名

🌐 no-shadow-restricted-names checks imports and class names

现在 no-shadow-restricted-names 规则也会检查导入声明和类名中的受限名称,例如:

🌐 The no-shadow-restricted-names rule will now check for restricted names also in import declarations and in class names, for example:

import undefined from "foo";

class NaN {}

游乐场链接

此规则是在 ESLint v0.1.4 中添加的,用于报告那些可能让开发者困惑的变量和函数名,例如 NaNundefined。 随着 JavaScript 的发展,引入了新的语法结构,这些结构可能接受相同的问题名称。 这些较新的情况现在也会被此规则检测并报告。

🌐 This rule was added in ESLint v0.1.4 to report on variables and functions with names that could be confusing to developers like NaN or undefined. As JavaScript evolved, new syntactic constructs were introduced that could accept the same problematic names. These newer cases are now detected and reported by the rule.

no-config 问题中允许的方法名称

🌐 Allowed method names in no-config problems

no-console-rule 已更新,以指示在报告问题时明确配置为允许的方法名称。这可以帮助开发者找到此规则报告的问题的可接受替代方案。

🌐 The no-console-rule has been updated to indicate the name of methods that are explicitly configured as allowed when reporting a problem. This can help developers to find an acceptable alternative to problem reported by this rule.

考虑以下情况,其中 no-console 配置为仅允许 warnerror 方法。

🌐 Consider the following case where no-console is configured to allow only the warn and error methods.

/* eslint no-console: ["error", { allow: ["warn", "error"] }] */

console.log("Some text.");

以前,该规则会用通用消息“Unexpected console statement.”报告问题。在 ESLint v9.18.0 中,消息显示为“Unexpected console statement. Only these console methods are allowed: warn, error.”

🌐 Previously, the rule would report a problem with the generic message “Unexpected console statement.” In ESLint v9.18.0, the message reads “Unexpected console statement. Only these console methods are allowed: warn, error.”

游乐场链接

特性

🌐 Features

错误修复

🌐 Bug Fixes

  • da768d4 修复:纠正 overrideConfigFile 类型 (#19289) (Francesco Trotta)

文档

🌐 Documentation

  • d9c23c5 文档:在规则示例中将 var 替换为 const (#19325) (Tanuj Kanti)
  • 8e1a898 文档:向 CLI 代码块添加制表符 (#18784) (Jay)
  • f3aeefb 文档:在规则示例中使用 let 和 const 重写 (#19320) (PoloSpark)
  • 0b680b3 文档:更新自述文件(GitHub Actions 机器人)
  • 98c86a9 文档:Edit this page 按钮链接到不同的分支 (#19228) (Tanuj Kanti)
  • 6947901 文档:移除硬编码的编辑链接 (#19323) (Milos Djermanovic)
  • 03f2f44 文档:在规则示例中将 var 重写为 const (#19317) (Thiago)
  • 26c3003 文档:明确 eslint:all 的危险 (#19318) (Nicholas C. Zakas)
  • c038257 文档:在 no-eq-null 的相关规则中添加 eqeqeq (#19310) (루밀LuMir)
  • 89c8fc5 文档:将使用 var 的示例重写为使用 let 和 const (#19315) (Amaresh S M)
  • db574c4 文档:给 no-void 添加缺失的反引号 (#19313) (루밀LuMir)
  • 8d943c3 文档:给 default-case-last 添加缺失的反引号 (#19311) (루밀LuMir)
  • 36ef8bb 文档:将使用 var 的示例重写为使用 let 和 const (#19298) (Amaresh S M)
  • 1610c9e 文档:给 no-else-return 添加缺失的反引号 (#19309) (루밀LuMir)
  • df409d8 文档:更新自述文件(GitHub Actions 机器人)
  • 2e84213 文档:修复移动端视图中规则描述的水平滚动溢出问题 (#19304) (Amaresh S M)
  • 6e7361b 文档:在规则示例中将 var 替换为 letconst (#19302) (Tanuj Kanti)
  • 069af5e 文档:在规则示例中使用 const 重写 var (#19303) (Kim GyeonWon)
  • 064e35d 文档:从 scope-manager-interface 中移除 ‘I hope to’ 评论 (#19300) (Josh Goldberg ✨)
  • 8e00305 文档:在规则示例中将 var 替换为 const (#19299) (Tanuj Kanti)
  • a559009 文档:增加关于扩展核心规则的警告 (#19295) (Nicholas C. Zakas)
  • 0bfdf6c 文档:更新自述文件(GitHub Actions 机器人)
  • ce0b9ff 文档:为 code explorer 添加导航链接 (#19285) (Tanuj Kanti)
  • e255cc9 文档:在底部添加 bluesky 图标 (#19290) (Tanuj Kanti)
  • 5d64851 文档:移除关于环境的过时信息 (#19296) (Francesco Trotta)
  • eec01f0 文档:将规则示例配置格式切换为 languageOptions (#19277) (Milos Djermanovic)
  • b36ca0a 文档:通过重新排列元素顺序修复焦点顺序 (#19241) (Amaresh S M)
  • d122c8a 文档:给 sort-imports 添加缺失的反引号 (#19282) (루밀LuMir)
  • 0367a70 文档:更新自定义解析器文档 (#19288) (Francesco Trotta)
  • 8c07ebb 文档:将 border-radius 添加到 hX:target 选择器样式 (#19270) (루밀LuMir)
  • eff7c57 文档:在 no-loop-func 中添加限制部分 (#19287) (Tanuj Kanti)
  • 5db226f 文档:在文档的各个部分添加缺失的反引号 (#19269) (루밀LuMir)
  • 789edbb 文档:更新自述文件(GitHub Actions 机器人)
  • 613c06a 文档:用 ❄️ 标记被冻结的规则 (#19231) (Amaresh S M)
  • 43172ec 文档:更新自述文件(GitHub Actions 机器人)
  • ac8b3c4 文档:修复 overrideConfigFile 选项的描述 (#19262) (Milos Djermanovic)
  • bbb9b46 文档:更新自述文件(GitHub Actions 机器人)
  • 995b492 文档:修复规则类别框中的不一致分隔符 (#19249) (Tanuj Kanti)
  • f76d05d 文档:通过更好的事件监听器清理重构搜索结果处理 (#19252) (Amaresh S M)
  • c5f3d7d 文档:更新自述文件(GitHub Actions 机器人)

杂项

🌐 Chores

  • c52be85 事务: 升级到 @eslint/js@9.18.0 (#19330) (Francesco Trotta)
  • 362099c 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • 495aa49 任务:为公共接口从 package.json 提取包 name (#19314) (루밀LuMir)
  • 6fe0e72 杂项:将依赖 @eslint/json 更新到 ^0.9.0 (#19263) (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 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。