Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Upgrade: update dependencies after dropping support for Node <8 #53

Merged
merged 4 commits into from
Jul 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!.eslintrc.js
16 changes: 16 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict";

module.exports = {
root: true,
extends: [
"eslint"
],
overrides: [
{
files: ["tests/**/*"],
env: {
mocha: true
}
}
]
};
7 changes: 0 additions & 7 deletions .eslintrc.yml

This file was deleted.

5 changes: 1 addition & 4 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ target.test = function() {
let errors = 0;
const lastReturn = exec(`${ISTANBUL} cover ${MOCHA} -- -R progress -c ${TEST_FILES}`);



if (lastReturn.code !== 0) {
errors++;
}
Expand Down Expand Up @@ -131,8 +129,7 @@ target.checkLicenses = function() {
impermissible.forEach(dependency => {
console.error("%s license for %s is impermissible.",
dependency.licenses,
dependency.name
);
dependency.name);
});
exit(1);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function defaultOptions() {
directive: false,
nodejsScope: false,
impliedStrict: false,
sourceType: "script", // one of ['script', 'module']
sourceType: "script", // one of ['script', 'module']
ecmaVersion: 5,
childVisitorKeys: null,
fallback: "iteration"
Expand All @@ -93,7 +93,7 @@ function updateDeeply(target, override) {
}

for (const key in override) {
if (override.hasOwnProperty(key)) {
if (Object.prototype.hasOwnProperty.call(override, key)) {
Copy link
Member Author

@kaicataldo kaicataldo Jun 26, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

96:22  error  Do not access Object.prototype method 'hasOwnProperty' from target object  no-prototype-builtins

This was manually fixed.

const val = override[key];

if (isHashObject(val)) {
Expand Down
60 changes: 33 additions & 27 deletions lib/referencer.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class Importer extends esrecurse.Visitor {
this.declaration,
null,
null
));
));
});
}

Expand Down Expand Up @@ -151,20 +151,26 @@ class Referencer extends esrecurse.Visitor {
assignment.right,
maybeImplicitGlobal,
pattern !== assignment.left,
init);
init
);
});
}

visitPattern(node, options, callback) {
let visitPatternOptions = options;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

160:13  error  Assignment to function parameter 'callback'     no-param-reassign
161:13  error  Assignment to function parameter 'options'      no-param-reassign

This was manually fixed.

let visitPatternCallback = callback;

if (typeof options === "function") {
callback = options;
options = { processRightHandNodes: false };
visitPatternCallback = options;
visitPatternOptions = { processRightHandNodes: false };
}

traverseIdentifierInPattern(
this.options,
node,
options.processRightHandNodes ? this : null,
callback);
visitPatternOptions.processRightHandNodes ? this : null,
visitPatternCallback
);
}

visitFunction(node) {
Expand All @@ -180,14 +186,14 @@ class Referencer extends esrecurse.Visitor {

// id is defined in upper scope
this.currentScope().__define(node.id,
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
new Definition(
Variable.FunctionName,
node.id,
node,
null,
null,
null
));
}

// FunctionExpression with name creates its special scope;
Expand Down Expand Up @@ -258,14 +264,14 @@ class Referencer extends esrecurse.Visitor {
visitClass(node) {
if (node.type === Syntax.ClassDeclaration) {
this.currentScope().__define(node.id,
new Definition(
Variable.ClassName,
node.id,
node,
null,
null,
null
));
new Definition(
Variable.ClassName,
node.id,
node,
null,
null,
null
));
}

this.visit(node.superClass);
Expand All @@ -274,11 +280,11 @@ class Referencer extends esrecurse.Visitor {

if (node.id) {
this.currentScope().__define(node.id,
new Definition(
Variable.ClassName,
node.id,
node
));
new Definition(
Variable.ClassName,
node.id,
node
));
}
this.visit(node.body);

Expand Down
89 changes: 46 additions & 43 deletions lib/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class Scope {
*/
this.type = type;

/**
/**
* The scoped {@link Variable}s of this scope, as <code>{ Variable.name
* : Variable }</code>.
* @member {Map} Scope#set
Expand Down Expand Up @@ -192,21 +192,21 @@ class Scope {
*/
this.block = block;

/**
/**
* The {@link Reference|references} that are not resolved with this scope.
* @member {Reference[]} Scope#through
*/
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
*/
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
Expand All @@ -217,7 +217,7 @@ class Scope {
*/
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.
Expand All @@ -226,38 +226,38 @@ class Scope {
this.variableScope =
(this.type === "global" || this.type === "function" || this.type === "module") ? this : upperScope.variableScope;

/**
/**
* Whether this scope is created by a FunctionExpression.
* @member {boolean} Scope#functionExpressionScope
*/
this.functionExpressionScope = false;

/**
/**
* Whether this is a scope that contains an 'eval()' invocation.
* @member {boolean} Scope#directCallToEvalScope
*/
this.directCallToEvalScope = false;

/**
/**
* @member {boolean} Scope#thisFound
*/
this.thisFound = false;

this.__left = [];

/**
/**
* Reference to the parent {@link Scope|scope}.
* @member {Scope} Scope#upper
*/
this.upper = upperScope;

/**
/**
* Whether 'use strict' is in effect in this scope.
* @member {boolean} Scope#isStrict
*/
this.isStrict = isStrictScope(this, block, isMethodDefinition, scopeManager.__useDirective());

/**
/**
* List of nested {@link Scope}s.
* @member {Scope[]} Scope#childScopes
*/
Expand Down Expand Up @@ -414,11 +414,12 @@ class Scope {
__define(node, def) {
if (node && node.type === Syntax.Identifier) {
this.__defineGeneric(
node.name,
this.set,
this.variables,
node,
def);
node.name,
this.set,
this.variables,
node,
def
);
}
}

Expand Down Expand Up @@ -550,14 +551,14 @@ class GlobalScope extends Scope {
const info = implicit[i];

this.__defineImplicit(info.pattern,
new Definition(
Variable.ImplicitGlobalVariable,
info.pattern,
info.node,
null,
null,
null
));
new Definition(
Variable.ImplicitGlobalVariable,
info.pattern,
info.node,
null,
null,
null
));

}

Expand All @@ -569,11 +570,12 @@ class GlobalScope extends Scope {
__defineImplicit(node, def) {
if (node && node.type === Syntax.Identifier) {
this.__defineGeneric(
node.name,
this.implicit.set,
this.implicit.variables,
node,
def);
node.name,
this.implicit.set,
this.implicit.variables,
node,
def
);
}
}
}
Expand All @@ -588,14 +590,14 @@ class FunctionExpressionNameScope extends Scope {
constructor(scopeManager, upperScope, block) {
super(scopeManager, "function-expression-name", upperScope, block, false);
this.__define(block.id,
new Definition(
Variable.FunctionName,
block.id,
block,
null,
null,
null
));
new Definition(
Variable.FunctionName,
block.id,
block,
null,
null,
null
));
this.functionExpressionScope = true;
}
}
Expand Down Expand Up @@ -684,11 +686,12 @@ class FunctionScope extends Scope {

__defineArguments() {
this.__defineGeneric(
"arguments",
this.set,
this.variables,
null,
null);
"arguments",
this.set,
this.variables,
null,
null
);
this.taints.set("arguments", true);
}

Expand All @@ -710,7 +713,7 @@ class FunctionScope extends Scope {
// It's invalid resolution in the following case:
return !(
variable.scope === this &&
ref.identifier.range[0] < bodyStart && // the reference is in the parameter part.
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.
);
}
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,17 @@
"estraverse": "^4.1.1"
},
"devDependencies": {
"chai": "^3.4.1",
"eslint": "^3.15.0",
"eslint-config-eslint": "^4.0.0",
"@typescript-eslint/parser": "^1.11.0",
"chai": "^4.2.0",
"eslint": "^6.0.1",
"eslint-config-eslint": "^5.0.1",
"eslint-plugin-node": "^9.1.0",
"eslint-release": "^1.0.0",
"espree": "^3.1.1",
"espree": "^6.0.0",
"istanbul": "^0.4.5",
"mocha": "^3.2.0",
"mocha": "^6.1.4",
"npm-license": "^0.3.3",
"shelljs": "^0.7.6",
"typescript": "~2.0.10",
"typescript-eslint-parser": "^1.0.0"
"shelljs": "^0.8.3",
"typescript": "^3.5.2"
}
}
4 changes: 0 additions & 4 deletions tests/.eslintrc.yml

This file was deleted.

Loading