fix: mark Pattern in CatchClause as scope (#12119)
This commit is contained in:
@@ -11,17 +11,15 @@ import {
|
||||
* Check if the input `node` is a scope.
|
||||
*/
|
||||
export default function isScope(node: Object, parent: Object): boolean {
|
||||
if (isBlockStatement(node) && isFunction(parent, { body: node })) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBlockStatement(node) && isCatchClause(parent, { body: node })) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If a Pattern is an immediate descendent of a Function, it must be in the params.
|
||||
// If a BlockStatement is an immediate descendent of a Function/CatchClause, it must be in the body.
|
||||
// Hence we skipped the parentKey === "params" check
|
||||
if (isPattern(node) && isFunction(parent)) {
|
||||
if (isBlockStatement(node) && (isFunction(parent) || isCatchClause(parent))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// If a Pattern is an immediate descendent of a Function/CatchClause, it must be in the params.
|
||||
// Hence we skipped the parentKey === "params" check
|
||||
if (isPattern(node) && (isFunction(parent) || isCatchClause(parent))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user