
亮点
🌐 Highlights
MCP 服务器的独立包
🌐 Separate Package for MCP Server
ESLint MCP 服务器在 v9.26.0 中被添加到核心,现在已被提取到一个独立的包 @eslint/mcp。可以通过运行 npx @eslint/mcp@latest 来启动该服务器。有关设置和使用的更多详细信息,请阅读 文档。
🌐 The ESLint MCP server, added to the core in v9.26.0, has been extracted into a separate package @eslint/mcp. The server can be started by running npx @eslint/mcp@latest. For more details on setup and usage, please read the documentation.
此更改旨在减少 ESLint 依赖的数量和大小。--mcp ESLint CLI 标志仍然有效,为已经依赖它的用户保持相同的行为,但现在它只是运行 npx @eslint/mcp@latest。
🌐 This change has been made to reduce the number and size of ESLint dependencies. The --mcp ESLint CLI flag still works, maintaining the same behavior for users who are already relying on it, but now it just runs npx @eslint/mcp@latest.
ESLINT_FLAGS 环境变量
🌐 ESLINT_FLAGS environment variable
功能标记 现在也可以使用 ESLINT_FLAGS 环境变量进行设置。
# .bashrc
export ESLINT_FLAGS="unstable_config_lookup_from_file,unstable_native_nodejs_ts_config"
这种方法在 CI/CD 管道中尤其有用,或者当你想在多个 ESLint 命令中启用相同的标志时。
🌐 This approach can be especially useful in CI/CD pipelines or when you want to enable the same flags across multiple ESLint commands.
有关更多详细信息,请参阅 使用环境变量启用功能标志。
🌐 See Enable Feature Flags with Environment Variables for more details.
已排序 eslint-suppressions.json
🌐 Sorted eslint-suppressions.json
抑制文件 中的对象键现在已排序,以避免内容更改时产生不必要的差异。
🌐 Object keys in suppressions files are now sorted, to avoid unnecessary diff when the content changes.
新规则 no-unassigned-vars
🌐 New Rule no-unassigned-vars
核心中已添加了一条新规则:no-unassigned-vars。
🌐 One new rule has been added to the core: no-unassigned-vars.
此规则报告使用 let 或 var 声明但从未赋值却仍在代码中读取的变量。由于这些变量的值将始终为 undefined,它们的使用可能是编程错误。
🌐 This rule reports variables declared using let or var that are never assigned a value but are still read in the code. Since these variables will always have the value undefined, their usage is likely a programming mistake.
/*eslint no-unassigned-vars: "error"*/
let status; // error: 'status' is always 'undefined' because it's never assigned.
if (status === 'ready') {
console.log('Ready!');
}
no-useless-escape 中的 allowRegexCharacters 选项
🌐 allowRegexCharacters option in no-useless-escape
no-useless-escape 规则有一个新的 allowRegexCharacters 选项,它可用于允许在正则表达式字面量中对指定字符进行不必要的转义。
🌐 The no-useless-escape rule has a new allowRegexCharacters option, which can be used to allow unnecessary escapes for specified characters in regular expression literals.
/*eslint no-useless-escape: ["error", { "allowRegexCharacters": ["-"] }]*/
/[0\-]/; // not reported, because "-" is specified in "allowRegexCharacters"
在上述示例中,转义 - 并不会改变正则表达式的行为,因此默认情况下,此规则会报告它。然而,允许转义 - 可能是有用的,以防止它在字符类末尾添加另一个字符时形成范围语法。
🌐 In the above example, escaping - doesn’t change the behavior of the regular expression, and therefore this rule would report it by default. However, allowing escaped - might be useful to prevent it from forming the range syntax if another character is later added to the end of the character class.
no-array-constructor可以自动修复
🌐 no-array-constructor is autofixable
由 no-array-constructor 规则报告的大多数问题现在可以通过 --fix 命令行选项自动修复。
🌐 Most problems reported by the no-array-constructor rule can now be automatically fixed with the --fix command line option.
在修复不安全的情况下,例如由于未知数量的参数而导致的 new Array(...args),以及在传递单个参数时 Array 构造函数的特定行为,此规则仍然提供建议。
🌐 In cases where the fix wouldn’t be safe, such as new Array(...args) due to an unknown number of arguments and the specific behavior of the Array constructor when a single argument is passed, this rule still provides suggestions.
核心规则中的 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.27.0 为另外两个核心规则引入了完整的 TypeScript 语法支持。这些规则是:
🌐 ESLint v9.27.0 introduces full TypeScript syntax support for two more core rules. These rules are:
max-params。这个规则有一个新的 TypeScript 特定选项countVoidThis。no-unassigned-vars。这个新增加的规则从一开始就支持 TypeScript 语法,不会报告全局声明。
这些规则现在可以用于检查 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.
特性
🌐 Features
d71e37f功能:允许在 ESLINT_FLAGS 环境变量中设置标志 (#19717) (Nicholas C. Zakas)ba456e0功能:外部化 MCP 服务器 (#19699) (Nicholas C. Zakas)07c1a7e功能:向no-useless-escape添加allowRegexCharacters(#19705) (sethamus)7bc6c71功能:添加 no-unassigned-vars 规则 (#19618) (Jacob Bandes-Storch)ee40364功能:将 no-array-constructor 建议转换为自动修复 (#19621) (sethamus)32957cd功能:在max-params中支持 TS 语法 (#19557) (Nitin Kumar)
错误修复
🌐 Bug Fixes
5687ce7修复:纠正不匹配的已删除规则 (#19734) (루밀LuMir)dc5ed33修复:纠正类型并在SourceCode类中收紧类型定义 (#19731) (루밀LuMir)de1b5de修复:纠正Linter.ESLintParseResult类型中的service属性名 (#19713) (Francesco Trotta)60c3e2c修复:对 eslint-suppressions.json 中的键进行排序以避免 git 频繁变动 (#19711) (Ron Waldon-Howe)9da90ca修复:将allowReserved添加到Linter.ParserOptions类型 (#19710) (Francesco Trotta)fbb8be9修复:将info添加到ESLint.DeprecatedRuleUse类型 (#19701) (Francesco Trotta)
文档
🌐 Documentation
25de550文档:更新冻结规则的描述以提及 TypeScript (#19736) (Nicholas C. Zakas)bd5def6文档:清理配置文件文档 (#19735) (Nicholas C. Zakas)4d0c60d文档:将 Neovim 添加到编辑器集成中 (#19729) (Maria José Solano)71317eb文档:更新自述文件(GitHub Actions 机器人)4c289e6文档:更新自述文件(GitHub Actions 机器人)f0f0d46文档:澄清未使用的抑制会导致非零退出代码 (#19698) (Milos Djermanovic)8ed3273文档:修复ConfigData类型的内部使用 (#19688) (Francesco Trotta)eb316a8文档:在Package.json Conventions中添加fmt和check部分 (#19686) (루밀LuMir)a3a2559文档:修复 Combine Configs 中的措辞 (#19685) (Milos Djermanovic)c8d17e1文档:更新自述文件(GitHub Actions 机器人)
杂项
🌐 Chores
f8f1560杂务:升级 @eslint/js@9.27.0 (#19739) (Milos Djermanovic)ecaef73事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)596fdc6事务:将依赖 @arethetypeswrong/cli 更新到 ^0.18.0 (#19732) (renovate[bot])f791da0杂项:从.editorconfig中移除不平衡的大括号 (#19730) (Maria José Solano)e86edee重构:整合配置助手 (#19675) (Nicholas C. Zakas)cf36352杂务:移除共享类型 (#19718) (Francesco Trotta)f60f276重构:更容易创建 RuleContext (#19709) (Nicholas C. Zakas)58a171e任务:将依赖 @eslint/plugin-kit 更新到 ^0.3.1 (#19712) (renovate[bot])3a075a2杂项:将依赖 @eslint/core 更新到 ^0.14.0 (#19715) (renovate[bot])44bac9dci:在 Node.js 24 中运行测试 (#19702) (Francesco Trotta)35304dd事务:向包中添加缺失的funding字段 (#19684) (루밀LuMir)f305beb测试:模拟process.emitWarning以防止输出中断 (#19687) (Francesco Trotta)
