
亮点
🌐 Highlights
sort-keys 的 ignoreComputedKeys 选项
🌐 ignoreComputedKeys option for sort-keys
此版本为 sort-keys 规则添加了一个新的布尔选项 ignoreComputedKeys。
ignoreComputedKeys 通过将计算键视为组分隔符而不是组的一部分,从而允许对非计算名称的属性进行更一致的排序。
以下示例显示在没有 ignoreComputedKeys 选项的情况下,对对象字面量中的属性进行排序的预期结果。
🌐 This release adds a new boolean option ignoreComputedKeys to the sort-keys rule.
ignoreComputedKeys allows a more consistent sorting of properties with non-computed names by treating computed keys as group separators rather than part of a group.
The following example shows the expected sorting of properties in an object literal without the ignoreComputedKeys option.
使用 ignoreComputedKeys: false(默认)
const obj = { a: 10, b: 20, [c]: 7.5, d: 15 };
当 ignoreComputedKeys 设置为 true 时,计算出的键 c 可以出现在字面量中的任何位置,只要其他属性组是有序的。
🌐 When ignoreComputedKeys is set to true, the computed key c can appear anywhere in the literal, as long as the other groups of properties are sorted.
使用 ignoreComputedKeys: true
const obj = { a: 10, b: 20, [c]: 7.5, d: 15 };
or
const obj = { d: 15, [c]: 7.5, a: 10, b: 20 };
or
const obj = { a: 10, b: 20, d: 15, [c]: 7.5 };
etc.
与语言无关的 no-restricted-syntax
🌐 Language-agnostic no-restricted-syntax
此版本的另一个改进是能够将no-restricted-syntax规则用于任何语言。 这在以前的版本中已经可能,但现在官方支持并记录了语言插件的使用。
🌐 Another enhancement in this release is the ability to use the no-restricted-syntax rule with any language.
This was already possible in previous releases, but now usage with language plugins is officially supported and documented.
在使用 @eslint/json 插件对 JSON 文件进行 lint 时,一个关于 null 使用发出警告的配置可能如下所示:
🌐 When linting JSON files with the @eslint/json plugin, a config that warns about the usage of null could look like this:
import json from "@eslint/json";
export default [
{
files: ["**/*.json"],
language: "json/json",
plugins: {
json,
},
rules: {
"no-restricted-syntax": [
"warn",
"Null" // AST selector for `null`
],
},
},
];
如果你希望基于 AST 选择器 限制项目中的语法,但不确定哪些节点代表特定代码,我们建议使用 代码浏览器。
🌐 If you would like to restrict syntax in your project based on AST selectors but you’re unsure what nodes represent a particular code, we recommend using Code Explorer.
特性
🌐 Features
文档
🌐 Documentation
9eefc8f文档:修复use-isnan中的拼写错误 (#19190) (루밀LuMir)0c8cea8文档:切换no-unreachable中单词的顺序 (#19189) (루밀LuMir)0c19417文档:给no-async-promise-executor添加缺失的反引号 (#19188) (루밀LuMir)8df9276文档:在no-compare-neg-zero的description中的-0添加反引号 (#19186) (루밀LuMir)7e16e3f文档:修复sort-keys的caseSensitive选项标题 (#19183) (Tanuj Kanti)0c6b842文档:修复migration-guide.md中的拼写错误 (#19180) (루밀LuMir)353266e文档:修复debug.md中的拼写错误 (#19179) (루밀LuMir)5ff318a文档:删除nodejs-api中不必要的水平分隔线(---) (#19175) (루밀LuMir)576bcc5文档:将更多规则标记为 TypeScript 处理 (#19164) (Tanuj Kanti)742d054文档:请注意no-restricted-syntax可以与任何语言一起使用 (#19148) (Milos Djermanovic)
杂项
🌐 Chores
feb703b事务: 升级到@eslint/js@9.16.0(#19195) (Francesco Trotta)df9bf95事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)f831893事务:为sort-keys的ignoreComputedKeys选项添加类型 (#19184) (Tanuj Kanti)3afb8a1杂项:将依赖 @eslint/json 更新到 ^0.8.0 (#19177) (Milos Djermanovic)1f77c53杂项:向package.json添加repository.directory属性 (#19165) (루밀LuMir)d460594事务:将依赖 @arethetypeswrong/cli 更新到 ^0.17.0 (#19147) (renovate[bot])45cd4ea重构:更新规则中的默认选项 (#19136) (Milos Djermanovic)
