massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / node_modules / eslint-visitor-keys / README.md
1 # eslint-visitor-keys
2
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)
7
8 Constants and utilities about visitor keys to traverse AST.
9
10 ## 💿 Installation
11
12 Use [npm] to install.
13
14 ```bash
15 $ npm install eslint-visitor-keys
16 ```
17
18 ### Requirements
19
20 - [Node.js] 10.0.0 or later.
21
22 ## 📖 Usage
23
24 ```js
25 const evk = require("eslint-visitor-keys")
26 ```
27
28 ### evk.KEYS
29
30 > type: `{ [type: string]: string[] | undefined }`
31
32 Visitor keys. This keys are frozen.
33
34 This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
35
36 For example:
37
38 ```
39 console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
40 ```
41
42 ### evk.getKeys(node)
43
44 > type: `(node: object) => string[]`
45
46 Get the visitor keys of a given AST node.
47
48 This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
49
50 This will be used to traverse unknown nodes.
51
52 For example:
53
54 ```
55 const node = {
56     type: "AssignmentExpression",
57     left: { type: "Identifier", name: "foo" },
58     right: { type: "Literal", value: 0 }
59 }
60 console.log(evk.getKeys(node)) // → ["type", "left", "right"]
61 ```
62
63 ### evk.unionWith(additionalKeys)
64
65 > type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
66
67 Make the union set with `evk.KEYS` and the given keys.
68
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.
71
72 For example:
73
74 ```
75 console.log(evk.unionWith({
76     MethodDefinition: ["decorators"]
77 })) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
78 ```
79
80 ## 📰 Change log
81
82 See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
83
84 ## 🍻 Contributing
85
86 Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
87
88 ### Development commands
89
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.
94
95
96 [npm]: https://www.npmjs.com/
97 [Node.js]: https://nodejs.org/en/
98 [ESTree]: https://github.com/estree/estree