
亮点
🌐 Highlights
批量抑制
🌐 Bulk Suppressions
此版本引入了批量抑制功能。此功能允许在不立即修复所有违规的情况下,将新的 lint 规则启用为 "error"。虽然该规则会在新代码中强制执行,但现有违规将不会被报告。这样,你可以根据自己的节奏处理现有违规。
🌐 This release introduces the bulk suppressions feature. This feature allows for enabling new lint rules as "error" without fixing all violations upfront. While the rule will be enforced for new code, the existing violations will not be reported. This way, you can address the existing violations at your own pace.
# Fix all autofixable violations and suppress the remaining ones
eslint --suppress-all --fix
# Fix all autofixable violations, but suppress only violations for <rule-name>
eslint --suppress-rule <rule-name> --fix
这种方法优先阻止新的违规行为,同时提供了一个清晰的路径来逐步改进现有代码。
🌐 This approach prioritizes preventing new violations while providing a clear path to incrementally improve existing code.
🌐 You can find all the details in the announcement blog post and the Bulk Supressions documentation page.
以 ./ 开头的模式
🌐 Patterns starting with ./
在 ESLint v9.24.0 之前,以 ./ 开头的 files 和 ignores 模式会被忽略。
🌐 Prior to ESLint v9.24.0, files and ignores patterns that start with ./ were ignored.
截至 ESLint v9.24.0,这些模式被视为相对于配置基路径(配置文件的位置,或者如果使用了 --config 命令行选项,则为当前工作目录)。以 ./ 开头的模式等同于没有 ./ 前缀的相同模式。
🌐 As of ESLint v9.24.0, these patterns are treated as relative to the config base path (the location of the config file, or the current working directory if the --config command line option was used). A pattern that starts with ./ is equivalent to the same pattern without the ./ prefix.
// eslint.config.js
export default [
{
// Equivalent to `ignores: ["foo.js"]`
ignores: ["./foo.js"]
},
{
// Equivalent to `files: ["bar/*.js"]`
files: ["./bar/*.js"],
rules: {
"no-undef": "error"
}
}
];
核心规则中的 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.24.0 为另外四个核心规则引入了完整的 TypeScript 语法支持。这些规则是:
🌐 ESLint v9.24.0 introduces full TypeScript syntax support for four more core rules. These rules are:
这些规则现在可以用于检查 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.
此外,class-methods-use-this 规则有两个新的 TypeScript 特定选项:ignoreOverrideMethods 和 ignoreClassesWithImplements。
🌐 Additionally, the class-methods-use-this rule has two new TypeScript-specific options: ignoreOverrideMethods and ignoreClassesWithImplements.
Node.js 原生加载 TypeScript 配置文件(实验性功能)
🌐 Node.js Native Loading of TypeScript Configuration Files (Experimental)
如果你使用的是 Node.js >= 22.10.0,你现在可以在不安装 jiti 的情况下使用 TypeScript 配置文件(eslint.config.ts、eslint.config.mts 或 eslint.config.cts)。这要归功于 --experimental-strip-types Node.js 标志。
🌐 If you’re using Node.js >= 22.10.0, you can now use TypeScript configuration files (eslint.config.ts, eslint.config.mts, or eslint.config.cts) without installing jiti. This is possible thanks to the --experimental-strip-types Node.js flag.
由于此功能仍在实验阶段,你还必须启用 unstable_native_nodejs_ts_config ESLint 标志。
🌐 Since this feature is still experimental, you must also enable the unstable_native_nodejs_ts_config ESLint flag.
npx --node-options='--experimental-strip-types' eslint --flag unstable_native_nodejs_ts_config
特性
🌐 Features
556c25b功能:支持使用--experimental-strip-types加载 TS 配置文件 (#19401) (Arya Emami)72650ac功能:在init-declarations中支持 TS 语法 (#19540) (Nitin Kumar)03fb0bc功能:规范模式以处理文件中的 “./” 前缀并忽略 (#19568) (Pixel998)071dcd3功能:在no-dupe-class-members中支持 TS 语法 (#19558) (Nitin Kumar)cd72bcc功能:引入一种抑制违规的方法 (#19159) (Iacovos Constantinou)2a81578功能:在no-loss-of-precision中支持 TS 语法 (#19560) (Nitin Kumar)30ae4ed功能:为 class-methods-use-this 添加新选项 (#19527) (sethamus)b79ade6功能:在no-array-constructor中支持 TypeScript 语法 (#19493) (Tanuj Kanti)
错误修复
🌐 Bug Fixes
b23d1c5修复:在 no-loop-func 错误信息中去重变量名 (#19595) (Nitin Kumar)fb8cdb8修复:对context.options使用any[]类型 (#19584) (Francesco Trotta)
文档
🌐 Documentation
f857820文档:更新--experimental-strip-types的文档 (#19594) (Nikolas Schröter)803e4af文档:简化 includeIgnoreFile 部分的 gitignore 路径处理 (#19596) (Thomas Broyer)6d979cc文档:更新自述文件(GitHub Actions 机器人)82177e4文档:更新自述文件(GitHub Actions 机器人)e849dc0文档:用 const 替换现有的 var (#19578) (Sweta Tanwar)0c65c62文档:在 lint 规则示例中不要传递文件名 (#19571) (Milos Djermanovic)6be36c9文档:更新 fixer 的自定义规则代码示例 (#19555) (潘一帆)
构建相关
🌐 Build Related
杂项
🌐 Chores
ef67420杂务:升级 @eslint/js@9.24.0 (#19602) (Milos Djermanovic)4946847事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)a995acb杂务:纠正包脚本中的 ‘flter’/‘filter’ 拼写错误 (#19587) (Josh Goldberg ✨)b9a5efa测试:在 Windows 上跳过符号链接测试 (#19503) (fisker Cheung)46eea6d任务:从shared/types.js中移除Rule和FormatterFunction(#19556) (Nitin Kumar)bdcc91d杂项:修改 .editorconfig 以与 prettier 配置保持一致 (#19577) (Sweta Tanwar)7790d83杂务:修复评论中的一些拼写错误 (#19576) (todaymoon)76064a6测试:忽略package-lock.json对eslint-webpack-plugin的影响 (#19572) (Francesco Trotta)
