ESLint v9.17.0 发布

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

亮点

🌐 Highlights

no-unused-vars 建议

🌐 no-unused-vars Suggestions

[no-unused-vars](https://eslint.nodejs.cn/docs/latest/rules/no-unused-vars) 规则现在提供了 建议!当规则检测到像这样的未使用变量时:

🌐 The no-unused-vars rule provides suggestions now! When the rule sees code with an unused variable like this:

const a = "Hello";
const b = "World!";
console.log(a);

现在它会建议删除未使用的变量声明:

🌐 It will now suggest removing the unused variable declaration:

const a = "Hello";

console.log(a);

建议也适用于更复杂的情况,如未使用的函数参数、解构语法等。

🌐 Suggestions also work for more complex cases like unused function arguments, destructuring syntax, etc.

function avg(a, b, c) {
    return (a + b) / 2;
}

console.log(avg(12, 13, 25));

在应用建议之后变为:

🌐 after the suggestion is applied becomes:

function avg(a, b) {
    return (a + b) / 2;
}

console.log(avg(12, 13, 25));

and

const [{ status, value, reason }] = await Promise.allSettled([promise1, promise2]);

if (status === "rejected") {
    throw reason;
}

在建议变为之后:

🌐 after the suggestion becomes:

const [{ status, reason }] = await Promise.allSettled([promise1, promise2]);

if (status === "rejected") {
    throw reason;
}

no-unused-vars 建议标志着数月工作的完成。我们很可能会在未来的更新中进一步改进和微调此功能。

允许空值 message.fix

🌐 Nullish message.fix Allowed

以前,如果一个 处理器 返回了一个 LintMessage 并且 fix 属性被设置为 undefinednull,在尝试应用自动修复时,ESLint 会因一个无用的错误信息而崩溃。这个问题在当前版本中已经修复。

🌐 Previously, if a processor returned a LintMessage with a fix property set to undefined or null, ESLint would crash with an unhelpful error message when trying to apply the autofix. This problem has been fixed in the current release.

特性

🌐 Features

错误修复

🌐 Bug Fixes

文档

🌐 Documentation

杂项

🌐 Chores

  • cc243c9 任务: 升级到 @eslint/js@9.17.0 (#19242) (Francesco Trotta)
  • 84c5787 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • 4c4f53b 事务:为 flags.js 添加缺失的反引号 (#19226) (루밀LuMir)
  • 4b3132c 杂务: 更新依赖 eslint-plugin-expect-type 到 ^0.6.0 (#19221) (renovate[bot])
  • 9bf2204 杂项:为 eslint-config-eslint 包添加类型定义 (#19050) (Arya Emami)
  • ee8c220 事务: 修复 integration-tutorial-code 中错误的 name 属性 (#19218) (루밀LuMir)
  • cca801d 杂项:将 cross-spawn 升级到 7.0.6 (#19185) (folortin)

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