Comparing version 1.2.1 to 1.2.2
{ | ||
"name": "flast", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"description": "Flatten JS AST", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
// eslint-disable-next-line no-unused-vars | ||
const {ASTNode} = require('espree'); | ||
const estraverse = require('estraverse'); | ||
@@ -32,3 +30,3 @@ const {generateCode, generateFlatAST} = require(__dirname + '/flast'); | ||
(currentNode.parentNode.declarations.length === 1 || | ||
!currentNode.parentNode.declarations.filter(d => d.nodeId !== currentNode.nodeId && !d.markedNode).length) | ||
!currentNode.parentNode.declarations.filter(d => d.nodeId !== currentNode.nodeId && !d.isMarked).length) | ||
)) currentNode = currentNode.parentNode; | ||
@@ -45,11 +43,11 @@ return currentNode; | ||
markNode(targetNode, replacementNode) { | ||
if (!targetNode.markedNode) { | ||
if (!targetNode.isMarked) { | ||
if (replacementNode) { // Mark for replacement | ||
this.markedForReplacement[targetNode.nodeId] = replacementNode; | ||
targetNode.markedNode = true; | ||
targetNode.isMarked = true; | ||
} else { // Mark for deletion | ||
targetNode = this._getCorrectTargetForDeletion(targetNode); | ||
if (!targetNode.markedNode) { | ||
if (!targetNode.isMarked) { | ||
this.markedForDeletion.push(targetNode.nodeId); | ||
targetNode.markedNode = true; | ||
targetNode.isMarked = true; | ||
} | ||
@@ -56,0 +54,0 @@ } |
// noinspection JSUnusedGlobalSymbols | ||
// eslint-disable-next-line no-unused-vars | ||
const {parse, ASTNode:espreeASTNode} = require('espree'); | ||
const {parse} = require('espree'); | ||
const {generate} = require('escodegen'); | ||
const estraverse = require('estraverse'); | ||
// eslint-disable-next-line no-unused-vars | ||
const {analyze, ScopeManager} = require('eslint-scope'); | ||
const {analyze} = require('eslint-scope'); | ||
@@ -13,12 +11,2 @@ const ecmaVersion = 'latest'; | ||
/** | ||
* @typedef ASTNode | ||
* @property {number} nodeId | ||
* @property {string} src | ||
* @property {array} childNodes | ||
* @property {?ASTNode} parentNode | ||
* @property {ScopeManager} scope | ||
* @property {?string} parentKey | ||
*/ | ||
const ASTNode = espreeASTNode; | ||
@@ -31,3 +19,2 @@ /** | ||
function parseCode(inputCode, opts = {}) { | ||
// noinspection JSValidateTypes | ||
return parse(inputCode, {ecmaVersion, comment: true, range: true, ...opts}); | ||
@@ -86,2 +73,6 @@ } | ||
estraverse.traverse(rootNode, { | ||
/** | ||
* @param {ASTNode} node | ||
* @param {ASTNode} parentNode | ||
*/ | ||
enter(node, parentNode) { | ||
@@ -171,3 +162,2 @@ if (opts.detailed) { | ||
generateCode, | ||
ASTNode, | ||
}; |
module.exports = { | ||
...require(__dirname + '/flast'), | ||
...require(__dirname + '/arborist'), | ||
...require(__dirname + '/types'), | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35541
16
577
8