ESLint v9.15.0 发布

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

此版本将 @eslint/plugin-kit 依赖更新到最新的 0.2.3 版本,其中包括针对安全公告 GHSA-7q7g-4xm8-89cq 的修复。

🌐 This release updates the @eslint/plugin-kit dependency to the latest version 0.2.3 which includes the fix for security advisory GHSA-7q7g-4xm8-89cq.

亮点

🌐 Highlights

meta.defaultOptions

规则现在可以指定默认选项。ESLint 将递归地将任何用户提供的选项元素合并到默认元素之上。

🌐 Rules can now specify default options. ESLint will recursively merge any user-provided options elements on top of the default elements.

此功能使在规则中处理选项变得更容易。

🌐 This feature makes it easier to work with options in rules.

// 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 { /* ... */ };
    }
};

此功能还允许文档生成器、其他工具和集成以及终端用户轻松找到规则的默认选项。

🌐 This feature also allows document generators, other tools and integrations, and end users to easily find the default options for rules.

其他显著变化

🌐 Other notable changes

  • 自定义语言现在可以提供 normalizeLanguageOptions(languageOptions) 方法。返回值在调用 parse()createSourceCode()applyLanguageOptions() 方法时将用作 languageOptions,并作为规则中 context.languageOptions 属性的值。
  • 现在 no-useless-computed-key 规则完全支持对象解构模式。

特性

🌐 Features

错误修复

🌐 Bug Fixes

文档

🌐 Documentation

杂项

🌐 Chores

  • 2967d91 杂务:升级 @eslint/js@9.15.0 (#19133) (Milos Djermanovic)
  • b441bee 事务:更新 package.json 以适配 @eslint/js 版本发布(Jenkins)
  • 7d6bf4a 杂务:升级 @eslint/core@0.9.0 (#19131) (Milos Djermanovic)
  • 902e707 杂务: 升级 @eslint/plugin-kit@0.2.3 (#19130) (Milos Djermanovic)
  • 5ff6c1d 杂务:升级 cross-spawn (#19125) (Ian Bobinac)
  • cceccc7 杂项:将依赖 @eslint/json 更新到 ^0.6.0 (#19117) (renovate[bot])
  • 0da3f73 杂务:更新 Algolia 推荐来源 (#19114) (Strek)
  • 4f08332 ci:取消固定 trunk-io/trunk-action (#19108) (Francesco Trotta)
  • 6b75683 性能:通过用 trimEnd 替换正则表达式来优化 text-table (#19061) (Nitin Kumar)

最新的 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 的一次小版本升级。此版本添加了一些新功能,并修复了上一版本中发现的几个错误。