diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/@babel/traverse/lib')
-rw-r--r-- | tools/node_modules/eslint/node_modules/@babel/traverse/lib/path/introspection.js | 9 | ||||
-rw-r--r-- | tools/node_modules/eslint/node_modules/@babel/traverse/lib/scope/index.js | 16 |
2 files changed, 21 insertions, 4 deletions
diff --git a/tools/node_modules/eslint/node_modules/@babel/traverse/lib/path/introspection.js b/tools/node_modules/eslint/node_modules/@babel/traverse/lib/path/introspection.js index 175ef2d771..2cd224a81b 100644 --- a/tools/node_modules/eslint/node_modules/@babel/traverse/lib/path/introspection.js +++ b/tools/node_modules/eslint/node_modules/@babel/traverse/lib/path/introspection.js @@ -94,9 +94,12 @@ function isCompletionRecord(allowInsideFunction) { let first = true; do { - const container = path.container; + const { + type, + container + } = path; - if (path.isFunction() && !first) { + if (!first && (path.isFunction() || type === "StaticBlock")) { return !!allowInsideFunction; } @@ -105,7 +108,7 @@ function isCompletionRecord(allowInsideFunction) { if (Array.isArray(container) && path.key !== container.length - 1) { return false; } - } while ((path = path.parentPath) && !path.isProgram()); + } while ((path = path.parentPath) && !path.isProgram() && !path.isDoExpression()); return true; } diff --git a/tools/node_modules/eslint/node_modules/@babel/traverse/lib/scope/index.js b/tools/node_modules/eslint/node_modules/@babel/traverse/lib/scope/index.js index 1ef4fa627f..ce1f1a38dd 100644 --- a/tools/node_modules/eslint/node_modules/@babel/traverse/lib/scope/index.js +++ b/tools/node_modules/eslint/node_modules/@babel/traverse/lib/scope/index.js @@ -854,7 +854,9 @@ class Scope { push(opts) { let path = this.path; - if (!path.isBlockStatement() && !path.isProgram()) { + if (path.isPattern()) { + path = this.getPatternParent().path; + } else if (!path.isBlockStatement() && !path.isProgram()) { path = this.getBlockParent().path; } @@ -921,6 +923,18 @@ class Scope { throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program..."); } + getPatternParent() { + let scope = this; + + do { + if (!scope.path.isPattern()) { + return scope.getBlockParent(); + } + } while (scope = scope.parent.parent); + + throw new Error("We couldn't find a BlockStatement, For, Switch, Function, Loop or Program..."); + } + getAllBindings() { const ids = Object.create(null); let scope = this; |