ESLint v9.0.0-beta.2 发布

我们刚刚发布了 ESLint v9.0.0-beta.2,这是 ESLint 的一次重大版本升级。此次发布增加了一些新功能,并修复了前一个版本中发现的几个错误。此次发布还有一些破坏性更改,因此请仔细阅读以下内容。

亮点

🌐 Highlights

这是本版本 ESLint 中你需要了解的主要更改的总结。

🌐 This is a summary of the major changes you need to know about for this version of ESLint.

正在安装

🌐 Installing

由于这是预发布版本,npm 不会自动升级。安装时必须指定 next 标签:

🌐 Since this is a pre-release version, you will not automatically be upgraded by npm. You must specify the next tag when installing:

npm i eslint@next --save-dev

你也可以直接指定版本:

🌐 You can also specify the version directly:

npm i eslint@9.0.0-beta.2 --save-dev

迁移指南

🌐 Migration Guide

由于有很多变化,我们创建了一个 迁移指南,详细描述了重大更改以及你应该采取的应对步骤。我们预计大多数用户应该能够在不更改构建的情况下升级,但如果遇到问题,迁移指南应该是一个有用的资源。

🌐 As there are a lot of changes, we’ve created a migration guide describing the breaking changes in great detail along with the steps you should take to address them. We expect that most users should be able to upgrade without any build changes, but the migration guide should be a useful resource if you encounter problems.

对于同一规则的多个 /* eslint */ 注释现在不被允许

🌐 Multiple /* eslint */ comments for the same rule are now disallowed

在 ESLint v8.x 中,如果被 lint 的文件包含针对同一规则的多个 /* eslint */ 配置注释,将会应用最后一个注释,而其他注释将被默默忽略。

🌐 In ESLint v8.x, if the file being linted contained multiple /* eslint */ configuration comments for the same rule, the last one would be applied, while the others would be silently ignored.

在 ESLint v9.0.0 中,第一个会被应用,而其他的会被报告为 lint 错误。

🌐 In ESLint v9.0.0, the first one is applied, while the others are reported as lint errors.

新功能

🌐 New Features

  • no-restricted-imports 规则有了新的选项 allowImportNamesallowImportNamePattern
  • no-unused-vars 规则有一个新选项 ignoreClassWithStaticInitBlock
  • complexity 规则现在还考虑了可选链和解构模式及参数中的默认值。

重大更改

🌐 Breaking Changes

  • 79a95eb feat!: 禁止对同一规则使用多个配置注释 (#18157) (Milos Djermanovic)

特性

🌐 Features

错误修复

🌐 Bug Fixes

  • e37153f 修复:改进无效规则配置的错误信息 (#18147) (Nitin Kumar)
  • af6e170 修复:在发生错误后停止对文件进行 lint (#18155) (Francesco Trotta)

文档

🌐 Documentation

  • ba1c1bb 文档:更新自述文件(GitHub Actions 机器人)
  • 337cdf9 文档:解释 RuleTester 修复测试的限制 (#18175) (Nicholas C. Zakas)
  • c7abd89 文档:解释 Node.js 版本支持 (#18176) (Nicholas C. Zakas)
  • d961eeb 文档:在规则文档的示例中显示红色下划线 (#18041) (太田洋介)
  • 558274a 文档:更新自述文件(GitHub Actions 机器人)
  • 2908b9b 文档:更新发布文档 (#18174) (Nicholas C. Zakas)
  • 1f1260e 文档:将 HackerOne 链接替换为 GitHub 公告 (#18165) (Francesco Trotta)
  • e5ef3cd 文档:在 no-fallthrough 中添加内联用例条件 (#18158) (Tanuj Kanti)
  • 450d0f0 文档:修复 ignore 选项文档 (#18154) (Francesco Trotta)

杂项

🌐 Chores

  • 7509276 事务: 升级 @eslint/js@9.0.0-beta.2 (#18180) (Milos Djermanovic)
  • 96087b3 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • 925afa2 杂务:移除 lodash.merge 的一些使用 (#18179) (Milos Djermanovic)
  • 972ef15 杂项:移除 @eslint/js 中的无效类型 (#18164) (Nitin Kumar)

最新的 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 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。