periscopic
Advanced tools
Comparing version 3.0.4 to 3.1.0
{ | ||
"name": "periscopic", | ||
"description": "periscopic", | ||
"version": "3.0.4", | ||
"repository": "Rich-Harris/periscopic", | ||
"main": "src/index.js", | ||
"module": "src/index.js", | ||
"type": "module", | ||
"exports": { | ||
"import": "./src/index.js" | ||
}, | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src", | ||
"types" | ||
], | ||
"devDependencies": { | ||
"@types/estree": "0.0.39", | ||
"acorn": "^7.0.0", | ||
"typescript": "^4.1.2", | ||
"uvu": "^0.5.1" | ||
}, | ||
"scripts": { | ||
"test": "uvu test", | ||
"prepublishOnly": "npm test && tsc" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"estree-walker": "^3.0.0", | ||
"is-reference": "^3.0.0" | ||
} | ||
"name": "periscopic", | ||
"description": "periscopic", | ||
"version": "3.1.0", | ||
"repository": "Rich-Harris/periscopic", | ||
"main": "src/index.js", | ||
"module": "src/index.js", | ||
"type": "module", | ||
"exports": { | ||
"types": "./types/index.js", | ||
"import": "./src/index.js" | ||
}, | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"src", | ||
"types" | ||
], | ||
"devDependencies": { | ||
"acorn": "^8.0.0", | ||
"typescript": "^4.9.0", | ||
"uvu": "^0.5.1" | ||
}, | ||
"scripts": { | ||
"test": "uvu test", | ||
"prepublishOnly": "npm test && tsc" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@types/estree": "^1.0.0", | ||
"estree-walker": "^3.0.0", | ||
"is-reference": "^3.0.0" | ||
} | ||
} |
@@ -18,13 +18,10 @@ import { walk } from 'estree-walker'; | ||
const references = []; | ||
/** @type {Scope} */ | ||
let current_scope = scope; | ||
walk(expression, { | ||
/** | ||
* @param {Node} node | ||
* @param {any} parent | ||
*/ | ||
enter(node, parent) { | ||
switch (node.type) { | ||
case 'Identifier': | ||
if (is_reference(node, parent)) { | ||
if (parent && is_reference(node, parent)) { | ||
references.push([current_scope, node]); | ||
@@ -84,3 +81,5 @@ } | ||
extract_names(node.param).forEach(name => { | ||
current_scope.declarations.set(name, node.param); | ||
if (node.param) { | ||
current_scope.declarations.set(name, node.param); | ||
} | ||
}); | ||
@@ -92,5 +91,4 @@ } | ||
/** @param {Node} node */ | ||
leave(node) { | ||
if (map.has(node)) { | ||
if (map.has(node) && current_scope !== null && current_scope.parent) { | ||
current_scope = current_scope.parent; | ||
@@ -116,3 +114,2 @@ } | ||
/** | ||
* | ||
* @param {Scope} scope | ||
@@ -127,2 +124,6 @@ * @param {string} name | ||
export class Scope { | ||
/** | ||
* @param {Scope | null} parent | ||
* @param {boolean} block | ||
*/ | ||
constructor(parent, block) { | ||
@@ -145,3 +146,5 @@ /** @type {Scope | null} */ | ||
/** @param {import('estree').VariableDeclaration | import('estree').ClassDeclaration} node */ | ||
/** | ||
* @param {import('estree').VariableDeclaration | import('estree').ClassDeclaration} node | ||
*/ | ||
add_declaration(node) { | ||
@@ -233,3 +236,7 @@ if (node.type === 'VariableDeclaration') { | ||
param.elements.forEach(handle_element); | ||
param.elements.forEach((element) => { | ||
if (element) { | ||
handle_element(element) | ||
} | ||
}); | ||
break; | ||
@@ -236,0 +243,0 @@ |
@@ -19,3 +19,7 @@ /** @param {import('estree').Node} expression */ | ||
export class Scope { | ||
constructor(parent: any, block: any); | ||
/** | ||
* @param {Scope | null} parent | ||
* @param {boolean} block | ||
*/ | ||
constructor(parent: Scope | null, block: boolean); | ||
/** @type {Scope | null} */ | ||
@@ -31,3 +35,5 @@ parent: Scope | null; | ||
references: Set<string>; | ||
/** @param {import('estree').VariableDeclaration | import('estree').ClassDeclaration} node */ | ||
/** | ||
* @param {import('estree').VariableDeclaration | import('estree').ClassDeclaration} node | ||
*/ | ||
add_declaration(node: import('estree').VariableDeclaration | import('estree').ClassDeclaration): void; | ||
@@ -34,0 +40,0 @@ /** |
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
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
3
255
11219
3
5
+ Added@types/estree@^1.0.0