
亮点
🌐 Highlights
配置对象中的 basePath 属性
🌐 basePath property in config objects
配置对象现在可以包含新的 basePath 属性,用于指定配置对象应应用到的子目录的路径。如果配置对象具有 basePath 属性,则 files 和 ignores 中指定的模式将相对于 basePath 所表示的子目录进行评估。这使得编写针对项目内特定目录的配置对象更容易。
🌐 Config objects can now include the new basePath property to specify the path to a subdirectory to which the config object should apply to. If a config object has a basePath property, patterns specified in files and ignores are evaluated relative to the subdirectory represented by basePath. This makes it easier to write config objects that target a particular directory inside your project.
// eslint.config.js
import { defineConfig } from "eslint/config";
import js from "@eslint/js";
export default defineConfig([
{
basePath: "packages/hello-base-path",
plugins: { js },
extends: ["js/recommended"],
ignores: ["coverage/**", "dist/**"],
},
]);
你可以在 the documentation 中阅读关于配置对象中基本路径的更多信息。
🌐 You can read more about base paths in config objects in the documentation.
稳定的功能开关 v10_config_lookup_from_file
🌐 Stable feature flag v10_config_lookup_from_file
随着在配置对象中添加了 basePath 属性,ESLint v9.12.0 中引入的 实验性配置文件解析 已经最终确定。它将在 ESLint 的下一个主要版本中成为默认行为。因此,功能标志 unstable_config_lookup_from_file 已重命名为 v10_config_lookup_from_file。旧的标志名称仍然有效,所以如果你在设置中已经使用了 unstable_config_lookup_from_file,则无需采取任何操作。
🌐 With the addition of the basePath property in config objects, the experimental configuration file resolution introduced in ESLint v9.12.0 has been finalized. It will become the default behavior in the next major release of ESLint. Accordingly, the feature flag unstable_config_lookup_from_file has been renamed to v10_config_lookup_from_file. The old flag name still works, so if you are already using unstable_config_lookup_from_file in your setup, you don’t need to take any action.
no-duplicate-imports 中的新 allowSeparateTypeImports 选项
🌐 New allowSeparateTypeImports option in no-duplicate-imports
通过新的选项 allowSeparateTypeImports,no-duplicate-imports 规则现在可以配置为将 import 和 import type 视为不同的用法,即使它们指定了相同的模块。
🌐 With the new option allowSeparateTypeImports, the no-duplicate-imports rule can now be configured to treat import and import type as separate usages, even if they specify the same module.
/*eslint no-duplicate-imports: ["error", { "allowSeparateTypeImports": false }]*/
import { someValue } from 'module';
import type { SomeType } from 'module';
其他显著变化
🌐 Other notable changes
SourceCode方法getIndexFromLoc现在会抛出错误,如果参数为column属性指定了负值。
特性
🌐 Features
52a5fca功能:在配置对象中支持basePath属性 (#19879) (Milos Djermanovic)4ab4482功能:向no-duplicate-imports添加allowSeparateTypeImports选项 (#19872) (sethamus)b8a7e7a功能:当getIndexFromLoc中的列为负数时抛出错误 (#19831) (루밀LuMir)
错误修复
🌐 Bug Fixes
6a0f164修复:在getIndexFromLoc方法中处理null类型的loc(#19862) (루밀LuMir)3fbcd70修复:更新no-restricted-properties的错误信息 (#19855) (Tanuj Kanti)7ef4cf7修复:从修复中移除不必要的分号 (#19857) (Francesco Trotta)7dabc38修复:在--env-info中使用process.version(#19865) (TKDev7)
文档
🌐 Documentation
8662ed1文档:采用与 eslint 风格子包相关的更改 (#19887) (ntnyq)20158b0文档:未使用变量处理的注释中的拼写错误 (#19870) (leopardracer)ebfb5b4文档:修复 configuration-files.md 中的拼写错误 (#19873) (0-20)4112fd0文档:澄清布尔值仍然允许用于规则meta.deprecated(#19866) (Bryan Mishkin)
杂项
🌐 Chores
