ESLint v9.25.0 发布

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

亮点

🌐 Highlights

no-restricted-propertiesallowObjects 选项

🌐 allowObjects option for no-restricted-properties

此版本为 no-restricted-properties 规则添加了一个新选项 allowObjectsallowObjects 选项允许你在全局范围内限制某个属性,但允许特定对象使用它。

🌐 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

错误修复

🌐 Bug Fixes

  • 910bd13 修复:nodeTypeKey 未在 NodeEventGenerator 中使用 (#19631) (StyleShit)

文档

🌐 Documentation

杂项

🌐 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)

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