Skip to content

Commit

Permalink
fix(pluginutils): keep for(const..) out of scope (rollup#151)
Browse files Browse the repository at this point in the history
* fix(pluginutils): createFilter windows regression

* chore: diagnose windows

* fix(pluginutils): keep for(const..) out of scope

* chore: clean up comments

* chore: revert github workflow
  • Loading branch information
shellscape authored and LarsDenBakker committed Sep 12, 2020
1 parent 12c937f commit 26f984b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions packages/pluginutils/src/attachScopes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'sc
if (node.type === 'VariableDeclaration') {
const { kind } = node;
const isBlockDeclaration = blockDeclarations[kind];

node.declarations.forEach((declaration: Node) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
// don't add const/let declarations in the body of a for loop #113
const parentType = parent ? parent.type : '';
if (!(isBlockDeclaration && /ForOfStatement/.test(parentType))) {
node.declarations.forEach((declaration: Node) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}
}

let newScope: AttachedScope | undefined;
Expand Down
1 change: 1 addition & 0 deletions packages/pluginutils/src/createFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const createFilter: CreateFilter = function createFilter(include?, exclude?, opt
const pattern = getMatcherString(id, resolutionBase);
const fn = mm.matcher(pattern, { dot: true });
const result = fn(what);

return result;
}
};
Expand Down

0 comments on commit 26f984b

Please sign in to comment.