Browse Source

Makes Network, DataSet and DataView eslint compliant (#3304)

* Makes network eslint compliant
Unused variables in private functions, who were never called internally with those arguments were removed.
lint rule was disabled for public functions, and in private functions which were called internally with those unused arguments

* Disables linting for unused args passed into DataSet and DataView
revert-3409-performance
macleodbroad-wf 7 years ago
committed by Yotam Berkowitz
parent
commit
0df59c8f41
21 changed files with 49 additions and 52 deletions
  1. +1
    -1
      lib/DataSet.js
  2. +1
    -1
      lib/DataView.js
  3. +2
    -1
      lib/network/CachedImage.js
  4. +1
    -1
      lib/network/Images.js
  5. +0
    -2
      lib/network/Network.js
  6. +2
    -2
      lib/network/gephiParser.js
  7. +1
    -1
      lib/network/modules/Canvas.js
  8. +1
    -1
      lib/network/modules/Clustering.js
  9. +0
    -1
      lib/network/modules/EdgesHandler.js
  10. +10
    -9
      lib/network/modules/LayoutEngine.js
  11. +4
    -3
      lib/network/modules/ManipulationSystem.js
  12. +1
    -1
      lib/network/modules/View.js
  13. +0
    -1
      lib/network/modules/components/NavigationHandler.js
  14. +0
    -1
      lib/network/modules/components/Node.js
  15. +6
    -4
      lib/network/modules/components/edges/util/EdgeBase.js
  16. +2
    -2
      lib/network/modules/components/nodes/shapes/Circle.js
  17. +1
    -1
      lib/network/modules/components/nodes/shapes/CircularImage.js
  18. +1
    -1
      lib/network/modules/components/nodes/shapes/Dot.js
  19. +3
    -5
      lib/network/modules/components/nodes/util/CircleImageBase.js
  20. +2
    -3
      lib/network/modules/components/physics/HierarchicalSpringSolver.js
  21. +10
    -10
      lib/network/modules/components/shared/Label.js

+ 1
- 1
lib/DataSet.js View File

@ -321,7 +321,7 @@ DataSet.prototype.update = function (data, senderId) {
* {String | function} [order] Order the items by a field name or custom sort function.
* @throws Error
*/
DataSet.prototype.get = function (args) {
DataSet.prototype.get = function (args) { // eslint-disable-line no-unused-vars
var me = this;
// parse the arguments

+ 1
- 1
lib/DataView.js View File

@ -158,7 +158,7 @@ DataView.prototype.refresh = function () {
* DataTable.
* @param args
*/
DataView.prototype.get = function (args) {
DataView.prototype.get = function (args) { // eslint-disable-line no-unused-vars
var me = this;
// parse the arguments

+ 2
- 1
lib/network/CachedImage.js View File

@ -9,6 +9,7 @@
* for svg, but the mipmapping may not be necessary.
*/
class CachedImage {
// eslint-disable-next-line no-unused-vars
constructor(image) {
this.NUM_ITERATIONS = 4; // Number of items in the coordinates array
@ -138,7 +139,7 @@ class CachedImage {
*
* @private
*/
_isImageOk(img) {
_isImageOk() {
var img = this.image;
// During the onload event, IE correctly identifies any images that

+ 1
- 1
lib/network/Images.js View File

@ -50,7 +50,7 @@ class Images {
* @param {string} brokenUrl Url of an image to use if the url image is not found
* @return {Image} img The image object
*/
load (url, brokenUrl, id) {
load (url, brokenUrl, id) { // eslint-disable-line no-unused-vars
//Try and get the image from the cache, if successful then return the cached image
var cachedImage = this.images[url];
if (cachedImage) return cachedImage;

+ 0
- 2
lib/network/Network.js View File

@ -3,8 +3,6 @@ require('./shapes');
let Emitter = require('emitter-component');
let util = require('../util');
let DataSet = require('../DataSet');
let DataView = require('../DataView');
let dotparser = require('./dotparser');
let gephiParser = require('./gephiParser');
let Activator = require('../shared/Activator');

+ 2
- 2
lib/network/gephiParser.js View File

@ -40,9 +40,9 @@ function parseGephi(gephiJSON, optionsObj) {
edges.push(edge);
}
for (var i = 0; i < gNodes.length; i++) {
for (var j = 0; j < gNodes.length; j++) {
var node = {};
var gNode = gNodes[i];
var gNode = gNodes[j];
node['id'] = gNode.id;
node['attributes'] = gNode.attributes;
node['x'] = gNode.x;

+ 1
- 1
lib/network/modules/Canvas.js View File

@ -330,7 +330,7 @@ class Canvas {
// set initialized so the get and set camera will work from now on.
this.initialized = true;
return emitEvent;
};
}
getContext() {

+ 1
- 1
lib/network/modules/Clustering.js View File

@ -902,7 +902,7 @@ class ClusterEngine {
}
return hubThreshold;
};
}
/**

+ 0
- 1
lib/network/modules/EdgesHandler.js View File

@ -4,7 +4,6 @@ var DataView = require('../../DataView');
var Edge = require("./components/Edge").default;
var Label = require("./components/shared/Label").default;
var LayoutEngine = require("./LayoutEngine").default; // For access to LayoutEngine.getStaticType()
class EdgesHandler {
constructor(body, images, groups) {

+ 10
- 9
lib/network/modules/LayoutEngine.js View File

@ -616,7 +616,6 @@ class LayoutEngine {
// get the size of the largest hubs and check if the user has defined a level for a node.
let node, nodeId;
let definedLevel = false;
let definedPositions = true;
let undefinedLevel = false;
this.lastNodeOnLevel = {};
this.hierarchical = new HierarchicalStatus();
@ -624,9 +623,6 @@ class LayoutEngine {
for (nodeId in this.body.nodes) {
if (this.body.nodes.hasOwnProperty(nodeId)) {
node = this.body.nodes[nodeId];
if (node.options.x === undefined && node.options.y === undefined) {
definedPositions = false;
}
if (node.options.level !== undefined) {
definedLevel = true;
this.hierarchical.levels[nodeId] = node.options.level;
@ -779,7 +775,7 @@ class LayoutEngine {
}
return [min, max, minSpace, maxSpace];
};
}
// check what the maximum level is these nodes have in common.
@ -832,8 +828,11 @@ class LayoutEngine {
// check the largest distance between the branches
let maxLevel = getCollisionLevel(node1, node2);
let [min1,max1, minSpace1, maxSpace1] = getBranchBoundary(branchNodes1, maxLevel);
let [min2,max2, minSpace2, maxSpace2] = getBranchBoundary(branchNodes2, maxLevel);
let branchNodeBoundary1 = getBranchBoundary(branchNodes1, maxLevel);
let branchNodeBoundary2 = getBranchBoundary(branchNodes2, maxLevel);
let max1 = branchNodeBoundary1[1];
let min2 = branchNodeBoundary2[0];
let minSpace2 = branchNodeBoundary2[2];
//console.log(node1.id, getBranchBoundary(branchNodes1, maxLevel), node2.id,
// getBranchBoundary(branchNodes2, maxLevel), maxLevel);
@ -935,7 +934,9 @@ class LayoutEngine {
getBranchNodes(node, branchNodes);
branches[node.id] = branchNodes;
}
let [minBranch, maxBranch, minSpaceBranch, maxSpaceBranch] = getBranchBoundary(branches[node.id]);
let branchBoundary = getBranchBoundary(branches[node.id]);
let minSpaceBranch = branchBoundary[2];
let maxSpaceBranch = branchBoundary[3];
let diff = guess - nodePosition;
@ -1389,7 +1390,7 @@ class LayoutEngine {
let minLevel = 100000;
// TODO: this should come from options.
let customCallback = function(nodeA, nodeB, edge) {
let customCallback = function(nodeA, nodeB, edge) { // eslint-disable-line no-unused-vars
};

+ 4
- 3
lib/network/modules/ManipulationSystem.js View File

@ -696,10 +696,11 @@ class ManipulationSystem {
}
_createDeleteButton(locale) {
var deleteBtnClass;
if (this.options.rtl) {
var deleteBtnClass = 'vis-button vis-delete-rtl';
deleteBtnClass = 'vis-button vis-delete-rtl';
} else {
var deleteBtnClass = 'vis-button vis-delete';
deleteBtnClass = 'vis-button vis-delete';
}
let button = this._createButton('delete', deleteBtnClass, locale['del'] || this.options.locales['en']['del']);
this.manipulationDiv.appendChild(button);
@ -840,7 +841,7 @@ class ManipulationSystem {
* @param event
* @private
*/
_controlNodeDragStart(event) {
_controlNodeDragStart(event) { // eslint-disable-line no-unused-vars
let pointer = this.lastTouch;
let pointerObj = this.selectionHandler._pointerToPositionObject(pointer);
let from = this.body.nodes[this.temporaryIds.nodes[0]];

+ 1
- 1
lib/network/modules/View.js View File

@ -265,7 +265,7 @@ class View {
}
this.body.emitter.emit("animationFinished");
}
};
}
getScale() {

+ 0
- 1
lib/network/modules/components/NavigationHandler.js View File

@ -1,4 +1,3 @@
var util = require('../../../util');
var Hammer = require('../../../module/hammer');
var hammerUtil = require('../../../hammerUtil');
var keycharm = require('keycharm');

+ 0
- 1
lib/network/modules/components/Node.js View File

@ -16,7 +16,6 @@ var Star = require('./nodes/shapes/Star').default;
var Text = require('./nodes/shapes/Text').default;
var Triangle = require('./nodes/shapes/Triangle').default;
var TriangleDown = require('./nodes/shapes/TriangleDown').default;
var Validator = require("../../../shared/Validator").default;
var { printStyle } = require("../../../shared/Validator");

+ 6
- 4
lib/network/modules/components/edges/util/EdgeBase.js View File

@ -62,7 +62,7 @@ class EdgeBase {
}
}
_drawDashedLine(ctx, values, viaNode, fromPoint, toPoint) {
_drawDashedLine(ctx, values, viaNode, fromPoint, toPoint) { // eslint-disable-line no-unused-vars
ctx.lineCap = 'round';
let pattern = [5,5];
if (Array.isArray(values.dashes) === true) {
@ -129,7 +129,7 @@ class EdgeBase {
to = this._findBorderPosition(this.to, ctx);
}
else {
let [x,y,radius] = this._getCircleData(ctx);
let [x,y] = this._getCircleData(ctx).slice(0, 2);
from = this._findBorderPositionCircle(this.from, ctx, {x, y, low:0.25, high:0.6, direction:-1});
to = this._findBorderPositionCircle(this.from, ctx, {x, y, low:0.6, high:0.8, direction:1});
@ -255,7 +255,7 @@ class EdgeBase {
}
getColor(ctx, values, selected, hover) {
getColor(ctx, values, selected, hover) { // eslint-disable-line no-unused-vars
if (values.inheritsColor !== false) {
// when this is a loop edge, just use the 'from' method
if ((values.inheritsColor === 'both') && (this.from.id !== this.to.id)) {
@ -316,6 +316,7 @@ class EdgeBase {
/**
* Calculate the distance between a point (x3,y3) and a line segment from
* (x1,y1) to (x2,y2).
* x3,y3 is the point.
* http://stackoverflow.com/questions/849211/shortest-distancae-between-a-point-and-a-line-segment
* @param {number} x1
* @param {number} y1
@ -323,9 +324,10 @@ class EdgeBase {
* @param {number} y2
* @param {number} x3
* @param {number} y3
* @param via
* @private
*/
getDistanceToEdge(x1, y1, x2, y2, x3, y3, via, values) { // x3,y3 is the point
getDistanceToEdge(x1, y1, x2, y2, x3, y3, via, values) { // eslint-disable-line no-unused-vars
let returnValue = 0;
if (this.from != this.to) {
returnValue = this._getDistanceToEdge(x1, y1, x2, y2, x3, y3, via)

+ 2
- 2
lib/network/modules/components/nodes/shapes/Circle.js View File

@ -4,7 +4,7 @@ import CircleImageBase from '../util/CircleImageBase'
class Circle extends CircleImageBase {
constructor(options, body, labelModule) {
super(options, body, labelModule)
super(options, body, labelModule);
this._setMargins(labelModule);
}
@ -40,7 +40,7 @@ class Circle extends CircleImageBase {
this.boundingBox.bottom = y + this.options.size;
}
distanceToBorder(ctx, angle) {
distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars
this.resize(ctx);
return this.width * 0.5;
}

+ 1
- 1
lib/network/modules/components/nodes/shapes/CircularImage.js View File

@ -65,7 +65,7 @@ class CircularImage extends CircleImageBase {
}
distanceToBorder(ctx, angle) {
distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars
this.resize(ctx);
return this.width * 0.5;
}

+ 1
- 1
lib/network/modules/components/nodes/shapes/Dot.js View File

@ -11,7 +11,7 @@ class Dot extends ShapeBase {
this._drawShape(ctx, 'circle', 2, x, y, selected, hover, values);
}
distanceToBorder(ctx, angle) {
distanceToBorder(ctx, angle) { // eslint-disable-line no-unused-vars
this.resize(ctx);
return this.options.size;
}

+ 3
- 5
lib/network/modules/components/nodes/util/CircleImageBase.js View File

@ -1,6 +1,4 @@
import NodeBase from './NodeBase';
import CachedImage from '../../../../CachedImage';
/**
* NOTE: This is a bad base class
@ -86,11 +84,11 @@ class CircleImageBase extends NodeBase {
// Only calculate the proper ratio if both width and height not zero
if (this.imageObj.width && this.imageObj.height) {
if (this.imageObj.width > this.imageObj.height) {
ratio_width = this.imageObj.width / this.imageObj.height;
if (this.imageObj.width > this.imageObj.height) {
ratio_width = this.imageObj.width / this.imageObj.height;
}
else {
ratio_height = this.imageObj.height / this.imageObj.width;
ratio_height = this.imageObj.height / this.imageObj.width;
}
}

+ 2
- 3
lib/network/modules/components/physics/HierarchicalSpringSolver.js View File

@ -73,7 +73,7 @@ class HierarchicalSpringSolver {
}
// normalize spring forces
var springForce = 1;
springForce = 1;
var springFx, springFy;
for (let i = 0; i < nodeIndices.length; i++) {
let nodeId = nodeIndices[i];
@ -101,7 +101,6 @@ class HierarchicalSpringSolver {
forces[nodeId].y -= correctionFy;
}
}
}
export default HierarchicalSpringSolver;
export default HierarchicalSpringSolver;

+ 10
- 10
lib/network/modules/components/shared/Label.js View File

@ -663,7 +663,7 @@ class Label {
};
s.mod = function() {
return (this.modStack.length === 0) ? 'normal' : this.modStack[0];
}
};
s.modName = function() {
if (this.modStack.length === 0)
return 'normal';
@ -678,8 +678,8 @@ class Label {
return 'ital';
}
}
}
s.emitBlock = function(override = false) {
};
s.emitBlock = function(override=false) { // eslint-disable-line no-unused-vars
if (this.spacing) {
this.add(" ");
this.spacing = false;
@ -688,7 +688,7 @@ class Label {
blocks.push({ text: this.buffer, mod: this.modName() });
this.buffer = "";
}
}
};
s.add = function(text) {
if (text === " ") {
s.spacing = true;
@ -700,7 +700,7 @@ class Label {
if (text != " ") {
this.buffer += text;
}
}
};
while (s.position < text.length) {
let ch = text.charAt(s.position);
if (/[ \t]/.test(ch)) {
@ -780,7 +780,7 @@ class Label {
};
s.mod = function() {
return (this.modStack.length === 0) ? 'normal' : this.modStack[0];
}
};
s.modName = function() {
if (this.modStack.length === 0)
return 'normal';
@ -795,8 +795,8 @@ class Label {
return 'ital';
}
}
}
s.emitBlock = function(override = false) {
};
s.emitBlock = function(override=false) { // eslint-disable-line no-unused-vars
if (this.spacing) {
this.add(" ");
this.spacing = false;
@ -805,7 +805,7 @@ class Label {
blocks.push({ text: this.buffer, mod: this.modName() });
this.buffer = "";
}
}
};
s.add = function(text) {
if (text === " ") {
s.spacing = true;
@ -817,7 +817,7 @@ class Label {
if (text != " ") {
this.buffer += text;
}
}
};
while (s.position < text.length) {
let ch = text.charAt(s.position);
if (/[ \t]/.test(ch)) {

Loading…
Cancel
Save