3 [![npm version](https://img.shields.io/npm/v/eslint-visitor-keys.svg)](https://www.npmjs.com/package/eslint-visitor-keys)
4 [![Downloads/month](https://img.shields.io/npm/dm/eslint-visitor-keys.svg)](http://www.npmtrends.com/eslint-visitor-keys)
5 [![Build Status](https://travis-ci.org/eslint/eslint-visitor-keys.svg?branch=master)](https://travis-ci.org/eslint/eslint-visitor-keys)
6 [![Dependency Status](https://david-dm.org/eslint/eslint-visitor-keys.svg)](https://david-dm.org/eslint/eslint-visitor-keys)
8 Constants and utilities about visitor keys to traverse AST.
15 $ npm install eslint-visitor-keys
20 - [Node.js] 4.0.0 or later.
25 const evk = require("eslint-visitor-keys")
30 > type: `{ [type: string]: string[] | undefined }`
32 Visitor keys. This keys are frozen.
34 This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
39 console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
44 > type: `(node: object) => string[]`
46 Get the visitor keys of a given AST node.
48 This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
50 This will be used to traverse unknown nodes.
56 type: "AssignmentExpression",
57 left: { type: "Identifier", name: "foo" },
58 right: { type: "Literal", value: 0 }
60 console.log(evk.getKeys(node)) // → ["type", "left", "right"]
63 ### evk.unionWith(additionalKeys)
65 > type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
67 Make the union set with `evk.KEYS` and the given keys.
69 - The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
70 - It removes duplicated keys as keeping the first one.
75 console.log(evk.unionWith({
76 MethodDefinition: ["decorators"]
77 })) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
82 See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
86 Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
88 ### Development commands
90 - `npm test` runs tests and measures code coverage.
91 - `npm run lint` checks source codes with ESLint.
92 - `npm run coverage` opens the code coverage report of the previous test with your default browser.
93 - `npm run release` publishes this package to [npm] registory.
96 [npm]: https://www.npmjs.com/
97 [Node.js]: https://nodejs.org/en/
98 [ESTree]: https://github.com/estree/estree