ESLint v9.15.0 发布

我们刚刚推送了 ESLint v9.15.0,这是一个 ESLint 的小版本升级。此版本添加了一些新功能,并修复了先前版本中发现的几个错误。

此版本将 @eslint/plugin-kit 依赖项更新到最新版本 0.2.3,其中包括针对安全公告 GHSA-7q7g-4xm8-89cq 的修复。

亮点

meta.defaultOptions

规则现在可以指定默认选项。ESLint 将递归地合并用户提供的选项元素到默认元素之上。

此功能使规则中的选项更易于使用。

// my-rule.js
export default {
meta: {
defaultOptions: [{
alias: "basic",
ignoreClassFields: false
}],
schema: [{
type: "object",
properties: {
alias: {
type: "string"
},
ignoreClassFields: {
type: "boolean"
}
},
additionalProperties: false
}]
},
create(context) {

// `context.options` is guaranteed to be an array with a single object
// that has a string property `alias` and a boolean property `ignoreClassFields`.
// If the rule is enabled with no options specified in the configuration file,
// `alias` will be `"basic"`, and `ignoreClassFields` will be `false`.
const [{ alias, ignoreClassFields }] = context.options;

return { /* ... */ };
}
};

此功能还允许文档生成器、其他工具和集成以及最终用户轻松找到规则的默认选项。

其他值得注意的更改

  • 自定义语言现在可以提供 normalizeLanguageOptions(languageOptions) 方法。返回值将在调用 parse()createSourceCode()applyLanguageOptions() 方法时用作 languageOptions,并在规则中用作 context.languageOptions 属性的值。
  • no-useless-computed-key 规则现在完全支持对象解构模式。

新特性

Bug 修复

文档

构建

  • 2967d91 chore: 升级 @eslint/js@9.15.0 (#19133) (Milos Djermanovic)
  • b441bee chore: package.json 更新,用于 @eslint/js 发布 (Jenkins)
  • 7d6bf4a chore: 升级 @eslint/core@0.9.0 (#19131) (Milos Djermanovic)
  • 902e707 chore: 升级 @eslint/plugin-kit@0.2.3 (#19130) (Milos Djermanovic)
  • 5ff6c1d chore: bump cross-spawn (#19125) (Ian Bobinac)
  • cceccc7 chore: 更新依赖 @eslint/json 到 ^0.6.0 (#19117) (renovate[bot])
  • 0da3f73 chore: 更新 algolia referrer (#19114) (Strek)
  • 4f08332 ci: 取消固定 trunk-io/trunk-action 版本 (#19108) (Francesco Trotta)
  • 6b75683 perf: 通过将正则表达式替换为 trimEnd 来优化 text-table (#19061) (Nitin Kumar)

最新的 ESLint 新闻、案例研究、教程和资源。

Evolving flat config with extends
5 分钟阅读

通过 extends 演进扁平配置

您的 eslint.config.js 文件现在可以使用 extends 来简化您的配置。

ESLint v9.22.0 released
1 分钟阅读

ESLint v9.22.0 发布

我们刚刚推送了 ESLint v9.22.0,这是一个 ESLint 的小版本升级。此版本添加了一些新功能,并修复了先前版本中发现的几个错误。

ESLint v9.21.0 released
2 分钟阅读

ESLint v9.21.0 发布

我们刚刚推送了 ESLint v9.21.0,这是一个 ESLint 的小版本升级。此版本添加了一些新功能,并修复了先前版本中发现的几个错误。