
亮点
🌐 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.0 --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.
规则选项的新默认值
🌐 New default values for rule options
在 v9.0.0 中,以下规则有了新的默认值:
🌐 In v9.0.0, the following rules have new defaults:
no-unused-vars:caughtErrors选项的默认值已从"none"更改为"all"。no-useless-computed-key:enforceForClassMembers选项的默认值已从false更改为true。
更严格的 RuleTester 验证
🌐 Stricter RuleTester validations
此版本在 RuleTester 中增加了更多检查:
🌐 This release adds more checks in RuleTester:
- 消息不能有未替换的占位符。
- 建议必须更改代码。
- 测试用例
output必须不同于code。 - 测试错误对象必须指定
message或messageId。 - 如果实际错误提供了建议,则测试错误对象必须指定
suggestions。 - 测试建议对象必须指定
desc或messageId。 - 测试建议对象必须指定
output。 filename和only测试对象的属性必须是预期的类型(分别为string和boolean)。
新 API loadESLint()
🌐 New API loadESLint()
ESLint 现在从其主入口点导出一个新的函数 loadESLint()。集成可以使用此函数获取 ESLint 类(原来的 FlatESLint 类)或 LegacyESLint 类(原来的 ESLint 类),从而轻松在 flat 配置和 eslintrc API 之间切换。
🌐 ESLint now exports a new function loadESLint() from its main entry point. Integrations can use this function to get either the ESLint class (former FlatESLint class) or the LegacyESLint class (former ESLint class) and thus easily swap between flat config and eslintrc APIs.
重大更改
🌐 Breaking Changes
9163646增强功能!:规则测试器检查消息中缺失的占位符数据 (#18073) (fnx)3c4d51d特性!:no-useless-computed-key中enforceForClassMembers的默认值 (#18054) (Francesco Trotta)47e60f8功能更新!: 更严格的规则测试验证 (#17654) (fnx)1a94589功能更新!:no-unused-vars将默认 caughtErrors 设置为 ‘all’ (#18043) (Josh Goldberg ✨)
特性
🌐 Features
53f0f47功能:为 v9 添加 loadESLint() API 方法 (#18097) (Nicholas C. Zakas)2d11d46功能:在二进制表达式中向use-isnan添加建议 (#17996) (StyleShit)
错误修复
🌐 Bug Fixes
文档
🌐 Documentation
f1c7e6f文档:切换到道德广告 (#18090) (Strek)15c143f文档:JS Foundation -> OpenJS Foundation 在 PR 模板中 (#18092) (Nicholas C. Zakas)6ea339e文档:在 v9 迁移指南中添加更严格的规则测试验证 (#18085) (Milos Djermanovic)3c816f1文档:从 CLI 使用相对链接到核心概念 (#18083) (Milos Djermanovic)9458735文档:修复规则示例中格式错误的eslint配置注释 (#18078) (Francesco Trotta)07a1ada文档:从--fixCLI 文档链接到相关核心概念 (#18080) (Bryan Mishkin)b844324文档:更新团队职责 (#18048) (Nicholas C. Zakas)aadfb60文档:记录 context 的 languageOptions 及其他 v9 变更 (#18074) (fnx)857e242文档:调整 meta.docs 规则属性的说明 (#18057) (Bryan Mishkin)10485e8文档:建议使用 messageId 而不是 message 来报告规则违规 (#18050) (Bryan Mishkin)98b5ab4文档:更新自述文件(GitHub Actions 机器人)505fbf4文档:更新no-restricted-imports规则 (#18015) (Tanuj Kanti)c25b4af文档:更新自述文件(GitHub Actions 机器人)
杂项
🌐 Chores
e40d1d7事务:升级 @eslint/js@9.0.0-beta.0 (#18108) (Milos Djermanovic)9870f93事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)2c62e79事务:升级 @eslint/eslintrc@3.0.1 (#18107) (Milos Djermanovic)81f0294杂项:升级 espree@10.0.1 (#18106) (Milos Djermanovic)5e2b292杂项:升级 eslint-visitor-keys@4.0.0 (#18105) (Milos Djermanovic)ce838ad事务:用 npm-run-all2 ^5.0.0 替换依赖 npm-run-all (#18045) (renovate[bot])54df731杂务:将依赖 markdownlint-cli 更新到 ^0.39.0 (#18084) (renovate[bot])8f06a60杂务: 更新依赖 shelljs 至 ^0.8.5 (#18079) (Francesco Trotta)93ffe30事务:将依赖 file-entry-cache 更新到 v8 (#17903) (renovate[bot])
