Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # eslint-visitor-keys
  2. [![npm version](https://img.shields.io/npm/v/eslint-visitor-keys.svg)](https://www.npmjs.com/package/eslint-visitor-keys)
  3. [![Downloads/month](https://img.shields.io/npm/dm/eslint-visitor-keys.svg)](http://www.npmtrends.com/eslint-visitor-keys)
  4. [![Build Status](https://travis-ci.org/eslint/eslint-visitor-keys.svg?branch=master)](https://travis-ci.org/eslint/eslint-visitor-keys)
  5. [![Dependency Status](https://david-dm.org/eslint/eslint-visitor-keys.svg)](https://david-dm.org/eslint/eslint-visitor-keys)
  6. Constants and utilities about visitor keys to traverse AST.
  7. ## 💿 Installation
  8. Use [npm] to install.
  9. ```bash
  10. $ npm install eslint-visitor-keys
  11. ```
  12. ### Requirements
  13. - [Node.js] 4.0.0 or later.
  14. ## 📖 Usage
  15. ```js
  16. const evk = require("eslint-visitor-keys")
  17. ```
  18. ### evk.KEYS
  19. > type: `{ [type: string]: string[] | undefined }`
  20. Visitor keys. This keys are frozen.
  21. This is an object. Keys are the type of [ESTree] nodes. Their values are an array of property names which have child nodes.
  22. For example:
  23. ```
  24. console.log(evk.KEYS.AssignmentExpression) // → ["left", "right"]
  25. ```
  26. ### evk.getKeys(node)
  27. > type: `(node: object) => string[]`
  28. Get the visitor keys of a given AST node.
  29. This is similar to `Object.keys(node)` of ES Standard, but some keys are excluded: `parent`, `leadingComments`, `trailingComments`, and names which start with `_`.
  30. This will be used to traverse unknown nodes.
  31. For example:
  32. ```
  33. const node = {
  34. type: "AssignmentExpression",
  35. left: { type: "Identifier", name: "foo" },
  36. right: { type: "Literal", value: 0 }
  37. }
  38. console.log(evk.getKeys(node)) // → ["type", "left", "right"]
  39. ```
  40. ### evk.unionWith(additionalKeys)
  41. > type: `(additionalKeys: object) => { [type: string]: string[] | undefined }`
  42. Make the union set with `evk.KEYS` and the given keys.
  43. - The order of keys is, `additionalKeys` is at first, then `evk.KEYS` is concatenated after that.
  44. - It removes duplicated keys as keeping the first one.
  45. For example:
  46. ```
  47. console.log(evk.unionWith({
  48. MethodDefinition: ["decorators"]
  49. })) // → { ..., MethodDefinition: ["decorators", "key", "value"], ... }
  50. ```
  51. ## 📰 Change log
  52. See [GitHub releases](https://github.com/eslint/eslint-visitor-keys/releases).
  53. ## 🍻 Contributing
  54. Welcome. See [ESLint contribution guidelines](https://eslint.org/docs/developer-guide/contributing/).
  55. ### Development commands
  56. - `npm test` runs tests and measures code coverage.
  57. - `npm run lint` checks source codes with ESLint.
  58. - `npm run coverage` opens the code coverage report of the previous test with your default browser.
  59. - `npm run release` publishes this package to [npm] registory.
  60. [npm]: https://www.npmjs.com/
  61. [Node.js]: https://nodejs.org/en/
  62. [ESTree]: https://github.com/estree/estree