Socket
Socket
Sign inDemoInstall

eslint-scope

Package Overview
Dependencies
2
Maintainers
3
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.7.1 to 4.0.0-alpha.0

7

CHANGELOG.md

@@ -0,1 +1,8 @@

v4.0.0-alpha.0 - April 27, 2018
* 7cc3769 Upgrade: eslint-release ^0.11.1 (#36) (Teddy Katz)
* c9f6967 Breaking: remove TDZScope (refs eslint/eslint#10245) (#35) (Toru Nagashima)
* 982a71f Fix: wrong resolution about default parameters (#33) (Toru Nagashima)
* 57889f1 Docs: Remove extra header line from LICENSE (#32) (Gyandeep Singh)
v3.7.1 - April 12, 2017

@@ -2,0 +9,0 @@

84

lib/referencer.js

@@ -144,22 +144,2 @@ /*

materializeTDZScope(node, iterationNode) {
// http://people.mozilla.org/~jorendorff/es6-draft.html#sec-runtime-semantics-forin-div-ofexpressionevaluation-abstract-operation
// TDZ scope hides the declaration's names.
this.scopeManager.__nestTDZScope(node, iterationNode);
this.visitVariableDeclaration(this.currentScope(), Variable.TDZ, iterationNode.left, 0, true);
}
materializeIterationScope(node) {
// Generate iteration scope for upper ForIn/ForOf Statements.
const letOrConstDecl = node.left;
this.scopeManager.__nestForScope(node);
this.visitVariableDeclaration(this.currentScope(), Variable.Variable, letOrConstDecl, 0);
this.visitPattern(letOrConstDecl.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
}
referencingDefaultValue(pattern, assignments, maybeImplicitGlobal, init) {

@@ -292,3 +272,2 @@ const scope = this.currentScope();

// FIXME: Maybe consider TDZ.
this.visit(node.superClass);

@@ -331,42 +310,38 @@

if (node.left.type === Syntax.VariableDeclaration && node.left.kind !== "var") {
this.materializeTDZScope(node.right, node);
this.visit(node.right);
this.close(node.right);
this.scopeManager.__nestForScope(node);
}
this.materializeIterationScope(node);
this.visit(node.body);
this.close(node);
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
if (node.left.type === Syntax.VariableDeclaration) {
this.visit(node.left);
this.visitPattern(node.left.declarations[0].id, pattern => {
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, null, true, true);
});
} else {
this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
let maybeImplicitGlobal = null;
this.visitPattern(node.left, { processRightHandNodes: true }, (pattern, info) => {
let maybeImplicitGlobal = null;
if (!this.currentScope().isStrict) {
maybeImplicitGlobal = {
pattern,
node
};
}
this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
});
}
this.visit(node.right);
this.visit(node.body);
if (!this.currentScope().isStrict) {
maybeImplicitGlobal = {
pattern,
node
};
}
this.referencingDefaultValue(pattern, info.assignments, maybeImplicitGlobal, false);
this.currentScope().__referencing(pattern, Reference.WRITE, node.right, maybeImplicitGlobal, true, false);
});
}
this.visit(node.right);
this.visit(node.body);
this.close(node);
}
visitVariableDeclaration(variableTargetScope, type, node, index, fromTDZ) {
visitVariableDeclaration(variableTargetScope, type, node, index) {
// If this was called to initialize a TDZ scope, this needs to make definitions, but doesn't make references.
const decl = node.declarations[index];
const init = decl.init;
this.visitPattern(decl.id, { processRightHandNodes: !fromTDZ }, (pattern, info) => {
variableTargetScope.__define(pattern,
this.visitPattern(decl.id, { processRightHandNodes: true }, (pattern, info) => {
variableTargetScope.__define(
pattern,
new Definition(

@@ -379,7 +354,6 @@ type,

node.kind
));
)
);
if (!fromTDZ) {
this.referencingDefaultValue(pattern, info.assignments, null, true);
}
this.referencingDefaultValue(pattern, info.assignments, null, true);
if (init) {

@@ -386,0 +360,0 @@ this.currentScope().__referencing(pattern, Reference.WRITE, init, null, !info.topLevel, true);

@@ -39,3 +39,2 @@ /*

const ForScope = Scope.ForScope;
const TDZScope = Scope.TDZScope;
const FunctionExpressionNameScope = Scope.FunctionExpressionNameScope;

@@ -122,5 +121,2 @@ const BlockScope = Scope.BlockScope;

}
if (testScope.type === "TDZ") {
return false;
}
return true;

@@ -242,6 +238,2 @@ }

__nestTDZScope(node) {
return this.__nestScope(new TDZScope(this, this.__currentScope, node));
}
__nestFunctionExpressionNameScope(node) {

@@ -248,0 +240,0 @@ return this.__nestScope(new FunctionExpressionNameScope(this, this.__currentScope, node));

@@ -160,3 +160,3 @@ /*

/**
* One of 'TDZ', 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'.
* One of 'module', 'block', 'switch', 'function', 'catch', 'with', 'function', 'class', 'global'.
* @member {String} Scope#type

@@ -345,18 +345,28 @@ */

// To override by function scopes.
// References in default parameters isn't resolved to variables which are in their function body.
__isValidResolution(ref, variable) { // eslint-disable-line class-methods-use-this, no-unused-vars
return true;
}
__resolve(ref) {
const name = ref.identifier.name;
if (this.set.has(name)) {
const variable = this.set.get(name);
if (!this.set.has(name)) {
return false;
}
const variable = this.set.get(name);
variable.references.push(ref);
variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
if (ref.tainted) {
variable.tainted = true;
this.taints.set(variable.name, true);
}
ref.resolved = variable;
return true;
if (!this.__isValidResolution(ref, variable)) {
return false;
}
return false;
variable.references.push(ref);
variable.stack = variable.stack && ref.from.variableScope === this.variableScope;
if (ref.tainted) {
variable.tainted = true;
this.taints.set(variable.name, true);
}
ref.resolved = variable;
return true;
}

@@ -399,6 +409,4 @@

variable.defs.push(def);
if (def.type !== Variable.TDZ) {
this.__addDeclaredVariablesOfNode(variable, def.node);
this.__addDeclaredVariablesOfNode(variable, def.parent);
}
this.__addDeclaredVariablesOfNode(variable, def.node);
this.__addDeclaredVariablesOfNode(variable, def.parent);
}

@@ -627,8 +635,2 @@ if (node) {

class TDZScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "TDZ", upperScope, block, false);
}
}
class BlockScope extends Scope {

@@ -697,2 +699,25 @@ constructor(scopeManager, upperScope, block) {

}
// References in default parameters isn't resolved to variables which are in their function body.
// const x = 1
// function f(a = x) { // This `x` is resolved to the `x` in the outer scope.
// const x = 2
// console.log(a)
// }
__isValidResolution(ref, variable) {
// If `options.nodejsScope` is true, `this.block` becomes a Program node.
if (this.block.type === "Program") {
return true;
}
const bodyStart = this.block.body.range[0];
// It's invalid resolution in the following case:
return !(
variable.scope === this &&
ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
variable.defs.every(d => d.name.range[0] >= bodyStart) // the variable is in the body.
);
}
}

@@ -719,3 +744,2 @@

WithScope,
TDZScope,
BlockScope,

@@ -722,0 +746,0 @@ SwitchScope,

@@ -84,3 +84,2 @@ /*

Variable.ImportBinding = "ImportBinding";
Variable.TDZ = "TDZ";
Variable.ImplicitGlobalVariable = "ImplicitGlobalVariable";

@@ -87,0 +86,0 @@

@@ -6,3 +6,3 @@ {

"main": "lib/index.js",
"version": "3.7.1",
"version": "4.0.0-alpha.0",
"engines": {

@@ -38,3 +38,3 @@ "node": ">=4.0.0"

"eslint-config-eslint": "^4.0.0",
"eslint-release": "^0.10.1",
"eslint-release": "^0.11.1",
"espree": "^3.1.1",

@@ -41,0 +41,0 @@ "istanbul": "^0.4.5",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc