
发布于: 发布说明 阅读 2 分钟
我们刚刚发布了 ESLint v9.16.0,这是一个 ESLint 的次要版本升级。此版本添加了一些新功能,并修复了先前版本中发现的几个错误。
sort-keys
规则的 ignoreComputedKeys
选项此版本为 sort-keys
规则添加了一个新的布尔型选项 ignoreComputedKeys
。ignoreComputedKeys
通过将计算键视为组分隔符而不是组的一部分,允许对具有非计算名称的属性进行更一致的排序。以下示例显示了在没有 ignoreComputedKeys
选项的情况下对象字面量中属性的预期排序。
使用 ignoreComputedKeys: false
(默认)
const obj = { a: 10, b: 20, [c]: 7.5, d: 15 };
当 ignoreComputedKeys
设置为 true
时,计算键 c
可以出现在字面量的任何位置,只要其他属性组已排序即可。
使用 ignoreComputedKeys: true
const obj = { a: 10, b: 20, [c]: 7.5, d: 15 };
或
const obj = { d: 15, [c]: 7.5, a: 10, b: 20 };
或
const obj = { a: 10, b: 20, d: 15, [c]: 7.5 };
等等。
no-restricted-syntax
此版本中的另一个增强功能是能够将 no-restricted-syntax
规则与任何语言一起使用。这在以前的版本中已经可以实现,但现在官方支持并记录了与语言插件一起使用。
使用 @eslint/json
插件检查 JSON 文件时,警告使用 null
的配置可能如下所示
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 选择器 限制项目中的语法,但您不确定哪些节点表示特定的代码,我们建议您使用 代码浏览器。
9eefc8f
docs: 修复 use-isnan
中的错别字 (#19190) (루밀LuMir)0c8cea8
docs: 更改 no-unreachable
中单词的顺序 (#19189) (루밀LuMir)0c19417
docs: 为 no-async-promise-executor
添加缺少的反引号 (#19188) (루밀LuMir)8df9276
docs: 在 no-compare-neg-zero
的 description
中的 -0
添加反引号 (#19186) (루밀LuMir)7e16e3f
docs: 修复 sort-keys
的 caseSensitive
选项的标题 (#19183) (Tanuj Kanti)0c6b842
docs: 修复 migration-guide.md
中的错别字 (#19180) (루밀LuMir)353266e
docs: 修复 debug.md
中的错别字 (#19179) (루밀LuMir)5ff318a
docs: 删除 nodejs-api
中不必要的水平线 (---
) (#19175) (루밀LuMir)576bcc5
docs: 将更多规则标记为由 TypeScript 处理 (#19164) (Tanuj Kanti)742d054
docs: 注意 no-restricted-syntax
可与任何语言一起使用 (#19148) (Milos Djermanovic)feb703b
chore: 升级到 @eslint/[email protected]
(#19195) (Francesco Trotta)df9bf95
chore: 更新 @eslint/js 版本的 package.json (Jenkins)f831893
chore: 为 sort-keys
规则的 ignoreComputedKeys
选项添加类型 (#19184) (Tanuj Kanti)3afb8a1
chore: 将 @eslint/json 依赖项更新为 ^0.8.0 (#19177) (Milos Djermanovic)1f77c53
chore: 将 repository.directory
属性添加到 package.json
(#19165) (루밀LuMir)d460594
chore: 将 @arethetypeswrong/cli 依赖项更新为 ^0.17.0 (#19147) (renovate[bot])45cd4ea
refactor: 更新规则中的默认选项 (#19136) (Milos Djermanovic)最新的 ESLint 新闻、案例研究、教程和资源。