
亮点
🌐 Highlights
MCP 服务器集成
🌐 MCP Server Integration
ESLint v9.26.0 增加了对 模型上下文协议 (MCP) 服务器的支持,使 ESLint 能够通过统一接口与 AI 模型和工具进行交互。此功能允许大型语言模型(LLM)在 IDE 和其他软件中运行 ESLint,帮助开发者完成如代码规范检查和代码分析等任务。可以使用 ESLint 命令行中的 --mcp 标志来启动 MCP 服务器。对于使用 GitHub Copilot 等 AI 驱动的编码助手的开发者来说,这一功能尤其有用。
阅读 文档 了解 MCP 服务器如何在开发任务中帮助你。
🌐 ESLint v9.26.0 adds support for a Model Context Protocol (MCP) server, enabling ESLint to interact with AI models and tools through a unified interface. This feature allows large language models (LLMs) to run ESLint in IDEs and other software, assisting developers with tasks like linting and code analysis. The MCP server can be started using the --mcp flag in the ESLint command line. This feature is particularly useful for developers using AI-powered coding assistants like GitHub Copilot.
Read the documentation to learn how the MCP server can help you in your development tasks.
在 no-shadow-restricted-names 中支持 globalThis
🌐 Support globalThis in no-shadow-restricted-names
现在 no-shadow-restricted-names 规则包括支持检测 globalThis 的遮蔽(shadowing),除此之外还包括其他受限标识符如 NaN、Infinity、undefined、eval 和 arguments。要启用此功能,必须将 reportGlobalThis 选项设置为 true。
🌐 The no-shadow-restricted-names rule now includes support for detecting shadowing of globalThis, in addition to other restricted identifiers like NaN, Infinity, undefined, eval, and arguments. To enable this feature, the reportGlobalThis option must be set to true.
/* eslint no-shadow-restricted-names: ["error", { "reportGlobalThis": true }] */
const globalThis = { /* custom object */ };
这一增强功能帮助开发者避免混淆或意外地遮蔽 globalThis 对象,该对象是在 ECMAScript 2020 语言规范中引入的。
🌐 This enhancement helps developers avoid confusing or unintended shadowing of the globalThis object, which was introduced in the ECMAScript 2020 language specification.
no-unused-expressions 中的 ignoreDirectives 选项
🌐 ignoreDirectives option in no-unused-expressions
[no-unused-expressions](https://eslint.nodejs.cn/docs/latest/rules/no-unused-expressions) 有一个新的 ignoreDirectives 选项,可用于在 ES3 代码库中忽略指令。此选项允许用户在 lint ES3 代码库时忽略指令(例如 "use strict")。默认情况下,该规则现在会将指令报告为在 ES3 环境中未使用的表达式,因为 ES3 并不正式支持指令,将其视为未使用的代码。这种行为与 ESLint v9.25.0 中的默认行为一致,该版本在 ESLint v9.25.1 中因兼容性问题被恢复。
🌐 The no-unused-expressions has a new ignoreDirectives option which can be used to ignore directives in ES3 codebases. This option allows users to ignore directives (e.g., "use strict") when linting ES3 codebases. By default, the rule now reports directives as unused expressions in ES3 environments, as ES3 does not formally support directives, treating them as unused code. This behavior aligns with the default behavior in ESLint v9.25.0, which was reverted in ESLint v9.25.1 because of compatibility concerns.
特性
🌐 Features
e9754e7功能:向 no-shadow-restricted-names 添加 reportGlobalThis (#19670) (sethamus)0fa2b7a功能:为eqeqeq规则添加建议 (#19640) (Nitin Kumar)dcbdcc9功能:添加 MCP 服务器 (#19592) (Nicholas C. Zakas)2dfd83e功能:在no-unused-expressions中添加ignoreDirectives选项 (#19645) (sethamus)
错误修复
🌐 Bug Fixes
96e84de修复:在删除前检查缓存文件是否存在 (#19648) (sethamus)d683aeb修复:在RuleTester中遇到循环引用的测试时不会崩溃 (#19664) (Milos Djermanovic)9736d5d修复:将namespace添加到Plugin.meta类型 (#19661) (Milos Djermanovic)17bae69修复:更新RuleTester.run()类型 (#19634) (Nitin Kumar)
文档
🌐 Documentation
dd98d63文档:更新自述文件(GitHub Actions 机器人)c25e858文档:更新自述文件(GitHub Actions 机器人)b2397e9文档:更新自述文件(GitHub Actions 机器人)addd0a6文档:修复 Markdown 中无序列表的格式 (#19660) (Milos Djermanovic)a21b38d文档:更新自述文件(GitHub Actions 机器人)c0721a7文档:修复命令中的双空格 (#19657) (CamWass)
杂项
🌐 Chores
5b247c8任务: 升级到@eslint/js@9.26.0(#19681) (Francesco Trotta)d6fa4ac事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)0958690杂务:澄清内部类型LanguageOptions和Rule(#19669) (Francesco Trotta)f1c858e杂项:修复对Plugin和Rule的内部类型引用 (#19665) (Francesco Trotta)40dd299重构:一次性 ESQuery 选择器分析 (#19652) (Nicholas C. Zakas)1cfd702杂项:将依赖 @eslint/json 更新到 ^0.12.0 (#19656) (renovate[bot])
