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.
- Type:
Scope[]
- Description: All scopes.
- Type:
Scope
- Description: The root scope.
- Parameters:
node
(ASTNode
) ... An AST node to get their scope.inner
(boolean
) ... If the node has multiple scope, this returns the outermost scope normally. Ifinner
istrue
then this returns the innermost scope. Default isfalse
.
- Return type:
Scope | null
- Description: Get the scope of a given AST node. The gotten scope's
block
property is the node. This method never returnsfunction-expression-name
scope. If the node does not have their scope, this returnsnull
.
- Parameters:
node
(ASTNode
) ... An AST node to get their variables.
- Return type:
Variable[]
- Description: Get the variables that a given AST node defines. The gotten variables'
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.
- Parameters:
- Return type:
boolean
- Description:
true
if this program is module.
- Parameters:
- Return type:
boolean
- Description:
true
if this program is strict mode implicitly. I.e.,options.impliedStrict === true
.
- Parameters:
- Return type:
boolean
- Description:
true
if this program supports strict mode. I.e.,options.ecmaVersion >= 5
.
- Parameters:
node
(ASTNode
) ... An AST node to get their scope.
- Return type:
Scope[] | null
- Description: Get the scopes of a given AST node. The gotten scopes'
block
property is the node. If the node does not have their scope, this returnsnull
.
Scope
object has all variables and references in the scope.
- Type:
string
- Description: The type of this scope. This is one of
"block"
,"catch"
,"class"
,"for"
,"function"
,"function-expression-name"
,"global"
,"module"
,"switch"
,"with"
- Type:
boolean
- Description:
true
if this scope is strict mode.
- Type:
Scope | null
- Description: The parent scope. If this is the global scope then this property is
null
.
- Type:
Scope[]
- Description: The array of child scopes. This does not include grandchild scopes.
- Type:
Scope
- Description: The scope which hosts variables which are defined by
var
declarations.
- Type:
ASTNode
- Description: The AST node which created this scope.
- Type:
Variable[]
- Description: The array of all variables which are defined on this scope. This does not include variables which are defined in child scopes.
- Type:
Map<string, Variable>
- Description: The map from variable names to variable objects.
I hope to rename
set
field or replace by a method.
- Type:
Reference[]
- Description: The array of all references on this scope. This does not include references in child scopes.
- Type:
Reference[]
- Description: The array of references which could not be resolved in this scope.
- Type:
boolean
- Description:
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.
- Type:
Map<string, boolean>
- Description: The map from variable names to
tainted
flag.
- Type:
boolean
- Description:
true
if this scope is dynamic. I.e., the type of this scope is"global"
or"with"
.
- Type:
boolean
- Description:
true
if this scope containseval()
invocations.
- Type:
boolean
- Description:
true
if this scope containsthis
.
- Parameters:
node
(ASTNode
) ... An AST node to get their reference object. The type of the node must be"Identifier"
.
- Return type:
Reference | null
- Description: Returns
this.references.find(r => r.identifier === node)
.
- Parameters:
- Return type:
boolean
- Description: Returns
!this.dynamic
.
- Parameters:
- Return type:
boolean
- Description:
true
if this is a"function"
scope which has usedarguments
variable.
- Parameters:
- Return type:
boolean
- Description: Returns
this.thisFound
.
- Parameters:
name
(string
) ... The name to check.
- Return type:
boolean
- Description:
true
if a given name is used in variable names or reference names.
Variable
object is variable's information.
- Type:
string
- Description: The name of this variable.
- Type:
ASTNode[]
- Description: The array of
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.
- Type:
Reference[]
- Description: The array of the references of this variable.
- Type:
Definition[]
- Description: The array of the definitions of this variable.
Those members are defined but not used in ESLint.
- Type:
boolean
- Description: The
tainted
flag. (alwaysfalse
)
- Type:
boolean
- Description: The
stack
flag. (I'm not sure what this means.)
Reference
object is reference's information.
- Type:
ASTNode
- Description: The
Identifier
node of this reference.
- Type:
Scope
- Description: The
Scope
object that this reference is on.
- Type:
Variable | null
- Description: The
Variable
object that this reference refers. If such variable was not defined, this isnull
.
- Type:
ASTNode | null
- Description: The ASTNode object which is right-hand side.
- Type:
boolean
- Description:
true
if this writing reference is a variable initializer or a default value.
- Parameters:
- Return type:
boolean
- Description:
true
if this reference is writing.
- Parameters:
- Return type:
boolean
- Description:
true
if this reference is reading.
- Parameters:
- Return type:
boolean
- Description:
true
if this reference is writing but not reading.
- Parameters:
- Return type:
boolean
- Description:
true
if this reference is reading but not writing.
- Parameters:
- Return type:
boolean
- Description:
true
if this reference is reading and writing.
Those members are defined but not used in ESLint.
- Type:
boolean
- Description: The
tainted
flag. (alwaysfalse
)
- Type:
number
- Description:
1
is reading,2
is writing,3
is reading/writing.
- Type:
boolean
- Description: The
partial
flag.
- Parameters:
- Return type:
boolean
- Description:
true
if this reference is resolved statically.
Definition
object is variable definition's information.
- Type:
string
- Description: The type of this definition. One of
"CatchClause"
,"ClassName"
,"FunctionName"
,"ImplicitGlobalVariable"
,"ImportBinding"
,"Parameter"
, and"Variable"
.
- Type:
ASTNode
- Description: The
Identifier
node of this definition.
- Type:
ASTNode
- Description: The enclosing node of the name.
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 |
- Type:
ASTNode | undefined | null
- Description: The enclosing statement node of the name.
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.
- Type:
number | undefined | null
- Description: The index in the declaration statement.
- Type:
string | undefined | null
- Description: The kind of the declaration statement.