
发布于: 公告 5 分钟阅读
我们刚刚推送了 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
规则现在完全支持对象解构模式。01557ce
feat: 实现 Language#normalizeLanguageOptions() (#19104) (Nicholas C. Zakas)2edc0e2
feat: 添加 meta.defaultOptions (#17656) (Josh Goldberg ✨)bdec50e
feat: 修复 no-useless-computed-key
规则在 __proto__
中的误报 (#19123) (Milos Djermanovic)3087c9e
feat: 向 @eslint/js
插件添加 meta
对象 (#19095) (Francesco Trotta)fd33f13
fix: 更新 no-restricted-imports
规则的类型定义 (#19060) (Nitin Kumar)bd35098
fix: 切换掉 Node.js 的 node:assert 和 AssertionError (#19082) (Josh Goldberg ✨)9db5b15
fix: no-lonely-if
规则的不安全报告 (#19087) (Abraham Guo)68fa497
fix: 忽略 Windows 上不同驱动器上的文件 (#19069) (Francesco Trotta)4ce625a
fix: 升级 @humanwhocodes/retry@0.4.1 以避免调试日志 (#19102) (Milos Djermanovic)d927920
docs: 修复无 JS 模式下的样式 (#18916) (Tanuj Kanti)09bc2a8
docs: 更新 README (GitHub Actions Bot)39089c8
docs: 添加 no-useless-computed-key
规则使用对象模式的示例 (#19109) (Milos Djermanovic)895c60f
docs: 添加缺失的 messageId 属性和 suggestion 属性 (#19122) (fnx)298625e
docs: 更改 CLI -c 参数以使用扁平配置 (#19103) (Nicholas C. Zakas)522d8a3
docs: 添加关于 indent
, quotes
和 semi
规则类型的弃用说明 (#19090) (Marco Pasqualetti)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 新闻、案例研究、教程和资源。