hermes-eslint
Advanced tools
Comparing version 0.4.1 to 0.4.3
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -54,2 +55,4 @@ */ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var Variable = require('./variable'); | ||
@@ -70,3 +73,27 @@ | ||
var Definition = function Definition(_ref) { | ||
var Definition = | ||
/** | ||
* Type of the occurrence (e.g. "Parameter", "Variable", ...). | ||
*/ | ||
/** | ||
* The identifier AST node of the occurrence. | ||
*/ | ||
/** | ||
* The enclosing node of the identifier. | ||
*/ | ||
/** | ||
* The enclosing statement node of the identifier. | ||
*/ | ||
/** | ||
* The index in the declaration statement. | ||
*/ | ||
/** | ||
* The kind of the declaration statement. | ||
*/ | ||
function Definition(_ref) { | ||
var type = _ref.type, | ||
@@ -81,30 +108,19 @@ name = _ref.name, | ||
/** | ||
* @member {String} Definition#type - type of the occurrence (e.g. "Parameter", "Variable", ...). | ||
*/ | ||
_defineProperty(this, "type", void 0); | ||
_defineProperty(this, "name", void 0); | ||
_defineProperty(this, "node", void 0); | ||
_defineProperty(this, "parent", void 0); | ||
_defineProperty(this, "index", void 0); | ||
_defineProperty(this, "kind", void 0); | ||
this.type = type; | ||
/** | ||
* @member {espree.Identifier} Definition#name - the identifier AST node of the occurrence. | ||
*/ | ||
this.name = name; | ||
/** | ||
* @member {espree.Node} Definition#node - the enclosing node of the identifier. | ||
*/ | ||
this.node = node; | ||
/** | ||
* @member {espree.Node?} Definition#parent - the enclosing statement node of the identifier. | ||
*/ | ||
this.parent = parent; | ||
/** | ||
* @member {Number?} Definition#index - the index in the declaration statement. | ||
*/ | ||
this.index = index; | ||
/** | ||
* @member {String?} Definition#kind - the kind of the declaration statement. | ||
*/ | ||
this.kind = kind; | ||
@@ -227,2 +243,5 @@ }; | ||
/** | ||
* Whether the parameter definition is a part of a rest parameter. | ||
*/ | ||
function ParameterDefinition(idNode, functionNode, index, rest) { | ||
@@ -239,7 +258,5 @@ var _this; | ||
}); | ||
/** | ||
* Whether the parameter definition is a part of a rest parameter. | ||
* @member {boolean} ParameterDefinition#rest | ||
*/ | ||
_defineProperty(_assertThisInitialized(_this), "rest", void 0); | ||
_this.rest = rest; | ||
@@ -323,2 +340,3 @@ return _this; | ||
ClassNameDefinition: ClassNameDefinition, | ||
Definition: Definition, | ||
DefinitionType: DefinitionType, | ||
@@ -325,0 +343,0 @@ EnumDefinition: EnumDefinition, |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -42,5 +43,10 @@ */ | ||
var READ = 0x1; | ||
var WRITE = 0x2; | ||
var RW = READ | WRITE; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var ReadWriteFlag = { | ||
READ: 0x1, | ||
WRITE: 0x2, | ||
RW: 0x3 | ||
}; | ||
/** | ||
@@ -50,44 +56,51 @@ * A Reference represents a single occurrence of an identifier in code. | ||
*/ | ||
var Reference = /*#__PURE__*/function () { | ||
/** | ||
* Identifier syntax node. | ||
*/ | ||
var Reference = /*#__PURE__*/function () { | ||
/** | ||
* Reference to the enclosing Scope. | ||
*/ | ||
/** | ||
* The variable this reference is resolved with. | ||
*/ | ||
/** | ||
* The read-write mode of the reference. | ||
*/ | ||
/** | ||
* If reference is writeable, this is the tree being written to it. | ||
*/ | ||
/** | ||
* Whether the Reference is to write of initialization. | ||
*/ | ||
function Reference(ident, scope, flag, writeExpr, maybeImplicitGlobal, init, isTypeReference) { | ||
_classCallCheck(this, Reference); | ||
/** | ||
* Identifier syntax node. | ||
* @member {espreeIdentifier} Reference#identifier | ||
*/ | ||
this.identifier = ident; | ||
/** | ||
* Reference to the enclosing Scope. | ||
* @member {Scope} Reference#from | ||
*/ | ||
_defineProperty(this, "identifier", void 0); | ||
this.from = scope; | ||
/** | ||
* The variable this reference is resolved with. | ||
* @member {Variable} Reference#resolved | ||
*/ | ||
_defineProperty(this, "from", void 0); | ||
this.resolved = null; | ||
/** | ||
* The read-write mode of the reference. (Value is one of {@link | ||
* Reference.READ}, {@link Reference.RW}, {@link Reference.WRITE}). | ||
* @member {number} Reference#flag | ||
* @private | ||
*/ | ||
_defineProperty(this, "resolved", null); | ||
_defineProperty(this, "flag", void 0); | ||
_defineProperty(this, "writeExpr", void 0); | ||
_defineProperty(this, "init", void 0); | ||
_defineProperty(this, "__maybeImplicitGlobal", void 0); | ||
_defineProperty(this, "__isTypeReference", void 0); | ||
this.identifier = ident; | ||
this.from = scope; | ||
this.flag = flag; | ||
if (this.isWrite()) { | ||
/** | ||
* If reference is writeable, this is the tree being written to it. | ||
* @member {espreeNode} Reference#writeExpr | ||
*/ | ||
this.writeExpr = writeExpr; | ||
/** | ||
* Whether the Reference is to write of initialization. | ||
* @member {boolean} Reference#init | ||
*/ | ||
this.init = init; | ||
@@ -101,4 +114,2 @@ } | ||
* Whether the reference is static. | ||
* @method Reference#isStatic | ||
* @returns {boolean} static | ||
*/ | ||
@@ -110,8 +121,6 @@ | ||
value: function isStatic() { | ||
return this.resolved && this.resolved.scope.isStatic(); | ||
return this.resolved != null && this.resolved.scope.isStatic(); | ||
} | ||
/** | ||
* Whether the reference is writeable. | ||
* @method Reference#isWrite | ||
* @returns {boolean} write | ||
*/ | ||
@@ -122,8 +131,6 @@ | ||
value: function isWrite() { | ||
return !!(this.flag & Reference.WRITE); | ||
return !!(this.flag & ReadWriteFlag.WRITE); | ||
} | ||
/** | ||
* Whether the reference is readable. | ||
* @method Reference#isRead | ||
* @returns {boolean} read | ||
*/ | ||
@@ -134,8 +141,6 @@ | ||
value: function isRead() { | ||
return !!(this.flag & Reference.READ); | ||
return !!(this.flag & ReadWriteFlag.READ); | ||
} | ||
/** | ||
* Whether the reference is read-only. | ||
* @method Reference#isReadOnly | ||
* @returns {boolean} read only | ||
*/ | ||
@@ -146,8 +151,6 @@ | ||
value: function isReadOnly() { | ||
return this.flag === Reference.READ; | ||
return this.flag === ReadWriteFlag.READ; | ||
} | ||
/** | ||
* Whether the reference is write-only. | ||
* @method Reference#isWriteOnly | ||
* @returns {boolean} write only | ||
*/ | ||
@@ -158,8 +161,6 @@ | ||
value: function isWriteOnly() { | ||
return this.flag === Reference.WRITE; | ||
return this.flag === ReadWriteFlag.WRITE; | ||
} | ||
/** | ||
* Whether the reference is read-write. | ||
* @method Reference#isReadWrite | ||
* @returns {boolean} read write | ||
*/ | ||
@@ -170,3 +171,3 @@ | ||
value: function isReadWrite() { | ||
return this.flag === Reference.RW; | ||
return this.flag === ReadWriteFlag.RW; | ||
} | ||
@@ -195,21 +196,6 @@ /** | ||
}(); | ||
/** | ||
* @constant Reference.READ | ||
* @private | ||
*/ | ||
Reference.READ = READ; | ||
/** | ||
* @constant Reference.WRITE | ||
* @private | ||
*/ | ||
Reference.WRITE = WRITE; | ||
/** | ||
* @constant Reference.RW | ||
* @private | ||
*/ | ||
Reference.RW = RW; | ||
module.exports = Reference; | ||
module.exports = { | ||
ReadWriteFlag: ReadWriteFlag, | ||
Reference: Reference | ||
}; |
@@ -67,3 +67,5 @@ /** | ||
var Reference = require('./reference'); | ||
var _require = require('./reference'), | ||
ReadWriteFlag = _require.ReadWriteFlag, | ||
Reference = _require.Reference; | ||
@@ -74,13 +76,13 @@ var Variable = require('./variable'); | ||
var _require = require('./definition'), | ||
CatchClauseDefinition = _require.CatchClauseDefinition, | ||
ClassNameDefinition = _require.ClassNameDefinition, | ||
DefinitionType = _require.DefinitionType, | ||
EnumDefinition = _require.EnumDefinition, | ||
FunctionNameDefinition = _require.FunctionNameDefinition, | ||
ImportBindingDefinition = _require.ImportBindingDefinition, | ||
ParameterDefinition = _require.ParameterDefinition, | ||
TypeDefinition = _require.TypeDefinition, | ||
TypeParameterDefinition = _require.TypeParameterDefinition, | ||
VariableDefinition = _require.VariableDefinition; | ||
var _require2 = require('./definition'), | ||
CatchClauseDefinition = _require2.CatchClauseDefinition, | ||
ClassNameDefinition = _require2.ClassNameDefinition, | ||
DefinitionType = _require2.DefinitionType, | ||
EnumDefinition = _require2.EnumDefinition, | ||
FunctionNameDefinition = _require2.FunctionNameDefinition, | ||
ImportBindingDefinition = _require2.ImportBindingDefinition, | ||
ParameterDefinition = _require2.ParameterDefinition, | ||
TypeDefinition = _require2.TypeDefinition, | ||
TypeParameterDefinition = _require2.TypeParameterDefinition, | ||
VariableDefinition = _require2.VariableDefinition; | ||
@@ -198,3 +200,3 @@ var assert = require('assert'); // Importing ImportDeclaration. | ||
assignments.forEach(function (assignment) { | ||
scope.__referencingValue(pattern, Reference.WRITE, assignment.right, maybeImplicitGlobal, init); | ||
scope.__referencingValue(pattern, ReadWriteFlag.WRITE, assignment.right, maybeImplicitGlobal, init); | ||
}); | ||
@@ -397,3 +399,3 @@ } | ||
this.visitPattern(node.left.declarations[0].id, function (pattern) { | ||
_this5.currentScope().__referencingValue(pattern, Reference.WRITE, node.right, null, true); | ||
_this5.currentScope().__referencingValue(pattern, ReadWriteFlag.WRITE, node.right, null, true); | ||
}); | ||
@@ -415,3 +417,3 @@ } else { | ||
_this5.currentScope().__referencingValue(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, false); | ||
_this5.currentScope().__referencingValue(pattern, ReadWriteFlag.WRITE, node.right, maybeImplicitGlobal, false); | ||
}); | ||
@@ -439,3 +441,3 @@ } | ||
if (init) { | ||
_this6.currentScope().__referencingValue(pattern, Reference.WRITE, init, null, true); | ||
_this6.currentScope().__referencingValue(pattern, ReadWriteFlag.WRITE, init, null, true); | ||
} | ||
@@ -465,6 +467,6 @@ }); | ||
_this7.currentScope().__referencingValue(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, false); | ||
_this7.currentScope().__referencingValue(pattern, ReadWriteFlag.WRITE, node.right, maybeImplicitGlobal, false); | ||
}); | ||
} else { | ||
this.currentScope().__referencingValue(node.left, Reference.RW, node.right); | ||
this.currentScope().__referencingValue(node.left, ReadWriteFlag.RW, node.right); | ||
} | ||
@@ -517,3 +519,3 @@ } else { | ||
if (PatternVisitor.isPattern(node.argument)) { | ||
this.currentScope().__referencingValue(node.argument, Reference.RW, null); | ||
this.currentScope().__referencingValue(node.argument, ReadWriteFlag.RW, null); | ||
} else { | ||
@@ -520,0 +522,0 @@ this.visitChildren(node); |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -42,2 +43,4 @@ */ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var _require = require('./scope'), | ||
@@ -59,7 +62,6 @@ BlockScope = _require.BlockScope, | ||
var assert = require('assert'); | ||
/** | ||
* @class ScopeManager | ||
*/ | ||
var ScopeManager = /*#__PURE__*/function () { | ||
@@ -69,8 +71,15 @@ function ScopeManager(options) { | ||
this.scopes = []; | ||
this.globalScope = null; | ||
this.__nodeToScope = new WeakMap(); | ||
this.__currentScope = null; | ||
_defineProperty(this, "scopes", []); | ||
_defineProperty(this, "globalScope", null); | ||
_defineProperty(this, "__nodeToScope", new WeakMap()); | ||
_defineProperty(this, "__currentScope", null); | ||
_defineProperty(this, "__options", void 0); | ||
_defineProperty(this, "__declaredVariables", new WeakMap()); | ||
this.__options = options; | ||
this.__declaredVariables = new WeakMap(); | ||
} | ||
@@ -77,0 +86,0 @@ |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -62,12 +63,16 @@ */ | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
var Syntax = require('estraverse').Syntax; | ||
var Reference = require('./reference'); | ||
var _require = require('./reference'), | ||
ReadWriteFlag = _require.ReadWriteFlag, | ||
Reference = _require.Reference; | ||
var Variable = require('./variable'); | ||
var _require = require('./definition'), | ||
DefinitionType = _require.DefinitionType, | ||
FunctionNameDefinition = _require.FunctionNameDefinition, | ||
ImplicitGlobalVariableDefinition = _require.ImplicitGlobalVariableDefinition; | ||
var _require2 = require('./definition'), | ||
DefinitionType = _require2.DefinitionType, | ||
FunctionNameDefinition = _require2.FunctionNameDefinition, | ||
ImplicitGlobalVariableDefinition = _require2.ImplicitGlobalVariableDefinition; | ||
@@ -92,6 +97,2 @@ var assert = require('assert'); | ||
* Test if scope is strict | ||
* @param {Scope} scope - scope | ||
* @param {Block} block - block | ||
* @param {boolean} isMethodDefinition - is method definition | ||
* @returns {boolean} is strict scope | ||
*/ | ||
@@ -167,5 +168,2 @@ | ||
* Register scope | ||
* @param {ScopeManager} scopeManager - scope manager | ||
* @param {Scope} scope - scope | ||
* @returns {void} | ||
*/ | ||
@@ -187,4 +185,2 @@ | ||
* Should be statically closed | ||
* @param {Object} def - def | ||
* @returns {boolean} should be statically closed | ||
*/ | ||
@@ -194,3 +190,5 @@ | ||
function shouldBeStaticallyClosed(def) { | ||
return def.type === DefinitionType.ClassName || def.type === DefinitionType.Enum || def.type === DefinitionType.Type || def.type === DefinitionType.Variable && def.parent.kind !== 'var'; | ||
var _def$parent; | ||
return def.type === DefinitionType.ClassName || def.type === DefinitionType.Enum || def.type === DefinitionType.Type || def.type === DefinitionType.Variable && ((_def$parent = def.parent) === null || _def$parent === void 0 ? void 0 : _def$parent.kind) !== 'var'; | ||
} | ||
@@ -203,105 +201,114 @@ /** | ||
var Scope = /*#__PURE__*/function () { | ||
/** | ||
* The type of the scope. | ||
*/ | ||
/** | ||
* The scoped {@link Variable}s of this scope, as <code>{ Variable.name | ||
* : Variable }</code>. | ||
*/ | ||
/** | ||
* Generally, through the lexical scoping of JS you can always know | ||
* which variable an identifier in the source code refers to. There are | ||
* a few exceptions to this rule. With 'global' and 'with' scopes you | ||
* can only decide at runtime which variable a reference refers to. | ||
* Moreover, if 'eval()' is used in a scope, it might introduce new | ||
* bindings in this or its parent scopes. | ||
* All those scopes are considered 'dynamic'. | ||
*/ | ||
/** | ||
* A reference to the scope-defining syntax node. | ||
*/ | ||
/** | ||
* The {@link Reference|references} that are not resolved with this scope. | ||
*/ | ||
/** | ||
* The scoped {@link Variable}s of this scope. In the case of a | ||
* 'function' scope this includes the automatic argument <em>arguments</em> as | ||
* its first element, as well as all further formal arguments. | ||
*/ | ||
/** | ||
* Any variable {@link Reference|reference} found in this scope. This | ||
* includes occurrences of local variables as well as variables from | ||
* parent scopes (including the global scope). For local variables | ||
* this also includes defining occurrences (like in a 'var' statement). | ||
* In a 'function' scope this does not include the occurrences of the | ||
* formal parameter in the parameter list. | ||
*/ | ||
/** | ||
* For 'global' and 'function' scopes, this is a self-reference. For | ||
* other scope types this is the <em>variableScope</em> value of the | ||
* parent scope. | ||
*/ | ||
/** | ||
* Whether this scope is created by a FunctionExpression. | ||
*/ | ||
/** | ||
* List of {@link Reference}s that are left to be resolved (i.e. which | ||
* need to be linked to the variable they refer to). | ||
*/ | ||
/** | ||
* Reference to the parent {@link Scope|scope}. | ||
*/ | ||
/** | ||
* Whether 'use strict' is in effect in this scope. | ||
*/ | ||
/** | ||
* List of nested {@link Scope}s. | ||
*/ | ||
function Scope(scopeManager, type, upperScope, block, isMethodDefinition) { | ||
_classCallCheck(this, Scope); | ||
/** | ||
* One of 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'. | ||
* @member {String} Scope#type | ||
*/ | ||
this.type = type; | ||
/** | ||
* The scoped {@link Variable}s of this scope, as <code>{ Variable.name | ||
* : Variable }</code>. | ||
* @member {Map} Scope#set | ||
*/ | ||
_defineProperty(this, "type", void 0); | ||
this.set = new Map(); | ||
/** | ||
* Generally, through the lexical scoping of JS you can always know | ||
* which variable an identifier in the source code refers to. There are | ||
* a few exceptions to this rule. With 'global' and 'with' scopes you | ||
* can only decide at runtime which variable a reference refers to. | ||
* Moreover, if 'eval()' is used in a scope, it might introduce new | ||
* bindings in this or its parent scopes. | ||
* All those scopes are considered 'dynamic'. | ||
* @member {boolean} Scope#dynamic | ||
*/ | ||
_defineProperty(this, "set", new Map()); | ||
this.dynamic = this.type === ScopeType.Global || this.type === ScopeType.With; | ||
/** | ||
* A reference to the scope-defining syntax node. | ||
* @member {espree.Node} Scope#block | ||
*/ | ||
_defineProperty(this, "dynamic", void 0); | ||
this.block = block; | ||
/** | ||
* The {@link Reference|references} that are not resolved with this scope. | ||
* @member {Reference[]} Scope#through | ||
*/ | ||
_defineProperty(this, "block", void 0); | ||
this.through = []; | ||
/** | ||
* The scoped {@link Variable}s of this scope. In the case of a | ||
* 'function' scope this includes the automatic argument <em>arguments</em> as | ||
* its first element, as well as all further formal arguments. | ||
* @member {Variable[]} Scope#variables | ||
*/ | ||
_defineProperty(this, "through", []); | ||
this.variables = []; | ||
/** | ||
* Any variable {@link Reference|reference} found in this scope. This | ||
* includes occurrences of local variables as well as variables from | ||
* parent scopes (including the global scope). For local variables | ||
* this also includes defining occurrences (like in a 'var' statement). | ||
* In a 'function' scope this does not include the occurrences of the | ||
* formal parameter in the parameter list. | ||
* @member {Reference[]} Scope#references | ||
*/ | ||
_defineProperty(this, "variables", []); | ||
this.references = []; | ||
/** | ||
* For 'global' and 'function' scopes, this is a self-reference. For | ||
* other scope types this is the <em>variableScope</em> value of the | ||
* parent scope. | ||
* @member {Scope} Scope#variableScope | ||
*/ | ||
_defineProperty(this, "references", []); | ||
this.variableScope = this.type === ScopeType.Global || this.type === ScopeType.Function || this.type === ScopeType.Module || this.type === ScopeType.DeclareModule ? this : upperScope.variableScope; | ||
/** | ||
* Whether this scope is created by a FunctionExpression. | ||
* @member {boolean} Scope#functionExpressionScope | ||
*/ | ||
_defineProperty(this, "variableScope", void 0); | ||
this.functionExpressionScope = false; | ||
/** | ||
* @member {boolean} Scope#thisFound | ||
*/ | ||
_defineProperty(this, "functionExpressionScope", false); | ||
this.thisFound = false; | ||
/** | ||
* List of {@link Reference}s that are left to be resolved (i.e. which | ||
* need to be linked to the variable they refer to). | ||
* @member {Reference[]} Scope#__referencesLeftToResolve | ||
*/ | ||
_defineProperty(this, "thisFound", false); | ||
this.__referencesLeftToResolve = []; | ||
/** | ||
* Reference to the parent {@link Scope|scope}. | ||
* @member {Scope} Scope#upper | ||
*/ | ||
_defineProperty(this, "__referencesLeftToResolve", []); | ||
_defineProperty(this, "upper", void 0); | ||
_defineProperty(this, "isStrict", void 0); | ||
_defineProperty(this, "childScopes", []); | ||
_defineProperty(this, "__declaredVariables", void 0); | ||
_defineProperty(this, "__isClosed", false); | ||
this.type = type; | ||
this.set = new Map(); | ||
this.dynamic = this.type === ScopeType.Global || this.type === ScopeType.With; | ||
this.block = block; | ||
this.variableScope = this.type === ScopeType.Global || this.type === ScopeType.Function || this.type === ScopeType.Module || this.type === ScopeType.DeclareModule ? this : // $FlowFixMe[incompatible-use] upperScope can only be null for Global scope | ||
upperScope.variableScope; | ||
this.upper = upperScope; | ||
/** | ||
* Whether 'use strict' is in effect in this scope. | ||
* @member {boolean} Scope#isStrict | ||
*/ | ||
this.isStrict = isStrictScope(this, block, isMethodDefinition); | ||
/** | ||
* List of nested {@link Scope}s. | ||
* @member {Scope[]} Scope#childScopes | ||
*/ | ||
this.childScopes = []; | ||
if (this.upper) { | ||
@@ -325,8 +332,8 @@ this.upper.childScopes.push(this); | ||
var name = ref.identifier.name; | ||
var variable = this.set.get(name); | ||
if (!this.set.has(name)) { | ||
if (variable == null) { | ||
return false; | ||
} | ||
var variable = this.set.get(name); | ||
var defs = variable.defs; | ||
@@ -383,3 +390,4 @@ return defs.length > 0 && defs.every(shouldBeStaticallyClosed); | ||
this.__referencesLeftToResolve = null; | ||
this.__referencesLeftToResolve = []; | ||
this.__isClosed = true; | ||
return this.upper; | ||
@@ -401,9 +409,8 @@ } | ||
var name = ref.identifier.name; | ||
var variable = this.set.get(name); | ||
if (!this.set.has(name)) { | ||
if (variable == null) { | ||
return false; | ||
} | ||
var variable = this.set.get(name); | ||
if (!this.__isValidResolution(ref, variable)) { | ||
@@ -449,8 +456,11 @@ return false; | ||
var variable; | ||
variable = set.get(name); | ||
var existingVariable = set.get(name); | ||
if (!variable) { | ||
variable = new Variable(name, this); | ||
set.set(name, variable); | ||
variables.push(variable); | ||
if (!existingVariable) { | ||
var newVariable = new Variable(name, this); | ||
set.set(name, newVariable); | ||
variables.push(newVariable); | ||
variable = newVariable; | ||
} else { | ||
variable = existingVariable; | ||
} | ||
@@ -494,3 +504,3 @@ | ||
/* scope */ | ||
, assign || Reference.READ | ||
, assign || ReadWriteFlag.READ | ||
/* read-write flag */ | ||
@@ -517,3 +527,3 @@ , writeExpr | ||
/* scope */ | ||
, Reference.READ | ||
, ReadWriteFlag.READ | ||
/* read-write flag */ | ||
@@ -538,7 +548,2 @@ , null | ||
} | ||
}, { | ||
key: "__isClosed", | ||
value: function __isClosed() { | ||
return this.__referencesLeftToResolve === null; | ||
} | ||
/** | ||
@@ -555,3 +560,3 @@ * returns resolved {Reference} | ||
var ref, i, iz; | ||
assert(this.__isClosed(), 'Scope should be closed.'); | ||
assert(this.__isClosed, 'Scope should be closed.'); | ||
assert(ident.type === Syntax.Identifier, 'Target should be identifier.'); | ||
@@ -571,4 +576,2 @@ | ||
* returns this scope is static | ||
* @method Scope#isStatic | ||
* @returns {boolean} static | ||
*/ | ||
@@ -583,4 +586,2 @@ | ||
* returns this scope has materialized arguments | ||
* @method Scope#isArgumentsMaterialized | ||
* @returns {boolean} arguemnts materialized | ||
*/ | ||
@@ -595,4 +596,2 @@ | ||
* returns this scope has materialized `this` reference | ||
* @method Scope#isThisMaterialized | ||
* @returns {boolean} this materialized | ||
*/ | ||
@@ -636,2 +635,5 @@ | ||
_this = _super.call(this, scopeManager, ScopeType.Global, null, block, false); | ||
_defineProperty(_assertThisInitialized(_this), "implicit", void 0); | ||
_this.implicit = { | ||
@@ -753,3 +755,4 @@ set: new Map(), | ||
this.__referencesLeftToResolve = null; | ||
this.__referencesLeftToResolve = []; | ||
this.__isClosed = true; | ||
return this.upper; | ||
@@ -831,3 +834,3 @@ } | ||
assert(variable, 'Always have arguments variable.'); | ||
return variable.references.length !== 0; | ||
return (variable === null || variable === void 0 ? void 0 : variable.references.length) !== 0; | ||
} | ||
@@ -834,0 +837,0 @@ }, { |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -35,2 +36,7 @@ */ | ||
'use strict'; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
/** | ||
@@ -41,40 +47,40 @@ * A Variable represents a locally scoped identifier. These include arguments to | ||
*/ | ||
var Variable = | ||
/** | ||
* The variable name, as given in the source code. | ||
*/ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
/** | ||
* List of defining occurrences of this variable (like in 'var ...' | ||
* statements or as parameter), as AST nodes. | ||
*/ | ||
var Variable = function Variable(name, scope) { | ||
/** | ||
* List of references of this variable (excluding parameter entries) | ||
* in its defining scope and all nested scopes. For defining | ||
* occurrences only see defs. | ||
*/ | ||
/** | ||
* List of defining occurrences of this variable (like in 'var ...' | ||
* statements or as parameter), as custom objects. | ||
*/ | ||
/** | ||
* Reference to the enclosing Scope. | ||
*/ | ||
function Variable(name, scope) { | ||
_classCallCheck(this, Variable); | ||
/** | ||
* The variable name, as given in the source code. | ||
* @member {String} Variable#name | ||
*/ | ||
this.name = name; | ||
/** | ||
* List of defining occurrences of this variable (like in 'var ...' | ||
* statements or as parameter), as AST nodes. | ||
* @member {espree.Identifier[]} Variable#identifiers | ||
*/ | ||
_defineProperty(this, "name", void 0); | ||
this.identifiers = []; | ||
/** | ||
* List of {@link Reference|references} of this variable (excluding parameter entries) | ||
* in its defining scope and all nested scopes. For defining | ||
* occurrences only see {@link Variable#defs}. | ||
* @member {Reference[]} Variable#references | ||
*/ | ||
_defineProperty(this, "identifiers", []); | ||
this.references = []; | ||
/** | ||
* List of defining occurrences of this variable (like in 'var ...' | ||
* statements or as parameter), as custom objects. | ||
* @member {Definition[]} Variable#defs | ||
*/ | ||
_defineProperty(this, "references", []); | ||
this.defs = []; | ||
/** | ||
* Reference to the enclosing Scope. | ||
* @member {Scope} Variable#scope | ||
*/ | ||
_defineProperty(this, "defs", []); | ||
_defineProperty(this, "scope", void 0); | ||
this.name = name; | ||
this.scope = scope; | ||
@@ -81,0 +87,0 @@ }; |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -9,0 +10,0 @@ */ |
@@ -7,2 +7,3 @@ /** | ||
* | ||
* | ||
* @format | ||
@@ -9,0 +10,0 @@ */ |
{ | ||
"name": "hermes-eslint", | ||
"version": "0.4.1", | ||
"version": "0.4.3", | ||
"description": "A custom parser for ESLint using the Hermes parser", | ||
@@ -17,4 +17,4 @@ "main": "dist/index.js", | ||
"estraverse": "^4.1.1", | ||
"hermes-parser": "0.4.1" | ||
"hermes-parser": "0.4.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
118500
18
2725
1
+ Addedhermes-parser@0.4.3(transitive)
- Removedhermes-parser@0.4.1(transitive)
Updatedhermes-parser@0.4.3