
亮点
🌐 Highlights
语言感知规则
🌐 Language-aware rules
ESLint v10.2.0 通过新的 meta.languages 属性增加了对语言感知规则的支持。规则作者现在可以明确声明规则支持哪些语言,如果在不支持的语言上启用该规则,ESLint 将根据 language 配置选项抛出运行时错误。
🌐 ESLint v10.2.0 adds support for language-aware rules through the new meta.languages property. Rule authors can now explicitly declare which languages a rule supports, and ESLint will throw a runtime error if that rule is enabled for an unsupported language, as specified by the language configuration option.
这是一个仅支持 JavaScript 语言的规则示例:
🌐 Here is an example of a rule that only supports the JavaScript language:
const rule = {
meta: {
type: "problem",
docs: {
description: "Example JavaScript rule",
},
languages: ["js/js"],
},
create(context) {
return {};
},
};
目前,没有任何 ESLint 内置规则限制它们设计用于的语言,但将来可能会有所改变。
🌐 Currently, none of the ESLint built-in rules restrict the languages they are designed to work with, but this may change in the future.
有关 meta.languages 属性的更多信息,请参见 自定义规则文档。
🌐 More information about the meta.languages property can be found in the custom rules documentation.
Temporal 支持
🌐 Temporal support
随着 Temporal 提案 现在处于 TC39 第 4 阶段,ESLint v10.2.0 将 Temporal 识别为内置全局。因此,在默认配置下,no-undef 规则不再标记 Temporal:
🌐 With the Temporal proposal now at TC39 stage 4, ESLint v10.2.0 recognizes Temporal as a built-in global. As a result, the no-undef rule no longer flags Temporal under the default configuration:
/* eslint no-undef: "error" */
const now = Temporal.Now.instant(); // OK
此外,no-obj-calls 规则现在会报告对全局 Temporal 对象的直接调用:
🌐 In addition, the no-obj-calls rule now reports direct calls to the global Temporal object:
/* eslint no-obj-calls: "error" */
Temporal(); // Error: 'Temporal' is not a function.
特性
🌐 Features
586ec2f功能:为规则添加meta.languages支持 (#20571) (Copilot)14207de功能:向no-obj-calls添加Temporal(#20675) (Pixel998)bbb2c93功能:向 ES2026 全局添加 Temporal (#20672) (Pixel998)
错误修复
🌐 Bug Fixes
文档
🌐 Documentation
a2af743文档:将language添加到配置对象 (#20712) (Francesco Trotta)845f23f文档:更新自述文件(GitHub Actions 机器人)5fbcf59文档:从 ts playground 链接中移除sourceType(#20477) (Tanuj Kanti)8702a47文档:更新自述文件(GitHub Actions 机器人)ddeaded文档:更新自述文件(GitHub Actions 机器人)2b44966文档:在管理发布中添加主要版本部分 (#20269) (Milos Djermanovic)eab65c7文档:更新示例中的eslint版本 (#20664) (루밀LuMir)3e4a299文档:更新 ESM 依赖政策,并附上自用包的备注 (#20660) (Milos Djermanovic)
杂项
🌐 Chores
8120e30重构:提取未修改的循环条件 (#20679) (kuldeep kumar)46e8469任务:将依赖 markdownlint-cli2 更新到 ^0.22.0 (#20697) (renovate[bot])01ed3aa测试:为 Unicode 工具添加单元测试 (#20622) (Manish chaudhary)811f493ci:从类型集成测试中移除--legacy-peer-deps(#20667) (Milos Djermanovic)6b86fcf杂务:将依赖 npm-run-all2 更新到 v8 (#20663) (renovate[bot])632c4f8杂项: 将prettier更新提交添加到.git-blame-ignore-revs(#20662) (루밀LuMir)b0b0f21事务:将依赖 eslint-plugin-regexp 更新到 ^3.1.0 (#20659) (Milos Djermanovic)228a2dd事务:将依赖 eslint-plugin-eslint-plugin 更新到 ^7.3.2 (#20661) (Milos Djermanovic)3ab4d7e测试:为 eslintrc 风格的键添加测试 (#20645) (kuldeep kumar)
