From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 17 Feb 2020 19:31:43 +0000 (-0800) Subject: JSDoc fixes (#7112) X-Git-Tag: v3.0.0-alpha~46 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3682da78993d9e0a193c05c8ba2aa399d2353504;p=thirdparty%2FChart.js.git JSDoc fixes (#7112) --- diff --git a/src/core/core.interaction.js b/src/core/core.interaction.js index ba73fc909..d172f1a35 100644 --- a/src/core/core.interaction.js +++ b/src/core/core.interaction.js @@ -50,7 +50,7 @@ function evaluateAllVisibleItems(chart, handler) { * @param {object} metaset - the dataset meta * @param {string} axis - the axis mide. x|y|xy * @param {number} value - the value to find - * @param {boolean} intersect - should the element intersect + * @param {boolean} [intersect] - should the element intersect * @returns {{lo:number, hi:number}} indices to search data array between */ function binarySearch(metaset, axis, value, intersect) { diff --git a/src/core/core.scale.js b/src/core/core.scale.js index 35f8fd6da..cb9f42b29 100644 --- a/src/core/core.scale.js +++ b/src/core/core.scale.js @@ -267,19 +267,19 @@ class Scale extends Element { this.paddingRight = undefined; // scale-specific properties - /** @type {string} */ + /** @type {string=} */ this.axis = undefined; - /** @type {number} */ + /** @type {number=} */ this.labelRotation = undefined; this.min = undefined; this.max = undefined; /** @type {object[]} */ this.ticks = null; - /** @type {object[]} */ + /** @type {object[]|null} */ this._gridLineItems = null; - /** @type {object[]} */ + /** @type {object[]|null} */ this._labelItems = null; - /** @type {object} */ + /** @type {object|null} */ this._labelSizes = null; /** @type {number} */ this._length = undefined; diff --git a/src/helpers/helpers.dom.js b/src/helpers/helpers.dom.js index e71ff3352..f651cbb75 100644 --- a/src/helpers/helpers.dom.js +++ b/src/helpers/helpers.dom.js @@ -39,7 +39,7 @@ function parseMaxStyle(styleValue, node, parentProperty) { * @param {HTMLElement} domNode - the node to check the constraint on * @param {string} maxStyle - the style that defines the maximum for the direction we are using ('max-width' / 'max-height') * @param {string} percentageProperty - property of parent to use when calculating width as a percentage - * @return {number|undefined} number or undefined if no constraint + * @return {number=} number or undefined if no constraint * @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser} */ function getConstraintDimension(domNode, maxStyle, percentageProperty) { @@ -64,12 +64,12 @@ export function getStyle(el, property) { document.defaultView.getComputedStyle(el, null).getPropertyValue(property); } -/** @return {number|undefined} number or undefined if no constraint */ +/** @return {number=} number or undefined if no constraint */ function getConstraintWidth(domNode) { return getConstraintDimension(domNode, 'max-width', 'clientWidth'); } -/** @return {number|undefined} number or undefined if no constraint */ +/** @return {number=} number or undefined if no constraint */ function getConstraintHeight(domNode) { return getConstraintDimension(domNode, 'max-height', 'clientHeight'); } diff --git a/src/helpers/helpers.options.js b/src/helpers/helpers.options.js index 3969a1c3d..d38bbb8b7 100644 --- a/src/helpers/helpers.options.js +++ b/src/helpers/helpers.options.js @@ -4,7 +4,7 @@ import {isNullOrUndef, isArray, isObject, valueOrDefault} from './helpers.core'; /** * Converts the given font object into a CSS font string. * @param {object} font - A font object. - * @return {string} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font + * @return {string|null} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font * @private */ function toFontString(font) { diff --git a/src/helpers/helpers.segment.js b/src/helpers/helpers.segment.js index f40d8a889..2f8eadc77 100644 --- a/src/helpers/helpers.segment.js +++ b/src/helpers/helpers.segment.js @@ -63,7 +63,7 @@ function getSegment(segment, points, bounds) { * @param {number} segment.end - end index of the segment, referring the points array * @param {boolean} segment.loop - indicates that the segment is a loop * @param {Point[]} points - the points that this segment refers to - * @param {object} bounds + * @param {object} [bounds] * @param {string} bounds.property - the property of a `Point` we are bounding. `x`, `y` or `angle`. * @param {number} bounds.start - start value of the property * @param {number} bounds.end - end value of the property @@ -114,7 +114,7 @@ export function _boundSegment(segment, points, bounds) { /** * Returns the segments of the line that are inside given bounds * @param {Line} line - * @param {object} bounds + * @param {object} [bounds] * @param {string} bounds.property - the property we are bounding with. `x`, `y` or `angle`. * @param {number} bounds.start - start value of the `property` * @param {number} bounds.end - end value of the `property` diff --git a/src/platform/platform.base.js b/src/platform/platform.base.js index b1defabb6..801eecb4e 100644 --- a/src/platform/platform.base.js +++ b/src/platform/platform.base.js @@ -12,11 +12,8 @@ export default class BasePlatform { * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}. * @param {HTMLCanvasElement} canvas - The canvas from which to acquire context (platform specific) * @param {object} options - The chart options - * @returns {CanvasRenderingContext2D} context2d instance */ - acquireContext(canvas, options) { // eslint-disable-line no-unused-vars - return undefined; - } + acquireContext(canvas, options) {} // eslint-disable-line no-unused-vars /** * Called at chart destruction time, releases any resources associated to the context diff --git a/src/platform/platform.dom.js b/src/platform/platform.dom.js index 220aa74db..df8c29cf4 100644 --- a/src/platform/platform.dom.js +++ b/src/platform/platform.dom.js @@ -37,7 +37,7 @@ const EVENT_TYPES = { * `element` has a size relative to its parent and this last one is not yet displayed, * for example because of `display: none` on a parent node. * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value - * @returns {number} Size in pixels or undefined if unknown. + * @returns {number=} Size in pixels or undefined if unknown. */ function readUsedSize(element, property) { const value = helpers.dom.getStyle(element, property); @@ -307,7 +307,7 @@ export default class DomPlatform extends BasePlatform { /** * @param {HTMLCanvasElement} canvas * @param {{ options: { aspectRatio?: number; }; }} config - * @return {CanvasRenderingContext2D=} + * @return {CanvasRenderingContext2D|null} */ acquireContext(canvas, config) { // To prevent canvas fingerprinting, some add-ons undefine the getContext diff --git a/src/scales/scale.linearbase.js b/src/scales/scale.linearbase.js index e1854ff58..07d3f2ae3 100644 --- a/src/scales/scale.linearbase.js +++ b/src/scales/scale.linearbase.js @@ -2,7 +2,10 @@ import {isNullOrUndef, valueOrDefault} from '../helpers/helpers.core'; import {almostEquals, almostWhole, log10, _decimalPlaces, _setMinAndMaxByKey, sign} from '../helpers/helpers.math'; import Scale from '../core/core.scale'; -// Implementation of the nice number algorithm used in determining where axis labels will go +/** + * Implementation of the nice number algorithm used in determining where axis labels will go + * @return {number} + */ function niceNum(range, round) { const exponent = Math.floor(log10(range)); const fraction = range / Math.pow(10, exponent); diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 367e5fcf3..9b9dc806e 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -615,7 +615,7 @@ class TimeScale extends Scale { * @param {object} obj * @param {string} axis * @param {number} index - * @return {number} + * @return {number|null} * @private */ _parseObject(obj, axis, index) {