docs/src/extend/scope-manager-interface.md
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[]Scopenode (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 | nullblock property is the node. This method never returns function-expression-name scope. If the node does not have their scope, this returns null.names (string[]) ... Names of variables to add to the global scope.undefinednode (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.
booleantrue if this program is module.booleantrue if this program is strict mode implicitly. I.e., options.impliedStrict === true.booleantrue if this program supports strict mode. I.e., options.ecmaVersion >= 5.node (ASTNode) ... An AST node to get their scope.Scope[] | nullblock 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", "class-field-initializer", "class-static-block", "for", "function", "function-expression-name", "global", "module", "switch", "with".booleantrue if this scope is strict mode.Scope | nullnull.Scope[]Scopetype is one of "class-field-initializer", "class-static-block", "function", "global", or "module". For the aforementioned scopes this is a self-reference.This represents the lowest enclosing function or top-level scope. Class field initializers and class static blocks are implicit functions. Historically, this was the scope which hosts variables that are defined by
vardeclarations, and thus the namevariableScope.
ASTNodeVariable[]Map<string, Variable>Reference[]Reference[]booleantrue if this scope is "function-expression-name" scope.This field exists only in the root Scope object (the global scope). It provides information about implicit global variables. Implicit global variables are variables that are neither built-in nor explicitly declared, but created implicitly by assigning values to undeclared variables in non-strict code. Variable objects for these variables are not present in the root Scope object's fields variables and set.
The value of the implicit field is an object with two properties.
Variable[]Map<string, Variable>::: tip
In Variable objects that represent implicit global variables, references is always an empty array. You can find references to these variables in the through field of the root Scope object (the global scope), among other unresolved references.
:::
Those members are defined but not used in ESLint.
Map<string, boolean>tainted flag.booleantrue if this scope is dynamic. I.e., the type of this scope is "global" or "with".booleantrue if this scope contains eval() invocations.booleantrue if this scope contains this.node (ASTNode) ... An AST node to get their reference object. The type of the node must be "Identifier".Reference | nullthis.references.find(r => r.identifier === node).boolean!this.dynamic.booleantrue if this is a "function" scope which has used arguments variable.booleanthis.thisFound.name (string) ... The name to check.booleantrue if a given name is used in variable names or reference names.Variable object is variable's information.
stringScopeASTNode[]Identifier nodes which define this variable. If this variable is redeclared, this array includes two or more nodes.Reference[]Definition[]Those members are defined but not used in ESLint.
booleantainted flag. (always false)booleanstack flag. (I'm not sure what this means.)Reference object is reference's information.
ASTNodeIdentifier or JSXIdentifier node of this reference.ScopeScope object that this reference is on.Variable | nullVariable object that this reference refers. If such variable was not defined, this is null.ASTNode | nullbooleantrue if this writing reference is a variable initializer or a default value.booleantrue if this reference is writing.booleantrue if this reference is reading.booleantrue if this reference is writing but not reading.booleantrue if this reference is reading but not writing.booleantrue if this reference is reading and writing.Those members are defined but not used in ESLint.
booleantainted flag. (always false)number1 is reading, 2 is writing, 3 is reading/writing.booleanpartial flag.booleantrue if this reference is resolved statically.Definition object is variable definition's information.
string"CatchClause", "ClassName", "FunctionName", "ImplicitGlobalVariable", "ImportBinding", "Parameter", and "Variable".ASTNodeIdentifier node of this definition.ASTNode| type | node |
|---|---|
"CatchClause" | CatchClause |
"ClassName" | ClassDeclaration or ClassExpression |
"FunctionName" | FunctionDeclaration or FunctionExpression |
"ImplicitGlobalVariable" | AssignmentExpression or ForInStatement or ForOfStatement |
"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 | nullstring | undefined | null