
亮点
🌐 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 中添加的,用于报告那些可能让开发者困惑的变量和函数名,例如 NaN 或 undefined。
随着 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 配置为仅允许 warn 和 error 方法。
🌐 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
e84e6e2功能:报告no-console规则允许的方法 (#19306) (Anna Bocharova)8efc2d0功能:取消标记 TypeScript 配置文件 (#19266) (Francesco Trotta)87a9352功能:检查no-shadow-restricted-names中的导入和类名 (#19272) (Milos Djermanovic)
错误修复
🌐 Bug Fixes
文档
🌐 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替换为let和const(#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
