
亮点
🌐 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规则有了新的选项allowImportNames和allowImportNamePattern。no-unused-vars规则有一个新选项ignoreClassWithStaticInitBlock。complexity规则现在还考虑了可选链和解构模式及参数中的默认值。
重大更改
🌐 Breaking Changes
特性
🌐 Features
1c173dc功能:向no-unused-vars添加ignoreClassWithStaticInitBlock选项 (#18170) (Tanuj Kanti)a451b32功能:使no-misleading-character-class报告更详细的错误 (#18082) (Francesco Trotta)c49ed63功能:更新复杂性规则以支持可选链和默认值 (#18152) (Mathias Schreck)11144a2功能:no-restricted-imports选项已添加allowImportNames(#16196) (M Pater)
错误修复
🌐 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
