From 51479f5c28a83a79d17b6661271d0ce429257859 Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Sat, 29 Apr 2023 20:29:54 -0400 Subject: [PATCH] [Glitch] Add eslint-plugin-jsdoc Port f22b4e556c0e66465b87c57a2d5cf48452ead259 to glitch-soc Signed-off-by: Claire --- .../glitch/actions/picture_in_picture.js | 2 +- .../flavours/glitch/actions/streaming.js | 16 +++++----- .../flavours/glitch/components/blurhash.jsx | 3 +- .../glitch/components/common_counter.jsx | 1 - .../flavours/glitch/components/hashtag.jsx | 1 - .../glitch/components/short_number.jsx | 2 -- .../features/ui/components/doodle_modal.jsx | 30 ++++++++++--------- app/javascript/flavours/glitch/stream.js | 14 ++++----- .../flavours/glitch/utils/scrollbar.js | 4 +-- 9 files changed, 35 insertions(+), 38 deletions(-) diff --git a/app/javascript/flavours/glitch/actions/picture_in_picture.js b/app/javascript/flavours/glitch/actions/picture_in_picture.js index 6b9ff7709e..898375abeb 100644 --- a/app/javascript/flavours/glitch/actions/picture_in_picture.js +++ b/app/javascript/flavours/glitch/actions/picture_in_picture.js @@ -20,7 +20,7 @@ export const PICTURE_IN_PICTURE_REMOVE = 'PICTURE_IN_PICTURE_REMOVE'; * @param {string} accountId * @param {string} playerType * @param {MediaProps} props - * @return {object} + * @returns {object} */ export const deployPictureInPicture = (statusId, accountId, playerType, props) => { // @ts-expect-error diff --git a/app/javascript/flavours/glitch/actions/streaming.js b/app/javascript/flavours/glitch/actions/streaming.js index 8c161ea83c..dbf668ccbd 100644 --- a/app/javascript/flavours/glitch/actions/streaming.js +++ b/app/javascript/flavours/glitch/actions/streaming.js @@ -27,7 +27,7 @@ const { messages } = getLocale(); /** * @param {number} max - * @return {number} + * @returns {number} */ const randomUpTo = max => Math.floor(Math.random() * Math.floor(max)); @@ -40,7 +40,7 @@ const randomUpTo = max => * @param {function(Function, Function): void} [options.fallback] * @param {function(): void} [options.fillGaps] * @param {function(object): boolean} [options.accept] - * @return {function(): void} + * @returns {function(): void} */ export const connectTimelineStream = (timelineId, channelName, params = {}, options = {}) => connectStream(channelName, params, (dispatch, getState) => { @@ -132,7 +132,7 @@ const refreshHomeTimelineAndNotification = (dispatch, done) => { }; /** - * @return {function(): void} + * @returns {function(): void} */ export const connectUserStream = () => // @ts-expect-error @@ -141,7 +141,7 @@ export const connectUserStream = () => /** * @param {Object} options * @param {boolean} [options.onlyMedia] - * @return {function(): void} + * @returns {function(): void} */ export const connectCommunityStream = ({ onlyMedia } = {}) => connectTimelineStream(`community${onlyMedia ? ':media' : ''}`, `public:local${onlyMedia ? ':media' : ''}`, {}, { fillGaps: () => (fillCommunityTimelineGaps({ onlyMedia })) }); @@ -151,7 +151,7 @@ export const connectCommunityStream = ({ onlyMedia } = {}) => * @param {boolean} [options.onlyMedia] * @param {boolean} [options.onlyRemote] * @param {boolean} [options.allowLocalOnly] - * @return {function(): void} + * @returns {function(): void} */ export const connectPublicStream = ({ onlyMedia, onlyRemote, allowLocalOnly } = {}) => connectTimelineStream(`public${onlyRemote ? ':remote' : (allowLocalOnly ? ':allow_local_only' : '')}${onlyMedia ? ':media' : ''}`, `public${onlyRemote ? ':remote' : (allowLocalOnly ? ':allow_local_only' : '')}${onlyMedia ? ':media' : ''}`, {}, { fillGaps: () => fillPublicTimelineGaps({ onlyMedia, onlyRemote, allowLocalOnly }) }); @@ -161,20 +161,20 @@ export const connectPublicStream = ({ onlyMedia, onlyRemote, allowLocalOnly } = * @param {string} tagName * @param {boolean} onlyLocal * @param {function(object): boolean} accept - * @return {function(): void} + * @returns {function(): void} */ export const connectHashtagStream = (columnId, tagName, onlyLocal, accept) => connectTimelineStream(`hashtag:${columnId}${onlyLocal ? ':local' : ''}`, `hashtag${onlyLocal ? ':local' : ''}`, { tag: tagName }, { accept }); /** - * @return {function(): void} + * @returns {function(): void} */ export const connectDirectStream = () => connectTimelineStream('direct', 'direct'); /** * @param {string} listId - * @return {function(): void} + * @returns {function(): void} */ export const connectListStream = listId => connectTimelineStream(`list:${listId}`, 'list', { list: listId }, { fillGaps: () => fillListTimelineGaps(listId) }); diff --git a/app/javascript/flavours/glitch/components/blurhash.jsx b/app/javascript/flavours/glitch/components/blurhash.jsx index 07cd31b6ca..f5c58e04ef 100644 --- a/app/javascript/flavours/glitch/components/blurhash.jsx +++ b/app/javascript/flavours/glitch/components/blurhash.jsx @@ -20,9 +20,8 @@ import PropTypes from 'prop-types'; /** * Component that is used to render blurred of blurhash string - * * @param {BlurhashProps} param1 Props of the component - * @returns Canvas which will render blurred region element to embed + * @returns {JSX.Element} Canvas which will render blurred region element to embed */ function Blurhash({ hash, diff --git a/app/javascript/flavours/glitch/components/common_counter.jsx b/app/javascript/flavours/glitch/components/common_counter.jsx index dd9b62de9b..9964be5166 100644 --- a/app/javascript/flavours/glitch/components/common_counter.jsx +++ b/app/javascript/flavours/glitch/components/common_counter.jsx @@ -4,7 +4,6 @@ import { FormattedMessage } from 'react-intl'; /** * Returns custom renderer for one of the common counter types - * * @param {"statuses" | "following" | "followers"} counterType * Type of the counter * @param {boolean} isBold Whether display number must be displayed in bold diff --git a/app/javascript/flavours/glitch/components/hashtag.jsx b/app/javascript/flavours/glitch/components/hashtag.jsx index c4701055c7..235aaeb3c1 100644 --- a/app/javascript/flavours/glitch/components/hashtag.jsx +++ b/app/javascript/flavours/glitch/components/hashtag.jsx @@ -35,7 +35,6 @@ class SilentErrorBoundary extends React.Component { /** * Used to render counter of how much people are talking about hashtag - * * @type {(displayNumber: JSX.Element, pluralReady: number) => JSX.Element} */ export const accountsCountRenderer = (displayNumber, pluralReady) => ( diff --git a/app/javascript/flavours/glitch/components/short_number.jsx b/app/javascript/flavours/glitch/components/short_number.jsx index 861d0bc589..0c40941c0d 100644 --- a/app/javascript/flavours/glitch/components/short_number.jsx +++ b/app/javascript/flavours/glitch/components/short_number.jsx @@ -24,7 +24,6 @@ import { FormattedMessage, FormattedNumber } from 'react-intl'; /** * Component that renders short big number to a shorter version - * * @param {ShortNumberProps} param0 Props for the component * @returns {JSX.Element} Rendered number */ @@ -58,7 +57,6 @@ ShortNumber.propTypes = { /** * Renders short number into corresponding localizable react fragment - * * @param {ShortNumberCounterProps} param0 Props for the component * @returns {JSX.Element} FormattedMessage ready to be embedded in code */ diff --git a/app/javascript/flavours/glitch/features/ui/components/doodle_modal.jsx b/app/javascript/flavours/glitch/features/ui/components/doodle_modal.jsx index 162957ad89..0b66ad09d2 100644 --- a/app/javascript/flavours/glitch/features/ui/components/doodle_modal.jsx +++ b/app/javascript/flavours/glitch/features/ui/components/doodle_modal.jsx @@ -125,9 +125,15 @@ const mapStateToProps = state => ({ }); const mapDispatchToProps = dispatch => ({ - /** Set options in the redux store */ + /** + * Set options in the redux store + * @param opts + */ setOpt: (opts) => dispatch(doodleSet(opts)), - /** Submit doodle for upload */ + /** + * Submit doodle for upload + * @param file + */ submit: (file) => dispatch(uploadCompose([file])), }); @@ -230,7 +236,10 @@ class DoodleModal extends ImmutablePureComponent { //endregion - /** Key up handler */ + /** + * Key up handler + * @param e + */ handleKeyUp = (e) => { if (e.target.nodeName === 'INPUT') return; @@ -256,7 +265,10 @@ class DoodleModal extends ImmutablePureComponent { } }; - /** Key down handler */ + /** + * Key down handler + * @param e + */ handleKeyDown = (e) => { if (e.key === 'Control' || e.key === 'Meta') { this.controlHeld = true; @@ -292,7 +304,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Set reference to the canvas element. * This is called during component init - * * @param elem - canvas element */ setCanvasRef = (elem) => { @@ -334,7 +345,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Set up the sketcher instance - * * @param canvas - canvas element. Null if we're just resizing */ initSketcher (canvas = null) { @@ -433,7 +443,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Palette left click. * Selects Fg color (or Bg, if Control/Meta is held) - * * @param e - event */ onPaletteClick = (e) => { @@ -452,7 +461,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Palette right click. * Selects Bg color - * * @param e - event */ onPaletteRClick = (e) => { @@ -463,7 +471,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Handle click on the Draw mode button - * * @param e - event */ setModeDraw = (e) => { @@ -473,7 +480,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Handle click on the Fill mode button - * * @param e - event */ setModeFill = (e) => { @@ -483,7 +489,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Handle click on Smooth checkbox - * * @param e - event */ tglSmooth = (e) => { @@ -493,7 +498,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Handle click on Adaptive checkbox - * * @param e - event */ tglAdaptive = (e) => { @@ -503,7 +507,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Handle change of the Weight input field - * * @param e - event */ setWeight = (e) => { @@ -512,7 +515,6 @@ class DoodleModal extends ImmutablePureComponent { /** * Set size - clalback from the select box - * * @param e - event */ changeSize = (e) => { diff --git a/app/javascript/flavours/glitch/stream.js b/app/javascript/flavours/glitch/stream.js index 8a60f12b48..66d249f6cd 100644 --- a/app/javascript/flavours/glitch/stream.js +++ b/app/javascript/flavours/glitch/stream.js @@ -17,10 +17,10 @@ let sharedConnection; */ /** - * @typedef StreamEvent - * @property {string} event - * @property {object} payload - */ + * @typedef StreamEvent + * @property {string} event + * @property {object} payload + */ /** * @type {Array.} @@ -126,7 +126,7 @@ const sharedCallbacks = { /** * @param {string} channelName * @param {Object.} params - * @return {string} + * @returns {string} */ const channelNameWithInlineParams = (channelName, params) => { if (Object.keys(params).length === 0) { @@ -140,7 +140,7 @@ const channelNameWithInlineParams = (channelName, params) => { * @param {string} channelName * @param {Object.} params * @param {function(Function, Function): { onConnect: (function(): void), onReceive: (function(StreamEvent): void), onDisconnect: (function(): void) }} callbacks - * @return {function(): void} + * @returns {function(): void} */ // @ts-expect-error export const connectStream = (channelName, params, callbacks) => (dispatch, getState) => { @@ -227,7 +227,7 @@ const handleEventSourceMessage = (e, received) => { * @param {string} accessToken * @param {string} channelName * @param {{ connected: Function, received: function(StreamEvent): void, disconnected: Function, reconnected: Function }} callbacks - * @return {WebSocketClient | EventSource} + * @returns {WebSocketClient | EventSource} */ const createConnection = (streamingAPIBaseURL, accessToken, channelName, { connected, received, disconnected, reconnected }) => { const params = channelName.split('&'); diff --git a/app/javascript/flavours/glitch/utils/scrollbar.js b/app/javascript/flavours/glitch/utils/scrollbar.js index 929b036d66..b3f543ffb3 100644 --- a/app/javascript/flavours/glitch/utils/scrollbar.js +++ b/app/javascript/flavours/glitch/utils/scrollbar.js @@ -2,7 +2,7 @@ let cachedScrollbarWidth = null; /** - * @return {number} + * @returns {number} */ const getActualScrollbarWidth = () => { const outer = document.createElement('div'); @@ -20,7 +20,7 @@ const getActualScrollbarWidth = () => { }; /** - * @return {number} + * @returns {number} */ export const getScrollbarWidth = () => { if (cachedScrollbarWidth !== null) {