ESLint v9.30.0 发布

我们刚刚发布了 ESLint v9.30.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。

亮点

🌐 Highlights

配置对象中的 basePath 属性

🌐 basePath property in config objects

配置对象现在可以包含新的 basePath 属性,用于指定配置对象应应用到的子目录的路径。如果配置对象具有 basePath 属性,则 filesignores 中指定的模式将相对于 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

通过新的选项 allowSeparateTypeImportsno-duplicate-imports 规则现在可以配置为将 importimport 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

错误修复

🌐 Bug Fixes

文档

🌐 Documentation

杂项

🌐 Chores

  • 2b6491c 任务: 升级到 @eslint/js@9.30.0 (#19889) (Francesco Trotta)
  • 5a5d526 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • eaf8a41 杂务:修复 linter 测试中的拼写错误 (#19878) (kilavvy)

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

ESLint v10.3.0 发布
1 min read

ESLint v10.3.0 发布

我们刚刚发布了 ESLint v10.3.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。

ESLint v10.2.1 发布
1 min read

ESLint v10.2.1 发布

我们刚刚发布了 ESLint v10.2.1,这是 ESLint 的一个补丁版本升级。本次发布修复了上一版本中发现的几个错误。

ESLint v10.2.0 发布
2 min read

ESLint v10.2.0 发布

我们刚刚发布了 ESLint v10.2.0,这是 ESLint 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。