This document was written based on the implementation of eslint-scope, a fork of escope, and deprecates some members ESLint is not using.
ScopeManager
object has all variable scopes.
Scope[]
Scope
node
(ASTNode
) ... An AST node to get their scope.inner
(boolean
) ... If the node has multiple scope, this returns the outermost scope normally. If inner
is true
then this returns the innermost scope. Default is false
.Scope | null
block
property is the node. This method never returns function-expression-name
scope. If the node does not have their scope, this returns null
.node
(ASTNode
) ... An AST node to get their variables.Variable[]
def[].node
/def[].parent
property is the node. If the node does not define any variable, this returns an empty array.Those members are defined but not used in ESLint.
boolean
true
if this program is module.boolean
true
if this program is strict mode implicitly. I.e., options.impliedStrict === true
.boolean
true
if this program supports strict mode. I.e., options.ecmaVersion >= 5
.node
(ASTNode
) ... An AST node to get their scope.Scope[] | null
block
property is the node. If the node does not have their scope, this returns null
.Scope
object has all variables and references in the scope.
string
"block"
, "catch"
, "class"
, "for"
, "function"
, "function-expression-name"
, "global"
, "module"
, "switch"
, "with"
boolean
true
if this scope is strict mode.Scope | null
null
.Scope[]
Scope
var
declarations.ASTNode
Variable[]
Map<string, Variable>
I hope to rename
set
field or replace by a method.
Reference[]
Reference[]
boolean
true
if this scope is "function-expression-name"
scope.I hope to deprecate
functionExpressionScope
field as replacing byscope.type === "function-expression-name"
.
Those members are defined but not used in ESLint.
Map<string, boolean>
tainted
flag.boolean
true
if this scope is dynamic. I.e., the type of this scope is "global"
or "with"
.boolean
true
if this scope contains eval()
invocations.boolean
true
if this scope contains this
.node
(ASTNode
) ... An AST node to get their reference object. The type of the node must be "Identifier"
.Reference | null
this.references.find(r => r.identifier === node)
.boolean
!this.dynamic
.boolean
true
if this is a "function"
scope which has used arguments
variable.boolean
this.thisFound
.name
(string
) ... The name to check.boolean
true
if a given name is used in variable names or reference names.Variable
object is variable's information.
string
ASTNode[]
Identifier
nodes which define this variable. If this variable is redeclared, this array includes two or more nodes.I hope to deprecate
identifiers
field as replacing bydefs[].name
field.
Reference[]
Definition[]
Those members are defined but not used in ESLint.
boolean
tainted
flag. (always false
)boolean
stack
flag. (I'm not sure what this means.)Reference
object is reference's information.
ASTNode
Identifier
node of this reference.Scope
Scope
object that this reference is on.Variable | null
Variable
object that this reference refers. If such variable was not defined, this is null
.ASTNode | null
boolean
true
if this writing reference is a variable initializer or a default value.boolean
true
if this reference is writing.boolean
true
if this reference is reading.boolean
true
if this reference is writing but not reading.boolean
true
if this reference is reading but not writing.boolean
true
if this reference is reading and writing.Those members are defined but not used in ESLint.
boolean
tainted
flag. (always false
)number
1
is reading, 2
is writing, 3
is reading/writing.boolean
partial
flag.boolean
true
if this reference is resolved statically.Definition
object is variable definition's information.
string
"CatchClause"
, "ClassName"
, "FunctionName"
, "ImplicitGlobalVariable"
, "ImportBinding"
, "Parameter"
, and "Variable"
.ASTNode
Identifier
node of this definition.ASTNode
type | node |
---|---|
"CatchClause" |
CatchClause |
"ClassName" |
ClassDeclaration or ClassExpression
|
"FunctionName" |
FunctionDeclaration or FunctionExpression
|
"ImplicitGlobalVariable" |
Program |
"ImportBinding" |
ImportSpecifier , ImportDefaultSpecifier , or ImportNamespaceSpecifier
|
"Parameter" |
FunctionDeclaration , FunctionExpression , or ArrowFunctionExpression
|
"Variable" |
VariableDeclarator |
ASTNode | undefined | null
type | parent |
---|---|
"CatchClause" |
null |
"ClassName" |
null |
"FunctionName" |
null |
"ImplicitGlobalVariable" |
null |
"ImportBinding" |
ImportDeclaration |
"Parameter" |
null |
"Variable" |
VariableDeclaration |
Those members are defined but not used in ESLint.
number | undefined | null
string | undefined | null
© JS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/developer-guide/scope-manager-interface