@automattic/eslint-config-target-es

中文文档
7.0.0发布于 2026/09/18MITCommonJS构建来源已验证近 30 天下载 7.2万

ESLint sharable config to activate eslint-plugin-es-x checks based on browserslist targets.

原始使用文档
文档目录7 节
  1. Installation
  2. Usage
  3. Checking built files
  4. Advanced usage
  5. Caveats
  6. Security
  7. License

eslint-config-target-es

ESLint shareable config to activate eslint-plugin-es-x checks based on browserslist browser targets and MDN browser compatibility data.

Installation

Generally you'll install this via your package manager, e.g.

npm install --save-dev eslint eslint-plugin-es-x @automattic/eslint-config-target-es

Usage

First, you'll probably want to set up a browserslist configuration.

Then you can use this like any other sharable config in your eslint.config.js or .eslintrc.* file. Three configurations are offered.

  • To check only for language features, such as nullish coalescing, use the 'language' config.
  • To check only for builtins, such as Promise, WeakRef, and various features of RegExp, use the 'builtins' config.
  • To check both, use the 'all' config.

For eslint.config.js, that might look like this:

import eslintConfigTargetEs from '@automattic/eslint-config-target-es/flat/language';

export default [
    eslintConfigTargetEs,
    // etc
];

while for eslintrc you'd do like

{
    extends: [ '@automattic/eslint-config-target-es/rc/language' ],
}

For backwards compatibility, the eslintrc configs may also be accessed without the /rc/ path component (e.g. as @automattic/eslint-config-target-es/language), and @automattic/eslint-config-target-es is equivalent to @automattic/eslint-config-target-es/rc/all.

Checking built files

If you want to check your built files to make sure you didn't omit transpiling any packages that need transpiling, you might create a validate-es.config.js like this

module.exports = {
    root: true,
    extends: [ '@automattic/eslint-config-target-es/rc/language' ],
    env: {
        // Whatever environments you need.
    },
};

and then run eslint like

eslint --no-eslintrc --no-inline-config --config validate-es.config.js --no-ignore build/

to avoid your standard eslintrc and eslintignore and to avoid errors from any inline directives.

Something similar can be done for flat config.

Advanced usage

You can import or require @automattic/eslint-config-target-es/functions to gain access to some functions that can be used to build your own configuration.

As browserslist and MDN use different browser codes, getAllBrowsers( { query: } ) will take a browserslist query and return an object with the MDN browser codes and the matched versions for each.

getRules( { query:, builtins: } ) will return the rules config. Set builtins true for "builtins", false for "language", or null/undefined for "all".

Caveats

Some browsers supported by browserslist are not availble in the MDN data (e.g. Opera Mini) or are no longer being updated (e.g. Internet Explorer). In cases like these where no data is available, features are assumed to be supported. Set the environment variable DEBUG=@automattic/eslint-config-target-es:warn to generate messages when this happens.

Security

Need to report a security vulnerability? Go to https://automattic.com/security/ or directly to our security bug bounty site https://hackerone.com/automattic.

License

eslint-config-target-es is licensed under GNU General Public License v2 (or later)

--

版本与发布记录

@automattic/eslint-config-target-es 共发布 18 个版本,首次发布于 2021/11/17;过去 12 个月发布了 3 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
7.0.0latest2026/09/181 个月前
6.0.02026/04/146 个月前
5.0.02026/01/129 个月前
4.0.12025/10/141.1 年前
4.0.02025/08/071.3 年前
3.0.02025/05/141.5 年前

关于 @automattic/eslint-config-target-es 的常见问题

@automattic/eslint-config-target-es 是什么?

ESLint sharable config to activate eslint-plugin-es-x checks based on browserslist targets.

如何安装 @automattic/eslint-config-target-es?

在项目目录运行 npm install @automattic/eslint-config-target-es,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>=4.19.1)、eslint-plugin-es-x(^8.0.0 || ^9.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@automattic/eslint-config-target-es 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/automattic__eslint-config-target-es 是否存在。

@automattic/eslint-config-target-es 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@automattic/eslint-config-target-es 可以商用吗?

@automattic/eslint-config-target-es 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@automattic/eslint-config-target-es 的下载量有多少?

根据 npm 官方下载统计,@automattic/eslint-config-target-es 在 2026/10/07 – 2026/11/05 这 30 天内被下载 71,947 次,日均约 2,398 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@automattic/eslint-config-target-es 还在维护吗?

最新版本 7.0.0 发布于 2026/09/18(1 个月前);至今共发布 18 个版本,其中过去 12 个月发布了 3 个;首次发布于 2021/11/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。