
亮点
🌐 Highlights
no-restricted-imports 中的 allowTypeImports 选项
🌐 allowTypeImports option in no-restricted-imports
[no-restricted-imports](/docs/latest/rules/no-restricted-imports) 规则现在支持 allowTypeImports 选项。当设置为 true 时,这将允许在 TypeScript 文件中进行仅类型导入,同时仍然禁止普通导入。
🌐 The no-restricted-imports rule now supports the allowTypeImports option.
When set to true, this will allow type-only imports in TypeScript files while still disallowing regular imports.
例如,以下规则设置只允许从 node:assert 模块进行仅类型导入:
🌐 For example, the following rule setting permits only type-only imports from the node:assert module:
/*
eslint no-restricted-imports: ["error", {
name: "node:assert",
allowTypeImports: true,
}]
*/
import assert from "node:assert"; // ❌ Incorrect
import type { AssertionError } from "node:assert"; // ✅ Correct
这将 no-restricted-imports 规则与 相应的 typescript-eslint 规则 对齐,并继续 ESLint 在核心规则中扩展 TypeScript 语法支持的持续努力。
🌐 This aligns the no-restricted-imports rule with the corresponding typescript-eslint rule, and continues ESLint’s ongoing efforts to extend TypeScript Syntax support in core rules.
--concurrency=auto 的改进启发式方法
🌐 Improved heuristic for --concurrency=auto
在 ESLint v9.34.0 引入多线程 linting 之后,一些使用 --cache 标志运行 ESLint 的用户报告说,与不设置 --concurrency 选项相比,使用 --concurrency=auto 时性能更慢。
🌐 After the introduction of multithreaded linting in ESLint v9.34.0, some users running ESLint with the --cache flag reported slower performance when using --concurrency=auto compared to leaving the --concurrency option unset.
慢速发生是因为即使大多数结果已经被缓存,ESLint 有时也会启用多线程模式,从而增加了不必要的开销。
🌐 The slowdown occurred because ESLint would sometimes enable multithread mode even when most results were already cached, adding unnecessary overhead.
这个行为已在 ESLint v9.37.0 中得到纠正,其中 --concurrency=auto 的启发式已得到改进,以更好地考虑增加并行性没有带来好处的情况。
🌐 This behavior has been corrected in ESLint v9.37.0, where the heuristic for --concurrency=auto has been improved to better account for cases where increased parallelism provides no benefit.
preserve-caught-error 识别计算的 cause 属性
🌐 preserve-caught-error recognizes computed cause property
现在 preserve-caught-error 规则可以正确处理在抛出错误中使用计算属性语法表达的 cause 选项的情况。例如:
🌐 The preserve-caught-error rule now correctly handles cases where the cause option in a thrown error is expressed using computed property syntax. For example:
try {
// ...
} catch (error) {
throw new Error("Unexpected error!", { ["cause"]: error });
}
特性
🌐 Features
39f7fb4功能:preserve-caught-error应该识别所有静态“cause”键 (#20163) (Pixel998)f81eabc功能:在no-restricted-imports中支持 TS 语法 (#19562) (Nitin Kumar)
错误修复
🌐 Bug Fixes
a129cce修复:纠正no-loss-of-precision对前导零的误报 (#20164) (Francesco Trotta)09e04fc修复:添加缺失的 AST 令牌类型 (#20172) (Pixel998)861c6da修复:更正ESLint类型定义 (#20122) (Pixel998)
文档
🌐 Documentation
b950359文档:修复文档中的拼写错误 (#20182) (루밀LuMir)42498a2文档:通过隐藏非语义字符改进目录可访问性 (#20181) (Percy Ma)29ea092文档:更新自述文件(GitHub Actions 机器人)5c97a04文档:在已弃用规则横幅中显示availableUntil(#20170) (Pixel998)90a71bf文档:更新README文件以添加徽章和说明 (#20115) (루밀LuMir)1603ae1文档:将引用从master更新为main(#20153) (루밀LuMir)
杂项
🌐 Chores
afe8a13杂务:将@eslint/js依赖更新到版本 9.37.0 (#20183) (Francesco Trotta)abee4ca事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)fc9381f任务:修复评论中的拼写错误 (#20175) (overlookmotel)e1574a2任务:取消固定 jiti (#20173) (renovate[bot])e1ac05e重构:将ESLint.findConfigFile()标记为async,添加缺失的文档 (#20157) (Pixel998)347906d杂务:更新 eslint (#20149) (renovate[bot])0cb5897测试:删除在多线程模式测试中为循环修复创建的临时目录 (#20146) (Milos Djermanovic)bb99566ci:将jiti固定到版本 2.5.1 (#20151) (Pixel998)177f669perf:改进"auto"并发的工作线程数量计算 (#20067) (Francesco Trotta)448b57b任务:将已废弃的格式规则标记为在 v11.0.0 之前可用 (#20144) (Milos Djermanovic)
