diff --git a/.eslintrc.js b/.eslintrc.js index ca4113bdfd..bc6e8e8833 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,3 +1,34 @@ module.exports = { extends: [require.resolve("vis-dev-utils/eslint-shareable-config")], + overrides: [ + { + files: ["**/*.js", "**/*.ts"], + extends: ["plugin:jsdoc/recommended"], + rules: { + "jsdoc/check-examples": "off", + "jsdoc/check-indentation": "off", + "jsdoc/check-syntax": "warn", + "jsdoc/check-tag-names": ["error", { definedTags: ["remarks"] }], + "jsdoc/empty-tags": "warn", + "jsdoc/no-undefined-types": "off", + "jsdoc/require-description": "off", + "jsdoc/require-jsdoc": "warn", + "jsdoc/require-param-description": "off", + "jsdoc/require-param-type": "off", + "jsdoc/require-returns": "off", + "jsdoc/require-returns-check": "off", + "jsdoc/require-returns-description": "off", + "jsdoc/require-returns-type": "off", + "jsdoc/tag-lines": "off", + }, + settings: { + jsdoc: { + tagNamePreference: { + inheritdoc: "inheritDoc", + typeparam: "typeParam", + }, + }, + }, + }, + ], }; diff --git a/examples/network/exampleUtil.js b/examples/network/exampleUtil.js index 33ac24fb50..704bb55b7c 100644 --- a/examples/network/exampleUtil.js +++ b/examples/network/exampleUtil.js @@ -1,10 +1,10 @@ // These globals will be injected into a page that will use them. -/* eslint no-unused-vars: "off" */ +/* eslint no-unused-vars: "off" -- old example */ // This is quite old and I don't want to waste too much time here. We probably // should stop using this altogether as the examples should be easy and // straightforward to understand and this only obscures it. -/* eslint require-jsdoc: "off" */ +/* eslint require-jsdoc: "off" -- it's an example */ /* global Alea:false seededRandom:true */ diff --git a/lib/DOMutil.js b/lib/DOMutil.js index 3f31f9164f..2e10e21a17 100644 --- a/lib/DOMutil.js +++ b/lib/DOMutil.js @@ -144,8 +144,7 @@ export function getDOMElement( * * @param {number} x * @param {number} y - * @param {object} groupTemplate: A template containing the necessary information to draw the datapoint e.g., {style: 'circle', size: 5, className: 'className' } - * @param groupTemplate + * @param {object} groupTemplate A template containing the necessary information to draw the datapoint e.g., {style: 'circle', size: 5, className: 'className' } * @param {object} JSONcontainer * @param {object} svgContainer * @param {object} labelObj diff --git a/lib/network/modules/CanvasRenderer.js b/lib/network/modules/CanvasRenderer.js index 5485687dee..df597139ad 100644 --- a/lib/network/modules/CanvasRenderer.js +++ b/lib/network/modules/CanvasRenderer.js @@ -254,8 +254,8 @@ class CanvasRenderer { /** * Redraw the network with the current data * - * @param {boolean} [hidden=false] | Used to get the first estimate of the node sizes. - * Only the nodes are drawn after which they are quickly drawn over. + * @param {boolean} [hidden] Used to get the first estimate of the node sizes. + * Only the nodes are drawn after which they are quickly drawn over. * @private */ _redraw(hidden = false) { @@ -355,8 +355,6 @@ class CanvasRenderer { /** * Redraw all nodes * - * @param {CanvasRenderingContext2D} ctx - * @param {boolean} [alwaysShow] * @private */ _resizeNodes() { diff --git a/lib/network/modules/Clustering.js b/lib/network/modules/Clustering.js index b5f44ce75a..a69d7b92d9 100644 --- a/lib/network/modules/Clustering.js +++ b/lib/network/modules/Clustering.js @@ -151,7 +151,7 @@ class ClusterEngine { * loop over all nodes, check if they adhere to the condition and cluster if needed. * * @param {object} options - * @param {boolean} [refreshData=true] + * @param {boolean} [refreshData] */ cluster(options = {}, refreshData = true) { if (options.joinCondition === undefined) { @@ -188,7 +188,7 @@ class ClusterEngine { * * @param {number} edgeCount * @param {object} options - * @param {boolean} [refreshData=true] + * @param {boolean} [refreshData] */ clusterByEdgeCount(edgeCount, options, refreshData = true) { options = this._checkOptions(options); @@ -310,7 +310,7 @@ class ClusterEngine { * Cluster all nodes in the network that have only 1 edge * * @param {object} options - * @param {boolean} [refreshData=true] + * @param {boolean} [refreshData] */ clusterOutliers(options, refreshData = true) { this.clusterByEdgeCount(1, options, refreshData); @@ -320,7 +320,7 @@ class ClusterEngine { * Cluster all nodes in the network that have only 2 edge * * @param {object} options - * @param {boolean} [refreshData=true] + * @param {boolean} [refreshData] */ clusterBridges(options, refreshData = true) { this.clusterByEdgeCount(2, options, refreshData); @@ -331,7 +331,7 @@ class ClusterEngine { * * @param {Node.id} nodeId * @param {object} options - * @param {boolean} [refreshData=true] + * @param {boolean} [refreshData] */ clusterByConnection(nodeId, options, refreshData = true) { // kill conditions diff --git a/lib/network/modules/EdgesHandler.js b/lib/network/modules/EdgesHandler.js index 4938468acd..fb5a9954e5 100644 --- a/lib/network/modules/EdgesHandler.js +++ b/lib/network/modules/EdgesHandler.js @@ -248,7 +248,7 @@ class EdgesHandler { * Load edges by reading the data table * * @param {Array | DataSet | DataView} edges The data containing the edges. - * @param {boolean} [doNotEmit=false] - Suppress data changed event. + * @param {boolean} [doNotEmit] - Suppress data changed event. * @private */ setData(edges, doNotEmit = false) { @@ -298,7 +298,7 @@ class EdgesHandler { * Add edges * * @param {number[] | string[]} ids - * @param {boolean} [doNotEmit=false] + * @param {boolean} [doNotEmit] * @private */ add(ids, doNotEmit = false) { @@ -362,7 +362,7 @@ class EdgesHandler { * Remove existing edges. Non existing ids will be ignored * * @param {number[] | string[]} ids - * @param {boolean} [emit=true] + * @param {boolean} [emit] * @private */ remove(ids, emit = true) { diff --git a/lib/network/modules/Groups.js b/lib/network/modules/Groups.js index dc3a84f41e..3b985de9b7 100644 --- a/lib/network/modules/Groups.js +++ b/lib/network/modules/Groups.js @@ -175,7 +175,7 @@ export class Groups { * If groupname is not found, a new group may be created. * * @param {*} groupname Can be a number, string, Date, etc. - * @param {boolean} [shouldCreate=true] If true, create a new group + * @param {boolean} [shouldCreate] If true, create a new group * @returns {object} The found or created group */ get(groupname, shouldCreate = true) { diff --git a/lib/network/modules/InteractionHandler.js b/lib/network/modules/InteractionHandler.js index 44c6c954bf..c6d6c59547 100644 --- a/lib/network/modules/InteractionHandler.js +++ b/lib/network/modules/InteractionHandler.js @@ -213,7 +213,7 @@ class InteractionHandler { * Select and deselect nodes depending current selection change. * * @param {{x: number, y: number}} pointer - * @param {boolean} [add=false] + * @param {boolean} [add] */ checkSelectionChanges(pointer, add = false) { if (add === true) { @@ -590,8 +590,6 @@ class InteractionHandler { /** * Event handler for mouse wheel event, used to zoom the timeline - * See http://adomas.org/javascript-mouse-wheel/ - * https://github.com/EightMedia/hammer.js/issues/256 * * @param {MouseEvent} event * @private @@ -604,8 +602,14 @@ class InteractionHandler { if (event.deltaY !== 0) { // calculate the new scale let scale = this.body.view.scale; - scale *= - 1 + (event.deltaY < 0 ? 1 : -1) * (this.options.zoomSpeed * 0.1); + const scaledY = event.deltaY / 8; + /** + * Rapid mouse wheel movement can cause the graph to zoom so fast + * that the entire graph disappears; therefore limit it to two + * "wheel clicks" per event. + */ + const clampedY = Math.sign(scaledY) * Math.min(Math.abs(scaledY), 2); + scale *= 1 - clampedY * (this.options.zoomSpeed * 0.1); // calculate the pointer location const pointer = this.getPointer({ x: event.clientX, y: event.clientY }); diff --git a/lib/network/modules/KamadaKawai.js b/lib/network/modules/KamadaKawai.js index 13474e6cb2..a8261340b9 100644 --- a/lib/network/modules/KamadaKawai.js +++ b/lib/network/modules/KamadaKawai.js @@ -43,7 +43,7 @@ class KamadaKawai { * * @param {Array.} nodesArray * @param {Array.} edgesArray - * @param {boolean} [ignoreClusters=false] + * @param {boolean} [ignoreClusters] */ solve(nodesArray, edgesArray, ignoreClusters = false) { // get distance matrix diff --git a/lib/network/modules/LayoutEngine.js b/lib/network/modules/LayoutEngine.js index 3a88e73dae..792bb97bc5 100644 --- a/lib/network/modules/LayoutEngine.js +++ b/lib/network/modules/LayoutEngine.js @@ -1615,7 +1615,7 @@ class LayoutEngine { /** * Crawl over the entire network and use a callback on each node couple that is connected to each other. * - * @param {Function} [callback=function(){}] | will receive nodeA, nodeB and the connecting edge. A and B are distinct. + * @param {Function} [callback] | will receive nodeA, nodeB and the connecting edge. A and B are distinct. * @param {Node.id} startingNodeId * @private */ @@ -1745,10 +1745,6 @@ class LayoutEngine { * * The individual instances contain all the operations and data specific to a layout direction. * - * @param {Node} node - * @param {{x: number, y: number}} position - * @param {number} level - * @param {boolean} [doNotUpdate=false] * @private */ setDirectionStrategy() { diff --git a/lib/network/modules/ManipulationSystem.js b/lib/network/modules/ManipulationSystem.js index ff4c69ea26..50d9c039ca 100644 --- a/lib/network/modules/ManipulationSystem.js +++ b/lib/network/modules/ManipulationSystem.js @@ -723,7 +723,7 @@ class ManipulationSystem { /** * create a seperator line. the index is to differentiate in the manipulation dom * - * @param {number} [index=1] + * @param {number} [index] * @private */ _createSeperator(index = 1) { diff --git a/lib/network/modules/NodesHandler.js b/lib/network/modules/NodesHandler.js index ee979564f7..bd79d5dc40 100644 --- a/lib/network/modules/NodesHandler.js +++ b/lib/network/modules/NodesHandler.js @@ -245,7 +245,7 @@ class NodesHandler { * Set a data set with nodes for the network * * @param {Array | DataSet | DataView} nodes The data containing the nodes. - * @param {boolean} [doNotEmit=false] - Suppress data changed event. + * @param {boolean} [doNotEmit] - Suppress data changed event. * @private */ setData(nodes, doNotEmit = false) { @@ -293,7 +293,7 @@ class NodesHandler { * Add nodes * * @param {number[] | string[]} ids - * @param {boolean} [doNotEmit=false] + * @param {boolean} [doNotEmit] * @private */ add(ids, doNotEmit = false) { @@ -380,7 +380,7 @@ class NodesHandler { * create a node * * @param {object} properties - * @param {class} [constructorClass=Node.default] + * @param {class} [constructorClass] * @returns {*} */ create(properties, constructorClass = Node) { @@ -396,7 +396,7 @@ class NodesHandler { /** * - * @param {boolean} [clearPositions=false] + * @param {boolean} [clearPositions] */ refresh(clearPositions = false) { forEach(this.body.nodes, (node, nodeId) => { diff --git a/lib/network/modules/PhysicsEngine.js b/lib/network/modules/PhysicsEngine.js index 1b46d1516a..c355626ee1 100644 --- a/lib/network/modules/PhysicsEngine.js +++ b/lib/network/modules/PhysicsEngine.js @@ -304,7 +304,7 @@ class PhysicsEngine { /** * Stop the simulation, force stabilization. * - * @param {boolean} [emit=true] + * @param {boolean} [emit] */ stopSimulation(emit = true) { this.stabilized = true; @@ -350,7 +350,7 @@ class PhysicsEngine { /** * trigger the stabilized event. * - * @param {number} [amountOfIterations=this.stabilizationIterations] + * @param {number} [amountOfIterations] * @private */ _emitStabilized(amountOfIterations = this.stabilizationIterations) { @@ -706,7 +706,7 @@ class PhysicsEngine { /** * Find a stable position for all nodes * - * @param {number} [iterations=this.options.stabilization.iterations] + * @param {number} [iterations] */ stabilize(iterations = this.options.stabilization.iterations) { if (typeof iterations !== "number") { diff --git a/lib/network/modules/SelectionHandler.js b/lib/network/modules/SelectionHandler.js index 2666baa436..f272a1fd68 100644 --- a/lib/network/modules/SelectionHandler.js +++ b/lib/network/modules/SelectionHandler.js @@ -124,11 +124,11 @@ class SelectionHandler { * This adds some extra data to the event with respect to cursor position and * selected nodes and edges. * - * @param {string} eventType Name of event to send + * @param {string} eventType Name of event to send * @param {Event} event - * @param {{x: number, y: number}} pointer Object with the x and y screen coordinates of the mouse - * @param {object | undefined} oldSelection If present, selection state before event occured - * @param {boolean|undefined} [emptySelection=false] Indicate if selection data should be passed + * @param {{x: number, y: number}} pointer Object with the x and y screen coordinates of the mouse + * @param {object | undefined} oldSelection If present, selection state before event occured + * @param {boolean|undefined} [emptySelection] Indicate if selection data should be passed */ generateClickEvent( eventType, @@ -168,7 +168,7 @@ class SelectionHandler { /** * * @param {object} obj - * @param {boolean} [highlightEdges=this.options.selectConnectedEdges] + * @param {boolean} [highlightEdges] * @returns {boolean} */ selectObject(obj, highlightEdges = this.options.selectConnectedEdges) { @@ -237,7 +237,7 @@ class SelectionHandler { * Get the top node at the passed point (like a click) * * @param {{x: number, y: number}} pointer - * @param {boolean} [returnNode=true] + * @param {boolean} [returnNode] * @returns {Node | undefined} node */ getNodeAt(pointer, returnNode = true) { @@ -291,7 +291,7 @@ class SelectionHandler { * Get the edges nearest to the passed point (like a click) * * @param {{x: number, y: number}} pointer - * @param {boolean} [returnEdge=true] + * @param {boolean} [returnEdge] * @returns {Edge | undefined} node */ getEdgeAt(pointer, returnEdge = true) { diff --git a/lib/network/modules/View.js b/lib/network/modules/View.js index 0b6aae2d98..c7d4959d62 100644 --- a/lib/network/modules/View.js +++ b/lib/network/modules/View.js @@ -37,7 +37,7 @@ class View { /** * - * @param {object} [options={}] + * @param {object} [options] */ setOptions(options = {}) { this.options = options; @@ -46,9 +46,8 @@ class View { /** * This function zooms out to fit all data on screen based on amount of nodes * - * @param {object} [options={{nodes=Array}}] - * @param options - * @param {boolean} [initialZoom=false] | zoom based on fitted formula or range, true = fitted, default = false; + * @param {object} options + * @param {boolean} [initialZoom] zoom based on fitted formula or range, true = fitted, default = false; */ fit(options, initialZoom = false) { options = normalizeFitOptions(options, this.body.nodeIndices); @@ -368,7 +367,7 @@ class View { } /** - * @param {boolean} [finished=false] + * @param {boolean} [finished] * @private */ _transitionRedraw(finished = false) { diff --git a/lib/network/modules/components/Edge.js b/lib/network/modules/components/Edge.js index 73bea9cee2..aabf42fe95 100644 --- a/lib/network/modules/components/Edge.js +++ b/lib/network/modules/components/Edge.js @@ -72,7 +72,6 @@ class Edge { /** * Set or overwrite options for the edge - * * @param {object} options an object with options * @returns {undefined|boolean} undefined if no options, true if layout affecting data changed, false otherwise. */ @@ -131,9 +130,9 @@ class Edge { * * @param {object} parentOptions * @param {object} newOptions - * @param {boolean} [allowDeletion=false] - * @param {object} [globalOptions={}] - * @param {boolean} [copyFromGlobals=false] + * @param {boolean} [allowDeletion] + * @param {object} [globalOptions] + * @param {boolean} [copyFromGlobals] */ static parseOptions( parentOptions, @@ -450,7 +449,6 @@ class Edge { /** * update the options in the label module - * * @param {object} options */ updateLabelModule(options) { @@ -470,7 +468,6 @@ class Edge { /** * update the edge type, set the options - * * @returns {boolean} */ updateEdgeType() { @@ -576,7 +573,6 @@ class Edge { /** * get the title of this edge. - * * @returns {string} title The title of the edge, or undefined when no title * has been set. */ @@ -586,7 +582,6 @@ class Edge { /** * check if this node is selecte - * * @returns {boolean} selected True if node is selected, else false */ isSelected() { @@ -595,7 +590,6 @@ class Edge { /** * Retrieve the value of the edge. Can be undefined - * * @returns {number} value */ getValue() { @@ -605,7 +599,6 @@ class Edge { /** * Adjust the value range of the edge. The edge will adjust it's width * based on its value. - * * @param {number} min * @param {number} max * @param {number} total @@ -659,7 +652,6 @@ class Edge { * Redraw a edge * Draw this edge in the given canvas * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d"); - * * @param {CanvasRenderingContext2D} ctx */ draw(ctx) { @@ -680,7 +672,6 @@ class Edge { * Redraw arrows * Draw this arrows in the given canvas * The 2d context of a HTML canvas can be retrieved by canvas.getContext("2d"); - * * @param {CanvasRenderingContext2D} ctx */ drawArrows(ctx) { @@ -813,8 +804,8 @@ class Edge { point = this.edgeType.getPoint(0.5, viaNode); ctx.save(); - const rotationPoint = this._getRotation(ctx); - if (rotationPoint.angle != 0) { + if (this.options.font.align !== "horizontal") { + const rotationPoint = this._getRotation(ctx); ctx.translate(rotationPoint.x, rotationPoint.y); ctx.rotate(rotationPoint.angle); } @@ -859,7 +850,6 @@ class Edge { /** * Determine all visual elements of this edge instance, in which the given * point falls within the bounding shape. - * * @param {point} point * @returns {Array.} list with the items which are on the point */ @@ -887,7 +877,6 @@ class Edge { /** * Check if this object is overlapping with the provided object - * * @param {object} obj an object with parameters left, top * @returns {boolean} True if location is located on the edge */ @@ -918,7 +907,6 @@ class Edge { /** * Determine the rotation point, if any. - * * @param {CanvasRenderingContext2D} [ctx] if passed, do a recalculation of the label size * @returns {rotationPoint} the point to rotate around and the angle in radians to rotate * @private @@ -966,7 +954,6 @@ class Edge { /** * Get a point on a circle - * * @param {number} x * @param {number} y * @param {number} radius @@ -997,7 +984,6 @@ class Edge { /** * cleans all required things on delete - * * @returns {*} */ cleanup() { @@ -1015,7 +1001,6 @@ class Edge { /** * Check if both connecting nodes exist - * * @returns {boolean} */ endPointsValid() { diff --git a/lib/network/modules/components/Node.js b/lib/network/modules/components/Node.js index 70eb31553e..f2714b3401 100644 --- a/lib/network/modules/components/Node.js +++ b/lib/network/modules/components/Node.js @@ -336,8 +336,8 @@ class Node { * * @param {object} parentOptions * @param {object} newOptions - * @param {boolean} [allowDeletion=false] - * @param {object} [globalOptions={}] + * @param {boolean} [allowDeletion] + * @param {object} [globalOptions] * @param {object} [groupList] * @static */ diff --git a/lib/network/modules/components/edges/util/edge-base.ts b/lib/network/modules/components/edges/util/edge-base.ts index 2b90a3399a..ba5913aede 100644 --- a/lib/network/modules/components/edges/util/edge-base.ts +++ b/lib/network/modules/components/edges/util/edge-base.ts @@ -174,8 +174,6 @@ export abstract class EdgeBase implements EdgeType { * @param ctx - The context that will be used for rendering. * @param values - Formatting values like color, opacity or shadow. * @param viaNode - Additional control point(s) for the edge. - * @param _fromPoint - Ignored (TODO: remove in the future). - * @param _toPoint - Ignored (TODO: remove in the future). */ private _drawDashedLine( ctx: CanvasRenderingContext2D, @@ -183,9 +181,7 @@ export abstract class EdgeBase implements EdgeType { EdgeFormattingValues, "shadowColor" | "shadowSize" | "shadowX" | "shadowY" >, - viaNode: Via, - _fromPoint?: Point, - _toPoint?: Point + viaNode: Via ): void { ctx.lineCap = "round"; const pattern = Array.isArray(values.dashes) ? values.dashes : [5, 5]; @@ -455,8 +451,6 @@ export abstract class EdgeBase implements EdgeType { * * @param ctx - The context that will be used for rendering. * @param values - Formatting values like color, opacity or shadow. - * @param _selected - Ignored (TODO: remove in the future). - * @param _hover - Ignored (TODO: remove in the future). * @returns Color string if single color is inherited or gradient if two. */ public getColor( diff --git a/lib/network/modules/components/nodes/util/ShapeBase.js b/lib/network/modules/components/nodes/util/ShapeBase.js index 196fef3f05..5485b915e8 100644 --- a/lib/network/modules/components/nodes/util/ShapeBase.js +++ b/lib/network/modules/components/nodes/util/ShapeBase.js @@ -21,7 +21,7 @@ class ShapeBase extends NodeBase { * @param {CanvasRenderingContext2D} ctx * @param {boolean} [selected] * @param {boolean} [hover] - * @param {object} [values={size: this.options.size}] + * @param {object} [values] */ resize( ctx, diff --git a/lib/network/modules/components/shared/Label.js b/lib/network/modules/components/shared/Label.js index a996869d41..8dc6f08d21 100644 --- a/lib/network/modules/components/shared/Label.js +++ b/lib/network/modules/components/shared/Label.js @@ -16,7 +16,7 @@ class Label { /** * @param {object} body * @param {object} options - * @param {boolean} [edgelabel=false] + * @param {boolean} [edgelabel] */ constructor(body, options, edgelabel = false) { this.body = body; @@ -407,7 +407,7 @@ class Label { * @param {number} y * @param {boolean} selected * @param {boolean} hover - * @param {string} [baseline='middle'] + * @param {string} [baseline] */ draw(ctx, x, y, selected, hover, baseline = "middle") { // if no label, return @@ -457,7 +457,7 @@ class Label { * @param {CanvasRenderingContext2D} ctx * @param {number} x * @param {number} y - * @param {string} [baseline='middle'] + * @param {string} [baseline] * @param {number} viewFontSize * @private */ @@ -634,9 +634,9 @@ class Label { * @param {CanvasRenderingContext2D} ctx * @param {boolean} selected * @param {boolean} hover - * @param {number} [x=0] - * @param {number} [y=0] - * @param {'middle'|'hanging'} [baseline='middle'] + * @param {number} [x] + * @param {number} [y] + * @param {'middle'|'hanging'} [baseline] */ calculateLabelSize(ctx, selected, hover, x = 0, y = 0, baseline = "middle") { this._processLabel(ctx, selected, hover); diff --git a/lib/network/modules/components/shared/LabelAccumulator.js b/lib/network/modules/components/shared/LabelAccumulator.js index 3d00793a74..ce9abfbf13 100644 --- a/lib/network/modules/components/shared/LabelAccumulator.js +++ b/lib/network/modules/components/shared/LabelAccumulator.js @@ -29,7 +29,7 @@ class LabelAccumulator { * * @param {number} l index of line to add to * @param {string} text string to append to line - * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal'] + * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod] * @private */ _add(l, text, mod = "normal") { @@ -83,7 +83,7 @@ class LabelAccumulator { * Add text in block to current line * * @param {string} text - * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal'] + * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod] */ append(text, mod = "normal") { this._add(this.current, text, mod); @@ -93,7 +93,7 @@ class LabelAccumulator { * Add text in block to current line and start a new line * * @param {string} text - * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod='normal'] + * @param {'bold'|'ital'|'boldital'|'mono'|'normal'} [mod] */ newLine(text, mod = "normal") { this._add(this.current, text, mod); diff --git a/lib/network/modules/components/shared/LabelSplitter.js b/lib/network/modules/components/shared/LabelSplitter.js index 4459887b42..6cd4fc3437 100644 --- a/lib/network/modules/components/shared/LabelSplitter.js +++ b/lib/network/modules/components/shared/LabelSplitter.js @@ -163,7 +163,7 @@ class MarkupAccumulator { /** * @param {string|RegExp} tag - * @param {number} [advance=true] if set, advance current position in text + * @param {number} advance if set, advance current position in text * @returns {boolean} true if match at given position, false otherwise * @private */ @@ -590,8 +590,8 @@ class LabelSplitter { * There is no special handling of tabs; these go along with the flow. * * @param {string} str - * @param {string} [mod='normal'] - * @param {boolean} [appendLast=false] + * @param {string} [mod] + * @param {boolean} [appendLast] * @private */ splitStringIntoLines(str, mod = "normal", appendLast = false) { diff --git a/package.json b/package.json index 7a37acdd9a..8cd3d40b4f 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "vis-network", - "version": "0.0.0-no-version", + "name": "@teddriggs/vis-network", + "version": "9.1.10", "description": "A dynamic, browser-based visualization library.", "homepage": "https://visjs.github.io/vis-network/", "license": "(Apache-2.0 OR MIT)", "repository": { "type": "git", - "url": "https://github.com/visjs/vis-network.git" + "url": "https://github.com/TedDriggs/vis-network.git" }, "bugs": { - "url": "https://github.com/visjs/vis-network/issues" + "url": "https://github.com/TedDriggs/vis-network/issues" }, "keywords": [ "vis", diff --git a/test/Network.test.js b/test/Network.test.js index 1d5e174488..d0aa4ea1ab 100644 --- a/test/Network.test.js +++ b/test/Network.test.js @@ -45,8 +45,10 @@ function merge(a, b) { return a; } -/* +/** * Load legacy-style (i.e. not module) javascript files into the given context. + * @param {string|ReadonlyArray} list + * @param {*} context */ function include(list, context) { if (!Array.isArray(list)) { @@ -60,13 +62,15 @@ function include(list, context) { } } -/* +/** * Defined network consists of two sub-networks: * * - 1-2-3-4 * - 11-12-13-14 * * For reference, this is the sample network of issue #1218 + * + * @param options */ function createSampleNetwork(options) { const NumInitialNodes = 8; @@ -119,13 +123,15 @@ function createSampleNetwork(options) { return [network, data, NumInitialNodes, NumInitialEdges]; } -/* +/** * Create a cluster for the dynamic data change cases. * * Works on the network created by createSampleNetwork(). * * This is actually a pathological case; there are two separate sub-networks and * a cluster is made of two nodes, each from one of the sub-networks. + * + * @param {Network} network */ function createCluster(network) { const clusterOptionsByData = { @@ -138,8 +144,10 @@ function createCluster(network) { network.cluster(clusterOptionsByData); } -/* +/** * Display node/edge state, useful during debugging + * + * @param {Network} network */ // eslint-disable-next-line no-unused-vars -- This is useful for debugging. function log(network) { @@ -149,9 +157,13 @@ function log(network) { console.debug(network.body.edgeIndices); } -/* +/** * Note that only the node and edges counts are asserted. * This might be done more thoroughly by explicitly checking the id's + * + * @param {Network} network + * @param {number} expectedPresent + * @param {number} [expectedVisible] */ function assertNumNodes(network, expectedPresent, expectedVisible) { if (expectedVisible === undefined) expectedVisible = expectedPresent; @@ -168,8 +180,12 @@ function assertNumNodes(network, expectedPresent, expectedVisible) { ); } -/* +/** * Comment at assertNumNodes() also applies. + * + * @param {Network} network + * @param {number} expectedPresent + * @param {number} [expectedVisible] */ function assertNumEdges(network, expectedPresent, expectedVisible) { if (expectedVisible === undefined) expectedVisible = expectedPresent; @@ -186,6 +202,12 @@ function assertNumEdges(network, expectedPresent, expectedVisible) { ); } +/** + * + * @param {Network} network + * @param {*} originalEdgesDataSet + * @param {*} assertMessagePrefix + */ function assertEdgeLabels(network, originalEdgesDataSet, assertMessagePrefix) { const originalIds = originalEdgesDataSet.getIds(); @@ -203,12 +225,15 @@ function assertEdgeLabels(network, originalEdgesDataSet, assertMessagePrefix) { } } -/* +/** * Check if the font options haven't changed. * * This is to guard against future code changes; a lot of the code deals with particular properties of * the font options. * If any assertion fails here, all code in Network handling fonts should be checked. + * + * @param {*} fontItem + * @param {boolean} checkStrict */ function checkFontProperties(fontItem, checkStrict = true) { const knownProperties = [ @@ -264,8 +289,10 @@ describe("Network", function () { // Local helper methods for Edge and Node testing ///////////////////////////////////////////////////// - /* + /** * Simplify network creation for local tests + * + * @param options */ function createNetwork(options) { const [network] = createSampleNetwork(options); @@ -273,6 +300,9 @@ describe("Network", function () { return network; } + /** + * @param {Network} network + */ function firstNode(network) { for (const id in network.body.nodes) { return network.body.nodes[id]; @@ -281,6 +311,9 @@ describe("Network", function () { return undefined; } + /** + * @param {Network} network + */ function firstEdge(network) { for (const id in network.body.edges) { return network.body.edges[id]; @@ -289,6 +322,12 @@ describe("Network", function () { return undefined; } + /** + * + * @param {*} item + * @param {*} chooser + * @param {*} labelChooser + */ function checkChooserValues(item, chooser, labelChooser) { if (chooser === "function") { assert.equal(typeof item.chooser, "function"); @@ -307,8 +346,13 @@ describe("Network", function () { // End Local helper methods for Edge and Node testing ///////////////////////////////////////////////////// - /* + /** * Helper function for clustering + * + * @param {Network} network + * @param clusterId + * @param nodeList + * @param allowSingle */ function clusterTo(network, clusterId, nodeList, allowSingle) { const options = { @@ -521,7 +565,7 @@ describe("Network", function () { checkChooserValues(firstEdge(network), "function", false); }); - /* + /** * Support routine for next unit test */ function createDataforColorChange() { @@ -897,7 +941,7 @@ describe("Network", function () { //log(network); }); - /* + /** * Helper function for setting up a graph for testing clusterByEdgeCount() */ function createOutlierGraph() { @@ -1039,7 +1083,7 @@ describe("Network", function () { // Automatic opening of clusters due to dynamic data change /////////////////////////////////////////////////////////////// - /* + /** * Helper function, created nested clusters, three deep */ function createNetwork1() { @@ -1354,6 +1398,12 @@ describe("Network", function () { }); describe("runs example ", function () { + /** + * + * @param {*} path + * @param {boolean} noPhysics + * @returns + */ function loadExample(path, noPhysics) { include(path, this); const container = document.getElementById("mynetwork"); diff --git a/test/canvas-mock.js b/test/canvas-mock.js index a2551d4e52..29bb0e8fe6 100644 --- a/test/canvas-mock.js +++ b/test/canvas-mock.js @@ -127,7 +127,7 @@ function overrideCreateElementNS(window) { * Suppresses a warning from `jsdom` on usage of `getContext()`. A mock definition is added for * it, so the message is not relevant. * - * @param {string} [html=''] html definitions which should be added to the jsdom definition + * @param {string} html definitions which should be added to the jsdom definition * @returns {Function} function to call in after(), to clean up for `jsdom_global` */ export function canvasMockify(html = "") {