eslint-visitor-keys

中文文档
5.0.1发布于 2026/02/20Apache-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 15.3亿

Constants and utilities about visitor keys to traverse AST.

原始使用文档
文档目录15 节
  1. 💿 Installation
  2. Requirements
  3. 📖 Usage
  4. evk.KEYS
  5. evk.getKeys(node)
  6. evk.unionWith(additionalKeys)
  7. 📰 Change log
  8. 🍻 Contributing
  9. Development commands
  10. Sponsors
  11. Platinum Sponsors
  12. Gold Sponsors
  13. Silver Sponsors
  14. Bronze Sponsors
  15. Technology Sponsors

eslint-visitor-keys

npm version Downloads/month Build Status

Constants and utilities about visitor keys to traverse AST.

💿 Installation

Use npm to install.

$ npm install eslint-visitor-keys

Requirements

  • Node.js ^20.19.0, ^22.13.0, or >=24

📖 Usage

To use in an ESM file:

import * as evk from "eslint-visitor-keys";

To use in a CommonJS file:

const evk = require("eslint-visitor-keys");

evk.KEYS

type: { [type: string]: string[] | undefined }

Visitor keys. This keys are frozen.

This is an object. Keys are the type of ESTree nodes. Their values are an array of property names which have child nodes.

For example:

console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]

evk.getKeys(node)

type: (node: object) => string[]

Get the visitor keys of a given AST node.

This is similar to Object.keys(node) of ES Standard, but some keys are excluded: parent, leadingComments, trailingComments, and names which start with _.

This will be used to traverse unknown nodes.

For example:

const node = {
    type: "AssignmentExpression",
    left: { type: "Identifier", name: "foo" },
    right: { type: "Literal", value: 0 },
};
console.log(evk.getKeys(node)); // → ["type", "left", "right"]

evk.unionWith(additionalKeys)

type: (additionalKeys: object) => { [type: string]: string[] | undefined }

Make the union set with evk.KEYS and the given keys.

  • The order of keys is, additionalKeys is at first, then evk.KEYS is concatenated after that.
  • It removes duplicated keys as keeping the first one.

For example:

console.log(
    evk.unionWith({
        MethodDefinition: ["decorators"],
    }),
); // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }

📰 Change log

See GitHub releases.

🍻 Contributing

Welcome. See ESLint contribution guidelines.

Development commands

  • npm test runs tests and measures code coverage.
  • npm run lint checks source codes with ESLint.
  • npm run test:open-coverage opens the code coverage report of the previous test with your default browser.

Sponsors

The following companies, organizations, and individuals support ESLint's ongoing maintenance and development. Become a Sponsor to get your logo on our READMEs and website.

Platinum Sponsors

Automattic

Gold Sponsors

Qlty Software Shopify

Silver Sponsors

Vite Liftoff StackBlitz

Bronze Sponsors

Cybozu SAP CrawlJobs Depot N-iX Ltd Icons8 Discord GitBook HeroCoders TestMu AI Open Source Office (Formerly LambdaTest)

Technology Sponsors

Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.

Netlify Algolia 1Password

版本与发布记录

eslint-visitor-keys 共发布 21 个版本,首次发布于 2017/11/17;过去 12 个月发布了 2 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.0.1latest2026/02/208 个月前
5.0.02025/11/1111 个月前
4.2.12025/06/091.4 年前
4.2.02024/10/302 年前
4.1.02024/09/272 年前
4.0.02024/02/102 年前

关于 eslint-visitor-keys 的常见问题

eslint-visitor-keys 是什么?

Constants and utilities about visitor keys to traverse AST.

如何安装 eslint-visitor-keys?

在项目目录运行 npm install eslint-visitor-keys,或使用 pnpm add / yarn add / bun add。

eslint-visitor-keys 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

eslint-visitor-keys 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

eslint-visitor-keys 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.19.0 || ^22.13.0 || >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

eslint-visitor-keys 可以商用吗?

eslint-visitor-keys 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

eslint-visitor-keys 的下载量有多少?

根据 npm 官方下载统计,eslint-visitor-keys 在 2026/10/04 – 2026/11/02 这 30 天内被下载 1,528,294,554 次,日均约 50,943,152 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

eslint-visitor-keys 还在维护吗?

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