Skip to content

Commit 7c9c5ac

Browse files
committed
minor cleanup before major merge of d3 branch
1 parent ef7258e commit 7c9c5ac

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

package/astParser.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ const JSXParser = acorn.Parser.extend(jsx());
77
function getHookNames(ast) {
88
// Initialize empty object to store the setters and getter
99
const hookState = {};
10+
// All module exports will always start off as a single 'FunctionDeclaration' type
1011
while (Object.hasOwnProperty.call(ast, 'body')) {
11-
// All module exports will always start off as a single 'FunctionDeclaration' type
1212
// Traverse down .body once before invoking parsing logic and will loop through any .body after
1313
ast = ast.body;
14-
console.log('AST Tree', ast);
1514
// Iterate through AST of every function declaration
1615
// Check within each function declaration if there are hook declarations
1716
ast.forEach(functionDec => {
@@ -39,16 +38,16 @@ function getHookNames(ast) {
3938

4039
module.exports = file => {
4140
// Create an empty object to allow all invocations of getHookNames to consolidate
42-
let hookNames = {};
41+
let allHookNames = {};
4342
const ast = JSXParser.parse(file);
44-
console.log('Original File', file.toString());
45-
console.log('Original AST', ast);
43+
// console.log('Original File', file.toString());
44+
// console.log('Original AST', ast);
4645
// Upsert any new/updated {_hookType#: hookName} pairs
47-
hookNames = {
48-
...hookNames,
46+
allHookNames = {
47+
...allHookNames,
4948
...getHookNames(ast),
5049
};
5150

5251
// Return the object with setters and getters
53-
return hookNames;
52+
return allHookNames;
5453
};

0 commit comments

Comments
 (0)