Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eslint-visitor-keys

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-visitor-keys - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

dist/eslint-visitor-keys.cjs

8

CHANGELOG.md

@@ -0,1 +1,8 @@

v3.0.0 - June 24, 2021
* [`701b67d`](https://github.com/eslint/eslint-visitor-keys/commit/701b67de7216cabebc03e7c6205fe47ce3177aa3) Breaking: drop node v10/v13/v15 (refs eslint/eslint#14023) (#23) (薛定谔的猫)
* [`f584b12`](https://github.com/eslint/eslint-visitor-keys/commit/f584b121421ceb6c4e034b79943f3c32aaa0541d) Breaking: Switch to ESM (#24) (Brett Zamir)
* [`7279e73`](https://github.com/eslint/eslint-visitor-keys/commit/7279e7304e95030a854408191b8fde3c01876451) Build: Update branch reference in CI (#25) (Milos Djermanovic)
* [`c6846d6`](https://github.com/eslint/eslint-visitor-keys/commit/c6846d69271c73041b797b7de9c8254dcf439a2e) Upgrade: eslint-release (#21) (Nicholas C. Zakas)
v2.1.0 - May 3, 2021

@@ -36,2 +43,1 @@

* 2204715 Initial commit (Toru Nagashima)

86

lib/index.js

@@ -5,15 +5,4 @@ /**

*/
"use strict";
import KEYS from "./visitor-keys.js";
const KEYS = require("./visitor-keys.json");
// Types.
const NODE_TYPES = Object.freeze(Object.keys(KEYS));
// Freeze the keys.
for (const type of NODE_TYPES) {
Object.freeze(KEYS[type]);
}
Object.freeze(KEYS);
// List to ignore keys.

@@ -35,49 +24,38 @@ const KEY_BLACKLIST = new Set([

//------------------------------------------------------------------------------
// Public interfaces
//------------------------------------------------------------------------------
/**
* Get visitor keys of a given node.
* @param {Object} node The AST node to get keys.
* @returns {string[]} Visitor keys of the node.
*/
export function getKeys(node) {
return Object.keys(node).filter(filterKey);
}
module.exports = Object.freeze({
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
// eslint-disable-next-line valid-jsdoc
/**
* Make the union set with `KEYS` and given keys.
* @param {Object} additionalKeys The additional keys.
* @returns {{ [type: string]: string[] | undefined }} The union set.
*/
export function unionWith(additionalKeys) {
const retv = Object.assign({}, KEYS);
/**
* Visitor keys.
* @type {{ [type: string]: string[] | undefined }}
*/
KEYS,
for (const type of Object.keys(additionalKeys)) {
if (Object.prototype.hasOwnProperty.call(retv, type)) {
const keys = new Set(additionalKeys[type]);
/**
* Get visitor keys of a given node.
* @param {Object} node The AST node to get keys.
* @returns {string[]} Visitor keys of the node.
*/
getKeys(node) {
return Object.keys(node).filter(filterKey);
},
for (const key of retv[type]) {
keys.add(key);
}
// Disable valid-jsdoc rule because it reports syntax error on the type of @returns.
// eslint-disable-next-line valid-jsdoc
/**
* Make the union set with `KEYS` and given keys.
* @param {Object} additionalKeys The additional keys.
* @returns {{ [type: string]: string[] | undefined }} The union set.
*/
unionWith(additionalKeys) {
const retv = Object.assign({}, KEYS);
retv[type] = Object.freeze(Array.from(keys));
} else {
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
}
}
for (const type of Object.keys(additionalKeys)) {
if (retv.hasOwnProperty(type)) {
const keys = new Set(additionalKeys[type]);
return Object.freeze(retv);
}
for (const key of retv[type]) {
keys.add(key);
}
retv[type] = Object.freeze(Array.from(keys));
} else {
retv[type] = Object.freeze(Array.from(additionalKeys[type]));
}
}
return Object.freeze(retv);
}
});
export { KEYS };
{
"name": "eslint-visitor-keys",
"version": "2.1.0",
"version": "3.0.0",
"description": "Constants and utilities about visitor keys to traverse AST.",
"main": "lib/index.js",
"type": "module",
"main": "dist/eslint-visitor-keys.cjs",
"exports": {
".": [
{
"import": "./lib/index.js",
"require": "./dist/eslint-visitor-keys.cjs"
},
"./dist/eslint-visitor-keys.cjs"
],
"./package.json": "./package.json"
},
"files": [
"dist/eslint-visitor-keys.cjs",
"lib"
],
"engines": {
"node": ">=10"
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
},
"dependencies": {},
"devDependencies": {
"eslint": "^4.7.2",
"eslint-config-eslint": "^4.0.0",
"eslint-release": "^1.0.0",
"mocha": "^3.5.3",
"nyc": "^11.2.1",
"opener": "^1.4.3"
"c8": "^7.7.3",
"eslint": "^7.29.0",
"eslint-config-eslint": "^7.0.0",
"eslint-plugin-jsdoc": "^35.4.0",
"eslint-plugin-node": "^11.1.0",
"eslint-release": "^3.1.2",
"mocha": "^9.0.1",
"opener": "^1.5.2",
"rollup": "^2.52.1"
},
"scripts": {
"lint": "eslint lib tests/lib",
"test": "nyc mocha tests/lib",
"coverage": "nyc report --reporter lcov && opener coverage/lcov-report/index.html",
"prepare": "npm run build",
"build": "rollup -c",
"lint": "eslint .",
"test": "mocha tests/lib/**/*.cjs && c8 mocha tests/lib/**/*.js",
"coverage": "c8 report --reporter lcov && opener coverage/lcov-report/index.html",
"generate-release": "eslint-generate-release",

@@ -26,0 +42,0 @@ "generate-alpharelease": "eslint-generate-prerelease alpha",

@@ -24,3 +24,11 @@ # eslint-visitor-keys

To use in an ESM file:
```js
import * as evk from "eslint-visitor-keys"
```
To use in a CommonJS file:
```js
const evk = require("eslint-visitor-keys")

@@ -27,0 +35,0 @@ ```

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc