eslint-visitor-keys
    Overview
    Documentation
    Insights
    Code
    Contributors
    Dependencies
    Alternatives

eslint-visitor-keys

Constants and utilities about visitor keys to traverse AST.

1.1.0  •  Updated 5 months ago  •  by eslint  •  Apache License 2.0

npm version Downloads/month Build Status Dependency Status

Constants and utilities about visitor keys to traverse AST.

💿 Installation

Use npm to install.

$ npm install eslint-visitor-keys

Requirements

📖 Usage

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 coverage opens the code coverage report of the previous test with your default browser.
  • npm run release publishes this package to npm registory.
How do you feel about the name openbase for this site?

Popularity

Weekly Downloads
6.2M
Stars
10

Maintenance

Development

Last ver 5 months ago
Created 2 years ago
Last commit 5 months ago
2 months between commits

Technology

Node version: 10.15.2
23.3K unpacked

Compliance

Apache License 2.0
OSI Approved
0 vulnerabilities

Contributors

5 contributors
Toru Nagashima
Maintainer, 5 commits, 6 merges, 4 PRs
ESLint Jenkins
4 commits
Teddy Katz
Maintainer, 1 commits, 1 merges, 1 PRs
ESLint Jenkins
2 commits
Ilya Volodin
Maintainer, 1 commits, 1 PRs
Works at Venmo
Kai Cataldo
Maintainer, 1 commits, 1 PRs
Works at eslint | babel
Ready for the next level?
Join Devstore's founding team to help us build the ultimate open-source app store, work with the latest technologies, and enjoy great culture, impact and autonomy
© 2020 Devstore, Inc.
Devstore helps developers find and use open-source packages, so they can focus on building amazing things