You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.
It's similar to function-expression-name scope which separates the variable of function expression names from function bodies. So I propose new function-default-params scope which separates the references in default parameters from function bodies.
If the current function has one or more default parameters in traversing, the referencer defines a function-default-params scope instead of function scope.
Note: the function-default-params scope has implicit arguments variable except if the function is arrow function expression.
Note: the function-default-params scope is the child scope of function-expression-name scope if the function is function expression.
The referencer evaluates the parameters.
The referencer defines function scope.
The referencer copies the all variables from the function-default-params scope to the function scope.
Note: those copies handle redeclaration such as function f(a = 1) { let a } correctly.
Note: at least, no-shadow rule has to handle those copies as special.
Note: I think we should use shallow copy here because Variable#defs and Variable#references should be shared with both scopes but Reference#resolved property cannot have multiple variable objects. For example, in function f(a, b = a) { g(a) } case, the two references of a should be aggregated into one Variable#references array.
The referencer evaluates the function body.
The referencer closes both function-default-params and function scopes at the end of the function.
The text was updated successfully, but these errors were encountered:
From #33, eslint/eslint#9335.
As the step 27.a of 9.2.12 FunctionDeclarationInstantiation( func, argumentsList ),
eslint-scope
should make new scope for the function body only if the parameters has any default value.It's similar to
function-expression-name
scope which separates the variable of function expression names from function bodies. So I propose newfunction-default-params
scope which separates the references in default parameters from function bodies.function-default-params
scope instead offunction
scope.function-default-params
scope has implicitarguments
variable except if the function is arrow function expression.function-default-params
scope is the child scope offunction-expression-name
scope if the function is function expression.function
scope.function-default-params
scope to thefunction
scope.function f(a = 1) { let a }
correctly.no-shadow
rule has to handle those copies as special.Variable#defs
andVariable#references
should be shared with both scopes butReference#resolved
property cannot have multiple variable objects. For example, infunction f(a, b = a) { g(a) }
case, the two references ofa
should be aggregated into oneVariable#references
array.function-default-params
andfunction
scopes at the end of the function.The text was updated successfully, but these errors were encountered: