
亮点
🌐 Highlights
no-restricted-properties 的 allowObjects 选项
🌐 allowObjects option for no-restricted-properties
此版本为 no-restricted-properties 规则添加了一个新选项 allowObjects。allowObjects 选项允许你在全局范围内限制某个属性,但允许特定对象使用它。
🌐 This release adds a new option allowObjects to the no-restricted-properties rule. The allowObjects option allows you to restrict a property globally but allow specific objects to use it.
/* eslint no-restricted-properties: ["error", { "property": "push", "allowObjects": ["router", "history"] } ] */
router.push('/home'); // allowed
history.push('/about'); // allowed
myArray.push("/info"); // not allowed
核心规则中的 TypeScript 语法支持
🌐 TypeScript Syntax Support in Core Rules
正如在 ESLint v9.23.0 发布博客文章 中宣布的那样,我们正在积极努力将 TypeScript 语法支持添加到核心规则中。
🌐 As announced in the ESLint v9.23.0 release blog post, we are actively working to add TypeScript syntax support to core rules.
ESLint v9.25.0 为另外四个核心规则引入了完整的 TypeScript 语法支持。这些规则是:
🌐 ESLint v9.25.0 introduces full TypeScript syntax support for four more core rules. These rules are:
[no-empty-function](/docs/latest/rules/no-empty-function)。此规则在allow数组中具有新的 TypeScript 特定选项:"privateConstructors"、"protectedConstructors"、"decoratedFunctions"和"overrideMethods"。no-invalid-this.no-loop-func.no-unused-expressions.
这些规则现在可以用于检查 TypeScript 文件以及常规 JavaScript 文件。
要检查 TypeScript 代码,请确保使用 @typescript-eslint/parser 或其他兼容的解析器。
🌐 These rules can now be used to lint TypeScript files as well as regular JavaScript.
To lint TypeScript code, be sure to use @typescript-eslint/parser, or another compatible parser.
特性
🌐 Features
dcd95aa功能:在 no-empty-function 规则中支持 TypeScript 语法 (#19551) (sethamus)77d6d5b功能:在no-unused-expressions中支持 TS 语法 (#19564) (Sweta Tanwar)90228e5功能:支持JSRuleDefinition类型 (#19604) (루밀LuMir)59ba6b7功能:为 no-restricted-properties 添加 allowObjects 选项 (#19607) (sethamus)db650a0功能:在no-invalid-this规则中支持 TypeScript 语法 (#19532) (Tanuj Kanti)9535cff功能:在no-loop-func中支持 TS 语法 (#19559) (Nitin Kumar)
错误修复
🌐 Bug Fixes
文档
🌐 Documentation
ca7a735文档:更新no-undef-init关于何时不使用的部分 (#19624) (Tanuj Kanti)1b870c9文档:在入门指南中使用eslint-config-xo(#19629) (Nitin Kumar)5d4af16文档:为多条规则选项添加类型 (#19616) (Tanuj Kanti)e8f8d57文档:更新自述文件(GitHub Actions 机器人)a40348f文档: no-use-before-define 调整 (#19622) (Kirk Waiblinger)0ba3ae3文档:更新自述文件(GitHub Actions 机器人)865dbfe文档:确保“了解更多”弃用链接指向有用的资源 (#19590) (Kirk Waiblinger)f80b746文档:为 no-self-compare 添加已知限制 (#19612) (Nitin Kumar)865aed6文档:更新自述文件(GitHub Actions 机器人)
杂项
🌐 Chores
88dc196杂务:升级 @eslint/js@9.25.0 (#19636) (Milos Djermanovic)345288d事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)affe6be杂务:升级干线 (#19628) (sethamus)dd20cf2测试:修复no-loop-func测试中的重复变量报告 (#19610) (Milos Djermanovic)bd05397事务: 升级@eslint/*依赖 (#19606) (Milos Djermanovic)22ea18b修复:在 JSDocs 中将无效的int类型替换为number。(#19597) (Arya Emami)
