Skip to content

Commit

Permalink
add vars to scope manager declaredVariables (#84)
Browse files Browse the repository at this point in the history
This makes eslint sourceCode getDeclaredVariables work which is required for some rules to work
  • Loading branch information
patricklx authored Apr 10, 2024
1 parent ded313e commit 1922eda
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/parser/transforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,17 @@ module.exports.convertAst = function convertAst(result, preprocessedResult, visi
const scope = result.isTypescript
? new TypescriptScope.BlockScope(result.scopeManager, upperScope, node)
: new Scope(result.scopeManager, 'block', upperScope, node);
const declaredVariables =
result.scopeManager.declaredVariables || result.scopeManager.__declaredVariables;
const vars = [];
declaredVariables.set(node, vars);
for (const [i, b] of node.params.entries()) {
const v = new Variable(b.name, scope);
v.identifiers.push(b);
v.defs.push(new Definition('Parameter', b, node, node, i, 'Block Param'));
scope.variables.push(v);
scope.set.set(b.name, v);
vars.push(v);
}
}
return null;
Expand Down

0 comments on commit 1922eda

Please sign in to comment.