ESLint v9.26.0 发布

我们刚刚发布了 ESLint v9.26.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。

亮点

🌐 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),除此之外还包括其他受限标识符如 NaNInfinityundefinedevalarguments。要启用此功能,必须将 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

错误修复

🌐 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 杂务:澄清内部类型 LanguageOptionsRule (#19669) (Francesco Trotta)
  • f1c858e 杂项:修复对 PluginRule 的内部类型引用 (#19665) (Francesco Trotta)
  • 40dd299 重构:一次性 ESQuery 选择器分析 (#19652) (Nicholas C. Zakas)
  • 1cfd702 杂项:将依赖 @eslint/json 更新到 ^0.12.0 (#19656) (renovate[bot])

最新的 ESLint 新闻、案例研究、教程和资源。

ESLint v10.3.0 发布
1 min read

ESLint v10.3.0 发布

我们刚刚发布了 ESLint v10.3.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。

ESLint v10.2.1 发布
1 min read

ESLint v10.2.1 发布

我们刚刚发布了 ESLint v10.2.1,这是 ESLint 的一个补丁版本升级。本次发布修复了上一版本中发现的几个错误。

ESLint v10.2.0 发布
2 min read

ESLint v10.2.0 发布

我们刚刚发布了 ESLint v10.2.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。