4.0.0 • Published 2 months ago

eslint-visitor-keys v4.0.0

Weekly downloads
22,720,923
License
Apache-2.0
Repository
github
Last release
2 months ago

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 ^18.18.0, ^20.9.0, or >=21.1.0

📖 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.
espreeeslinteslint-utils@typescript-eslint/visitor-keysbabel-eslint@types/eslint-visitor-keysvue-eslint-parser@huyhpham/rn-lineeasy-select-rnreact-native-bluetooth2killi8n-react-native-fast-imagepipihome@icanpm/api-mastereslint-4-fix@arisageha/react-lazyload@arisageha/react-lazyload-fix@oneplanetcrowd/developers@almeidaa/mseslint-json-parserreact-native-template-rfbaseairscanairscan-examplebb-chatreact-native-esc-pos-sahaab@borisovart/atol-kkt-moduledeneme323112@ntt_app/react-native-custom-notificationagreestudioeslintreact-native-covid-sdkgql_din_modmutasi-bca@jttechnic/interpreter@saeon/quick-formcthpb-plugin-social@iobroker-community-adapters/iobroker.device-watchermysql-formatreact-native-printer-brothers@belko.tech/belko-multi-wallet-sdkdrill4js-cli@newhorizon-tech/dd-npm-package-templatereact-native-shekhar-bridge-testcogoportutilssynvert-core-javascriptukor-remasteruncoded-connect@reversodev/oceanic-fleetwilscanner@khalitovadel/abstract-repository@oiti/documentoscopy-react-native@respondea/cordova-plugin-v-inappbrowserquoc-testreact-native-slider-kf@infinitebrahmanuniverse/nolb-eslint-vplginexpand-react-bridgeopea-bootstraapluminos-ui-coresklif-ui-kitsklif-apits-handy@everything-registry/sub-chunk-1615jawwy-sdkjawwy_gamification_release@deepakorg/test@deepak757/testreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgp149-tablesklif-uimachinebeemrcapsreact-native-jawwy_sampleswiftallystitch-node@apardellass/react-native-audio-stream@adroiti/eslint@ailhc/javascript-obfuscator@amirdiafi/react-native-ios-haptics@amiruldev/wajs@_nomtek/react-native-shimmer-animation@aabelmann/ui-layer@ahmed-hairon/sharing@affinidi/affinidi-auth-sdk-kernel@armano/typescript-eslint-parser@arkalone/arkalone-yogyakarta@arielapaula/components@ankitfxz/params-ui@angangii/frontendpractice@anonybit-modules/videoreconstruction@antcube/core@antcube/core-tf@antcube/core-v1caropcarop2carop3carop4carosello-campus-opacitacarosello-tribus
4.0.0

2 months ago

3.4.3

8 months ago

3.4.2

9 months ago

3.4.1

12 months ago

3.4.0

1 year ago

3.3.0

2 years ago

3.2.0

2 years ago

3.1.0

2 years ago

3.0.0

3 years ago

2.1.0

3 years ago

2.0.0

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.0

5 years ago

1.0.0

6 years ago

0.1.0

6 years ago