From 43141d2e3a96762b456293d02ddc2d4f956b7c9a Mon Sep 17 00:00:00 2001 From: Amaan Khan Date: Mon, 3 Mar 2025 22:05:48 +0530 Subject: [PATCH 01/11] feat: add feat/jsdoc-require-returns-type eslint rule --- .eslintrc.cjs | 1 + packages/blocks/src/block-manager/index.tsx | 6 ++++-- packages/blocks/src/blocks/core-audio.tsx | 2 +- packages/blocks/src/blocks/core-button.tsx | 2 +- packages/blocks/src/blocks/core-buttons.tsx | 2 +- packages/blocks/src/blocks/core-code.tsx | 2 +- packages/blocks/src/blocks/core-column.tsx | 2 +- packages/blocks/src/blocks/core-columns.tsx | 2 +- packages/blocks/src/blocks/core-cover.tsx | 5 +++-- packages/blocks/src/blocks/core-details.tsx | 2 +- packages/blocks/src/blocks/core-file.tsx | 2 +- packages/blocks/src/blocks/core-freeform.tsx | 2 +- packages/blocks/src/blocks/core-gallery.tsx | 2 +- packages/blocks/src/blocks/core-group.tsx | 4 ++-- packages/blocks/src/blocks/core-heading.tsx | 2 +- packages/blocks/src/blocks/core-html.tsx | 2 +- packages/blocks/src/blocks/core-image.tsx | 13 +++++++------ packages/blocks/src/blocks/core-list-item.tsx | 2 +- packages/blocks/src/blocks/core-list.tsx | 2 +- packages/blocks/src/blocks/core-media-text.tsx | 6 ++++-- packages/blocks/src/blocks/core-paragraph.tsx | 2 +- packages/blocks/src/blocks/core-pattern.tsx | 2 +- packages/blocks/src/blocks/core-post-content.tsx | 2 +- packages/blocks/src/blocks/core-preformatted.tsx | 2 +- packages/blocks/src/blocks/core-pullquote.tsx | 2 +- packages/blocks/src/blocks/core-quote.tsx | 2 +- packages/blocks/src/blocks/core-separator.tsx | 2 +- packages/blocks/src/blocks/core-spacer.tsx | 2 +- packages/blocks/src/blocks/core-template-part.tsx | 2 +- packages/blocks/src/blocks/core-verse.tsx | 2 +- packages/blocks/src/blocks/core-video.tsx | 4 ++-- packages/blocks/src/blocks/default.tsx | 3 ++- .../blocks/src/editor-blocks-renderer/index.tsx | 3 ++- .../blocks/src/utils/flat-list-to-hierarchical.ts | 3 ++- packages/core/src/config/snapwp-config-manager.ts | 12 +++++++----- .../src/config/tests/snapwp-config-manager.test.tsx | 2 +- packages/core/src/logger/index.ts | 10 +++++----- packages/core/src/utils/cn.ts | 3 ++- .../src/utils/find-element-and-get-class-names.ts | 2 +- packages/core/src/utils/generate-graphql-url.ts | 2 +- .../core/src/utils/get-class-names-from-string.ts | 3 ++- packages/core/src/utils/get-color-class-name.ts | 3 ++- .../src/utils/get-image-size-from-attributes.ts | 3 ++- .../core/src/utils/get-px-for-size-attribute.ts | 3 ++- .../core/src/utils/get-spacing-preset-css-var.ts | 2 +- .../core/src/utils/get-style-object-from-string.ts | 9 ++++++--- .../core/src/utils/get-styles-from-attributes.ts | 3 ++- packages/core/src/utils/is-valid-url.ts | 3 ++- .../src/utils/parse-external-remote-patterns.ts | 3 ++- packages/core/src/utils/replace-host-url.ts | 3 ++- packages/core/src/utils/url-slash-modify.ts | 8 ++++---- packages/next/src/components/default-error.tsx | 2 +- packages/next/src/components/font.tsx | 3 ++- packages/next/src/components/image.tsx | 2 +- packages/next/src/components/link.tsx | 2 +- packages/next/src/components/script-module.tsx | 3 ++- packages/next/src/components/script.tsx | 3 ++- packages/next/src/config/with-snap-wp.ts | 12 ++++++++---- packages/next/src/middleware/cors.ts | 7 ++++--- packages/next/src/middleware/current-path.ts | 3 ++- packages/next/src/middleware/proxies.ts | 3 ++- packages/next/src/middleware/utils.ts | 4 ++-- packages/next/src/react-parser/index.tsx | 3 ++- packages/next/src/react-parser/options.tsx | 3 ++- packages/next/src/root-layout/global-head.tsx | 3 ++- packages/next/src/root-layout/index.tsx | 2 +- packages/next/src/template-renderer/index.tsx | 3 ++- .../next/src/template-renderer/template-head.tsx | 3 ++- .../next/src/template-renderer/template-scripts.tsx | 12 ++++++++---- packages/query/src/query-engine/index.ts | 11 +++++++---- packages/query/src/utils/parse-global-styles.ts | 2 +- packages/query/src/utils/parse-template.ts | 12 ++++++------ 72 files changed, 157 insertions(+), 111 deletions(-) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 69c66330..b6ffd96d 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -71,6 +71,7 @@ module.exports = { // Turn of JSdoc types and use TypeScript types instead. 'jsdoc/no-types': [ 'off' ], + 'jsdoc/require-returns-type': [ 'error' ], // Restrict the use of empty functions. 'no-empty-function': 'error', diff --git a/packages/blocks/src/block-manager/index.tsx b/packages/blocks/src/block-manager/index.tsx index ec9392aa..84c011f2 100644 --- a/packages/blocks/src/block-manager/index.tsx +++ b/packages/blocks/src/block-manager/index.tsx @@ -24,7 +24,8 @@ export default class BlockManager { /** * Function to convert a flat list of blocks to a tree depending on `clientId` and `parentClientId` * @param blockList - A flat list of blocks. - * @return A tree of blocks. + * + * @return {Array} A tree of blocks. */ public static flatListToHierarchical( blockList?: BlockData[] | null @@ -72,7 +73,8 @@ export default class BlockManager { /** * Pre processes a flat list of blocks for rendering. * @param blockList - A flat list of blocks. - * @return A tree of blocks with render functions. + * + * @return {Array} A tree of blocks with render functions. */ public static parseBlockForRendering( blockList?: BlockData[] | null diff --git a/packages/blocks/src/blocks/core-audio.tsx b/packages/blocks/src/blocks/core-audio.tsx index 8fc64696..5fd49ba9 100644 --- a/packages/blocks/src/blocks/core-audio.tsx +++ b/packages/blocks/src/blocks/core-audio.tsx @@ -13,7 +13,7 @@ import type { CoreAudio as CoreAudioType, CoreAudioProps } from '@snapwp/types'; * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element|null} The rendered block. */ const CoreAudio: CoreAudioType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-button.tsx b/packages/blocks/src/blocks/core-button.tsx index c56674f1..77a67e57 100644 --- a/packages/blocks/src/blocks/core-button.tsx +++ b/packages/blocks/src/blocks/core-button.tsx @@ -13,7 +13,7 @@ import type { * @param props - The props for the block component. * @param props.attributes - Block attributes. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreButton: CoreButtonType = ( { attributes }: CoreButtonProps ) => { const { diff --git a/packages/blocks/src/blocks/core-buttons.tsx b/packages/blocks/src/blocks/core-buttons.tsx index d3af3184..bff9f12f 100644 --- a/packages/blocks/src/blocks/core-buttons.tsx +++ b/packages/blocks/src/blocks/core-buttons.tsx @@ -12,7 +12,7 @@ import type { * @param props.attributes - Block attributes. * @param props.children - The block's children. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreButtons: CoreButtonsType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-code.tsx b/packages/blocks/src/blocks/core-code.tsx index 736c8a10..511bfbeb 100644 --- a/packages/blocks/src/blocks/core-code.tsx +++ b/packages/blocks/src/blocks/core-code.tsx @@ -9,7 +9,7 @@ import type { CoreCode as CoreCodeType, CoreCodeProps } from '@snapwp/types'; * @param props - The props for the block component. * @param props.attributes - Block attributes. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreCode: CoreCodeType = ( { attributes }: CoreCodeProps ) => { const { style, cssClassName, content } = attributes || {}; diff --git a/packages/blocks/src/blocks/core-column.tsx b/packages/blocks/src/blocks/core-column.tsx index 8d9af039..a92eafc0 100644 --- a/packages/blocks/src/blocks/core-column.tsx +++ b/packages/blocks/src/blocks/core-column.tsx @@ -12,7 +12,7 @@ import type { * @param props.attributes - Block attributes. * @param props.children - The block's children. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreColumn: CoreColumnType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-columns.tsx b/packages/blocks/src/blocks/core-columns.tsx index 59a677cf..e1440254 100644 --- a/packages/blocks/src/blocks/core-columns.tsx +++ b/packages/blocks/src/blocks/core-columns.tsx @@ -12,7 +12,7 @@ import type { * @param props.attributes - Block attributes. * @param props.children - The block's children. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreColumns: CoreColumnsType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-cover.tsx b/packages/blocks/src/blocks/core-cover.tsx index 992db7f4..ef1badac 100644 --- a/packages/blocks/src/blocks/core-cover.tsx +++ b/packages/blocks/src/blocks/core-cover.tsx @@ -23,7 +23,7 @@ const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 }; * * @param focalPoint - The focal point coordinates object containing x and y values. * - * @return CSS position string or undefined if no focal point + * @return {string} CSS position string or undefined if no focal point */ const mediaPosition = ( focalPoint?: FocalPoint | null ): string => { if ( ! focalPoint ) { @@ -42,7 +42,8 @@ const mediaPosition = ( focalPoint?: FocalPoint | null ): string => { * @param root0.renderedHtml - Pre-rendered HTML string for class extraction * @param root0.connectedMediaItem - The connected media item object * @param root0.mediaDetails - The media details object - * @return The rendered cover block or null if using featured image + * + * @return {React.JSX.Element} The rendered cover block or null if using featured image */ const CoreCover: CoreCoverType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-details.tsx b/packages/blocks/src/blocks/core-details.tsx index 9ffeb2cc..de39d339 100644 --- a/packages/blocks/src/blocks/core-details.tsx +++ b/packages/blocks/src/blocks/core-details.tsx @@ -17,7 +17,7 @@ import type { * @param props.children - The block's children. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreDetails: CoreDetailsType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-file.tsx b/packages/blocks/src/blocks/core-file.tsx index 68d93eb3..8c8a6538 100644 --- a/packages/blocks/src/blocks/core-file.tsx +++ b/packages/blocks/src/blocks/core-file.tsx @@ -17,7 +17,7 @@ const FALLBACK_ARIA_LABEL = 'PDF embed'; * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element|null} The rendered block. */ const CoreFile: CoreFileType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-freeform.tsx b/packages/blocks/src/blocks/core-freeform.tsx index 1e65b219..b20367c6 100644 --- a/packages/blocks/src/blocks/core-freeform.tsx +++ b/packages/blocks/src/blocks/core-freeform.tsx @@ -11,7 +11,7 @@ import type { * @param props - The props for the block component. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element|null} The rendered block. */ const CoreFreeform: CoreFreeformType = ( { renderedHtml, diff --git a/packages/blocks/src/blocks/core-gallery.tsx b/packages/blocks/src/blocks/core-gallery.tsx index c95f12aa..4b10bd85 100644 --- a/packages/blocks/src/blocks/core-gallery.tsx +++ b/packages/blocks/src/blocks/core-gallery.tsx @@ -17,7 +17,7 @@ import type { * @param props.children - The block's children. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreGallery: CoreGalleryType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-group.tsx b/packages/blocks/src/blocks/core-group.tsx index efe66bc9..bd2b2ec9 100644 --- a/packages/blocks/src/blocks/core-group.tsx +++ b/packages/blocks/src/blocks/core-group.tsx @@ -19,7 +19,7 @@ import type { * @param props.style - Inline styles. * @param props.children - The content to render inside the element. * - * @return The rendered HTML element or the children if no tag name is provided. + * @return {React.JSX.Element} The rendered HTML element or the children if no tag name is provided. */ const Tag = ( { name, className, style, children }: TagProps ) => { if ( ! name ) { @@ -37,7 +37,7 @@ const Tag = ( { name, className, style, children }: TagProps ) => { * @param props.children - The block's children. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreGroup: CoreGroupType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-heading.tsx b/packages/blocks/src/blocks/core-heading.tsx index 9c77fe26..042f86ee 100644 --- a/packages/blocks/src/blocks/core-heading.tsx +++ b/packages/blocks/src/blocks/core-heading.tsx @@ -12,7 +12,7 @@ import type { * @param props - The props for the block component. * @param props.attributes - Block attributes. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreHeading: CoreHeadingType = ( { attributes }: CoreHeadingProps ) => { const { style, cssClassName, content, level } = attributes || {}; diff --git a/packages/blocks/src/blocks/core-html.tsx b/packages/blocks/src/blocks/core-html.tsx index 8f4b0172..8ec2aee7 100644 --- a/packages/blocks/src/blocks/core-html.tsx +++ b/packages/blocks/src/blocks/core-html.tsx @@ -8,7 +8,7 @@ import type { CoreHtml as CoreHtmlType, CoreHtmlProps } from '@snapwp/types'; * @param props - The props for the block component. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element|null} The rendered block. */ const CoreHtml: CoreHtmlType = ( { renderedHtml }: CoreHtmlProps ) => { // @todo use attributes.content instead of renderedHtml once it's available diff --git a/packages/blocks/src/blocks/core-image.tsx b/packages/blocks/src/blocks/core-image.tsx index d25de732..37bab85d 100644 --- a/packages/blocks/src/blocks/core-image.tsx +++ b/packages/blocks/src/blocks/core-image.tsx @@ -28,7 +28,7 @@ import type { * @param [props.rel] - The rel for the link. * @param [props.lightbox] - The lightbox attribute. * - * @return The rendered figure element. + * @return {React.JSX.Element} The rendered figure element. */ const Figure = ( { children, @@ -77,7 +77,8 @@ const Figure = ( { * @param [props.connectedMediaItem] - The connected media item. * @param [props.mediaDetails] - The media details. * @param [props.renderedHtml] - The rendered HTML. - * @return The rendered core image block or null if no URL is provided. + * + * @return {React.JSX.Element|null} The rendered core image block or null if no URL is provided. */ const CoreImage: CoreImageType = ( { attributes, @@ -170,7 +171,7 @@ const CoreImage: CoreImageType = ( { * @param [connectedMediaItem] The connected media item. * @param [mediaDetails] The media details. * - * @return The props for the image component. + * @return {Object} The props for the image component. */ const getImageProps = ( attributes?: CoreImageAttributes, @@ -244,7 +245,7 @@ const getImageProps = ( * * @param lightbox - The lightbox attribute. * - * @return Whether the lightbox is enabled. + * @return {boolean} Whether the lightbox is enabled. */ //@ts-ignore -- Stubbed until lightbox support is fixed. const isLightboxEnabled = ( lightbox?: string | null ) => { @@ -265,7 +266,7 @@ const isLightboxEnabled = ( lightbox?: string | null ) => { * @param element - The element to extract attributes for. * @param renderedHtml - The rendered HTML. * - * @return The extracted interactivity attributes. + * @return {Object} The extracted interactivity attributes. */ const extractInteractivityAttributesForElement = ( element: string, @@ -305,7 +306,7 @@ const extractInteractivityAttributesForElement = ( * @param element - The element to extract attributes for. * @param renderedHtml - The rendered HTML. * - * @return The extracted ARIA attributes. + * @return {Object} The extracted ARIA attributes. */ const extractAriaAttributesForElement = ( element: string, diff --git a/packages/blocks/src/blocks/core-list-item.tsx b/packages/blocks/src/blocks/core-list-item.tsx index 599c4f4d..b8bd2a0a 100644 --- a/packages/blocks/src/blocks/core-list-item.tsx +++ b/packages/blocks/src/blocks/core-list-item.tsx @@ -18,7 +18,7 @@ import type { * @param props.children - The block's children. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreListItem: CoreListItemType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-list.tsx b/packages/blocks/src/blocks/core-list.tsx index 65860aab..0811af09 100644 --- a/packages/blocks/src/blocks/core-list.tsx +++ b/packages/blocks/src/blocks/core-list.tsx @@ -9,7 +9,7 @@ import type { CoreList as CoreListType, CoreListProps } from '@snapwp/types'; * @param props.attributes - Block attributes. * @param props.children - The block's children. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreList: CoreListType = ( { attributes, children }: CoreListProps ) => { const { cssClassName, ordered, reversed, start, style, type } = diff --git a/packages/blocks/src/blocks/core-media-text.tsx b/packages/blocks/src/blocks/core-media-text.tsx index 53fed709..cb23a8c3 100644 --- a/packages/blocks/src/blocks/core-media-text.tsx +++ b/packages/blocks/src/blocks/core-media-text.tsx @@ -28,7 +28,8 @@ const DEFAULT_MEDIA_SIZE_SLUG = 'full'; * @param focalPoint - The focal point of the image. * @param focalPoint.x - The x-coordinate of the focal point (0 to 1). * @param focalPoint.y - The y-coordinate of the focal point (0 to 1). - * @return CSS styles for the image fill. + * + * @return {Object} CSS styles for the image fill. */ function imageFillStyles( url?: string, focalPoint?: FocalPoint ) { return url @@ -51,7 +52,8 @@ function imageFillStyles( url?: string, focalPoint?: FocalPoint ) { * @param props.renderedHtml - Raw HTML string from WordPress * @param props.connectedMediaItem - Connected media item * @param props.mediaDetails - Media details - * @return Rendered component or null if no content + * + * @return {React.JSX.Element} Rendered component or null if no content */ const CoreMediaText: CoreMediaTextType = ( { attributes = {}, diff --git a/packages/blocks/src/blocks/core-paragraph.tsx b/packages/blocks/src/blocks/core-paragraph.tsx index d9a01bf2..07aae210 100644 --- a/packages/blocks/src/blocks/core-paragraph.tsx +++ b/packages/blocks/src/blocks/core-paragraph.tsx @@ -12,7 +12,7 @@ import type { * @param props - The props for the block component. * @param props.attributes - Block attributes. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreParagraph: CoreParagraphType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-pattern.tsx b/packages/blocks/src/blocks/core-pattern.tsx index 1539092a..ea6afd57 100644 --- a/packages/blocks/src/blocks/core-pattern.tsx +++ b/packages/blocks/src/blocks/core-pattern.tsx @@ -10,7 +10,7 @@ import type { * @param props - The props for the block component. * @param props.children - The block's children. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CorePattern: CorePatternType = ( { children }: CorePatternProps ) => { // Patterns contain only children, so we just return them. diff --git a/packages/blocks/src/blocks/core-post-content.tsx b/packages/blocks/src/blocks/core-post-content.tsx index fb9bce63..fbda6b24 100644 --- a/packages/blocks/src/blocks/core-post-content.tsx +++ b/packages/blocks/src/blocks/core-post-content.tsx @@ -12,7 +12,7 @@ import type { * @param props.children - The block's children. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CorePostContent: CorePostContentType = ( { renderedHtml, diff --git a/packages/blocks/src/blocks/core-preformatted.tsx b/packages/blocks/src/blocks/core-preformatted.tsx index 61ecfe6c..efdd7902 100644 --- a/packages/blocks/src/blocks/core-preformatted.tsx +++ b/packages/blocks/src/blocks/core-preformatted.tsx @@ -17,7 +17,7 @@ import type { * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CorePreformatted: CorePreformattedType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-pullquote.tsx b/packages/blocks/src/blocks/core-pullquote.tsx index 14a77bc1..3533b646 100644 --- a/packages/blocks/src/blocks/core-pullquote.tsx +++ b/packages/blocks/src/blocks/core-pullquote.tsx @@ -17,7 +17,7 @@ import type { * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CorePullquote: CorePullquoteType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-quote.tsx b/packages/blocks/src/blocks/core-quote.tsx index b0fec182..6c69f0e8 100644 --- a/packages/blocks/src/blocks/core-quote.tsx +++ b/packages/blocks/src/blocks/core-quote.tsx @@ -10,7 +10,7 @@ import type { CoreQuote as CoreQuoteType, CoreQuoteProps } from '@snapwp/types'; * @param props.attributes - Block attributes. * @param props.children - The block's children. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreQuote: CoreQuoteType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-separator.tsx b/packages/blocks/src/blocks/core-separator.tsx index 32664d98..302ac03c 100644 --- a/packages/blocks/src/blocks/core-separator.tsx +++ b/packages/blocks/src/blocks/core-separator.tsx @@ -11,7 +11,7 @@ import type { * @param props - The props for the block component. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreSeparator: CoreSeparatorType = ( { renderedHtml, diff --git a/packages/blocks/src/blocks/core-spacer.tsx b/packages/blocks/src/blocks/core-spacer.tsx index cd5ddc36..515d7c10 100644 --- a/packages/blocks/src/blocks/core-spacer.tsx +++ b/packages/blocks/src/blocks/core-spacer.tsx @@ -17,7 +17,7 @@ import type { * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreSpacer: CoreSpacerType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-template-part.tsx b/packages/blocks/src/blocks/core-template-part.tsx index f74415b1..068ea1f8 100644 --- a/packages/blocks/src/blocks/core-template-part.tsx +++ b/packages/blocks/src/blocks/core-template-part.tsx @@ -13,7 +13,7 @@ import type { * @param props.children - The block's children. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreTemplatePart: CoreTemplatePartType = ( { renderedHtml, diff --git a/packages/blocks/src/blocks/core-verse.tsx b/packages/blocks/src/blocks/core-verse.tsx index cd650ee2..0bcc90d0 100644 --- a/packages/blocks/src/blocks/core-verse.tsx +++ b/packages/blocks/src/blocks/core-verse.tsx @@ -14,7 +14,7 @@ import type { CoreVerse as CoreVerseType, CoreVerseProps } from '@snapwp/types'; * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element} The rendered block. */ const CoreVerse: CoreVerseType = ( { attributes, diff --git a/packages/blocks/src/blocks/core-video.tsx b/packages/blocks/src/blocks/core-video.tsx index 87114c2c..3d5f175a 100644 --- a/packages/blocks/src/blocks/core-video.tsx +++ b/packages/blocks/src/blocks/core-video.tsx @@ -17,7 +17,7 @@ import type { * @param props - The props for the component. * @param props.tracks - An array of track objects containing `src`, `kind`, `srclang`, and `label`. * - * @return A list of `` elements or `null` if no tracks are provided. + * @return {React.JSX.Element|null} A list of `` elements or `null` if no tracks are provided. */ const Tracks = ( { tracks }: { tracks?: TrackProps[] } ) => { if ( ! tracks || tracks.length === 0 ) { @@ -45,7 +45,7 @@ const Tracks = ( { tracks }: { tracks?: TrackProps[] } ) => { * @param props.attributes - Block attributes. * @param props.renderedHtml - The block's rendered HTML. * - * @return The rendered block. + * @return {React.JSX.Element|null} The rendered block. */ const CoreVideo: CoreVideoType = ( { attributes, diff --git a/packages/blocks/src/blocks/default.tsx b/packages/blocks/src/blocks/default.tsx index 370ea008..bb3706d5 100644 --- a/packages/blocks/src/blocks/default.tsx +++ b/packages/blocks/src/blocks/default.tsx @@ -6,7 +6,8 @@ import type { Default as DefaultType, DefaultProps } from '@snapwp/types'; * Renders the default block. * @param props - The props for the component. * @param props.renderedHtml - The rendered HTML. - * @return The rendered default block. + * + * @return {React.JSX.Element|null} The rendered default block. */ const Default: DefaultType = ( { renderedHtml }: DefaultProps ) => { if ( ! renderedHtml ) { diff --git a/packages/blocks/src/editor-blocks-renderer/index.tsx b/packages/blocks/src/editor-blocks-renderer/index.tsx index 780d91c8..92c7c0a7 100644 --- a/packages/blocks/src/editor-blocks-renderer/index.tsx +++ b/packages/blocks/src/editor-blocks-renderer/index.tsx @@ -14,7 +14,8 @@ type EditorBlocksRendererProps = { * @param props - Props. * @param props.editorBlocks - A list of blocks to be rendered. * @param props.blockDefinitions - Blocks rendering functions. - * @return The rendered template + * + * @return {React.JSX.Element} The rendered template. */ export default function EditorBlocksRenderer( { editorBlocks, diff --git a/packages/blocks/src/utils/flat-list-to-hierarchical.ts b/packages/blocks/src/utils/flat-list-to-hierarchical.ts index 814e897c..d0187333 100644 --- a/packages/blocks/src/utils/flat-list-to-hierarchical.ts +++ b/packages/blocks/src/utils/flat-list-to-hierarchical.ts @@ -14,7 +14,8 @@ type Data = Record< string | number, unknown >; * @param options.idKey The key for the unique identifier. * @param options.parentKey The key for the parent identifier. * @param options.childrenKey The key for the children. - * @return Data Array + * + * @return {Array} Data Array */ export default function flatListToHierarchical( data: Data[] = [], diff --git a/packages/core/src/config/snapwp-config-manager.ts b/packages/core/src/config/snapwp-config-manager.ts index 27c80905..38c00546 100644 --- a/packages/core/src/config/snapwp-config-manager.ts +++ b/packages/core/src/config/snapwp-config-manager.ts @@ -76,7 +76,7 @@ const defaultConfig: Partial< SnapWPEnv & SnapWPConfig > = { * * This is a function (instead of a constant) so we can inject the variables in Jest. * - * @return The configuration object. + * @return {Partial} The configuration object. */ const envConfig = (): Partial< SnapWPEnv > => ( { /* eslint-disable n/no-process-env -- These are the env variables we want to manage. */ @@ -220,7 +220,8 @@ class SnapWPConfigManager { * Normalizes the configuration. * * @param cfg The configuration to normalize. - * @return The normalized configuration. + * + * @return {Partial} The normalized configuration. */ static normalizeConfig = < T >( cfg: Partial< T > ) => { // Removing empty values. @@ -249,7 +250,7 @@ class SnapWPConfigManager { /** * Get the configuration. * - * @return The resolved configuration. + * @return {SnapWPConfig|SnapWPEnv} The resolved configuration. */ static getConfig(): Readonly< SnapWPConfig & SnapWPEnv > { if ( ! SnapWPConfigManager.configsSet ) { @@ -304,7 +305,8 @@ class SnapWPConfigManager { * @param config The configuration to validate. * @param schema The schema to validate the configuration against. * - * @return The resolved configuration. + * @return {Partial} The resolved configuration. + * * @throws {Error} If the configuration is invalid. */ static validateConfig = < T >( @@ -364,7 +366,7 @@ class SnapWPConfigManager { /** * Get the GraphQL URL. * - * @return The GraphQL URL. + * @return {string} The GraphQL URL. */ static getGraphqlUrl(): string { return generateGraphqlUrl( diff --git a/packages/core/src/config/tests/snapwp-config-manager.test.tsx b/packages/core/src/config/tests/snapwp-config-manager.test.tsx index 9f45a1be..73c3b4cb 100644 --- a/packages/core/src/config/tests/snapwp-config-manager.test.tsx +++ b/packages/core/src/config/tests/snapwp-config-manager.test.tsx @@ -12,7 +12,7 @@ import React from 'react'; /** * A mock React component used for testing block definitions. * - * @return A div containing "Test Block". + * @return {React.JSX.Element} A div containing "Test Block". */ const MockBlockComponent = () =>
Test Block
; diff --git a/packages/core/src/logger/index.ts b/packages/core/src/logger/index.ts index 70848be3..2ded22b9 100644 --- a/packages/core/src/logger/index.ts +++ b/packages/core/src/logger/index.ts @@ -60,7 +60,7 @@ class Logger { * * @example Logger.debug("This is a debug message.") * - * @return void + * @return {void} */ static debug = ( ...args: any[] ): void => log( LOGTYPE.DEBUG, ...args ); @@ -71,7 +71,7 @@ class Logger { * * @example Logger.info("This is an info message.") * - * @return void + * @return {void} */ static info = ( ...args: any[] ): void => log( LOGTYPE.INFO, ...args ); @@ -82,7 +82,7 @@ class Logger { * * @example Logger.warn("You should do/change something.") * - * @return void + * @return {void} */ static warn = ( ...args: any[] ): void => log( LOGTYPE.WARN, ...args ); @@ -93,7 +93,7 @@ class Logger { * * @example Logger.error("An error occurred.") * - * @return void + * @return {void} */ static error = ( ...args: any[] ): void => log( LOGTYPE.ERROR, ...args ); @@ -104,7 +104,7 @@ class Logger { * * @example Logger.log("This is a message.") * - * @return void + * @return {void} */ static log = ( ...args: any[] ): void => log( LOGTYPE.LOG, ...args ); } diff --git a/packages/core/src/utils/cn.ts b/packages/core/src/utils/cn.ts index 1fb34a01..d2eefb19 100644 --- a/packages/core/src/utils/cn.ts +++ b/packages/core/src/utils/cn.ts @@ -4,7 +4,8 @@ import { type ClassValue, clsx } from 'clsx'; * Combines class names. * * @param inputs - Class names or objects to combine. - * @return Joined class names. + * + * @return {string} Joined class names. * * @internal */ diff --git a/packages/core/src/utils/find-element-and-get-class-names.ts b/packages/core/src/utils/find-element-and-get-class-names.ts index 6f21f1fb..bcd317cf 100644 --- a/packages/core/src/utils/find-element-and-get-class-names.ts +++ b/packages/core/src/utils/find-element-and-get-class-names.ts @@ -6,7 +6,7 @@ import { getClassNamesFromString, cn } from '@/utils'; * @param renderedHtml - The rendered HTML string. * @param elementSelector - The element selector (class, id, or tag name) If selector is not provided then it will select the first element and will return it's classNames. * - * @return The extracted class names from the first occurrence of the specified element or an empty string if the element is not found. + * @return {string} The extracted class names from the first occurrence of the specified element or an empty string if the element is not found. */ export default function findElementAndGetClassNames( renderedHtml?: string | null, diff --git a/packages/core/src/utils/generate-graphql-url.ts b/packages/core/src/utils/generate-graphql-url.ts index 07c45d24..a06da885 100644 --- a/packages/core/src/utils/generate-graphql-url.ts +++ b/packages/core/src/utils/generate-graphql-url.ts @@ -6,7 +6,7 @@ import { Logger } from '@/logger'; * @param homeUrl The home URL. * @param graphqlEndpoint The GraphQL endpoint. * - * @return The complete GraphQL URL. + * @return {string} The complete GraphQL URL. */ export default function generateGraphqlUrl( homeUrl?: string, diff --git a/packages/core/src/utils/get-class-names-from-string.ts b/packages/core/src/utils/get-class-names-from-string.ts index f2a5f4f7..1a028bac 100644 --- a/packages/core/src/utils/get-class-names-from-string.ts +++ b/packages/core/src/utils/get-class-names-from-string.ts @@ -2,7 +2,8 @@ * Extracts class names from the `class` attribute in an HTML string. * * @param html - The HTML string to parse. - * @return An array of class names. + * + * @return {Array} An array of class names. */ export default function getClassNamesFromString( html: string ): string[] { // Match the first occurrence of the class attribute diff --git a/packages/core/src/utils/get-color-class-name.ts b/packages/core/src/utils/get-color-class-name.ts index 687bdea4..724f8299 100644 --- a/packages/core/src/utils/get-color-class-name.ts +++ b/packages/core/src/utils/get-color-class-name.ts @@ -3,7 +3,8 @@ * * @param colorContextName - The context name for the color (e.g., 'background', 'text'). * @param colorSlug - The slug for the color (e.g., 'primary', 'secondary'). - * @return The generated CSS class name or undefined if parameters are missing. + * + * @return {string|undefined} The generated CSS class name or undefined if parameters are missing. */ export default function getColorClassName( colorContextName?: string, diff --git a/packages/core/src/utils/get-image-size-from-attributes.ts b/packages/core/src/utils/get-image-size-from-attributes.ts index 541ee96f..5bfb6080 100644 --- a/packages/core/src/utils/get-image-size-from-attributes.ts +++ b/packages/core/src/utils/get-image-size-from-attributes.ts @@ -30,7 +30,8 @@ const imageSizeToHeight: { * Retrieves the width and height based on image attributes. * * @param attributes - Image size attributes including sizeSlug, width, and height. - * @return An object containing the width and height in pixels. + * + * @return {Object} An object containing the width and height in pixels. * * @internal */ diff --git a/packages/core/src/utils/get-px-for-size-attribute.ts b/packages/core/src/utils/get-px-for-size-attribute.ts index 0b64d668..270c91ff 100644 --- a/packages/core/src/utils/get-px-for-size-attribute.ts +++ b/packages/core/src/utils/get-px-for-size-attribute.ts @@ -2,7 +2,8 @@ * Converts a size attribute to pixels. * * @param sizeAttribute - The size attribute string (e.g., "10em", "50%"). - * @return The size in pixels. + * + * @return {number} The size in pixels. * * @internal */ diff --git a/packages/core/src/utils/get-spacing-preset-css-var.ts b/packages/core/src/utils/get-spacing-preset-css-var.ts index a57132d3..c02031d5 100644 --- a/packages/core/src/utils/get-spacing-preset-css-var.ts +++ b/packages/core/src/utils/get-spacing-preset-css-var.ts @@ -5,7 +5,7 @@ * * @param value Value to convert. * - * @return CSS var string for given spacing preset value. + * @return {string|undefined} CSS var string for given spacing preset value. */ export default function getSpacingPresetCssVar( value: string | null | undefined diff --git a/packages/core/src/utils/get-style-object-from-string.ts b/packages/core/src/utils/get-style-object-from-string.ts index 4978bf4d..881e3bba 100644 --- a/packages/core/src/utils/get-style-object-from-string.ts +++ b/packages/core/src/utils/get-style-object-from-string.ts @@ -5,7 +5,8 @@ import { Logger } from '@/logger'; * Formats a string to camel case. * * @param str - The input string. - * @return The camelcased string. + * + * @return {string} The camelcased string. * * @internal */ @@ -31,7 +32,8 @@ function formatStringToCamelCase( str: string ): string { * Converts a CSS string to an object. * * @param str - The CSS string. - * @return The style object. + * + * @return {CSSProperties} The style object. */ function cssToReactStyle( str: string ): CSSProperties { const style: { [ key: string ]: string } = {}; // add index signature here @@ -55,7 +57,8 @@ function cssToReactStyle( str: string ): CSSProperties { * Converts a CSS string or object to a React style object. * * @param css - The CSS string. - * @return The style object. + * + * @return {CSSProperties} The style object. */ export default function getStyleObjectFromString( css: object | string diff --git a/packages/core/src/utils/get-styles-from-attributes.ts b/packages/core/src/utils/get-styles-from-attributes.ts index b50d841b..928cec0c 100644 --- a/packages/core/src/utils/get-styles-from-attributes.ts +++ b/packages/core/src/utils/get-styles-from-attributes.ts @@ -9,7 +9,8 @@ interface AttributesWithStyle { * Extracts and compiles styles from attributes. * * @param attributes - Object containing a style string. - * @return Compiled styles as an object or an empty object if no styles exist. + * + * @return {CSSProperties} Compiled styles as an object or an empty object if no styles exist. */ export default function getStylesFromAttributes( attributes: AttributesWithStyle diff --git a/packages/core/src/utils/is-valid-url.ts b/packages/core/src/utils/is-valid-url.ts index 1bb163d7..94114058 100644 --- a/packages/core/src/utils/is-valid-url.ts +++ b/packages/core/src/utils/is-valid-url.ts @@ -1,6 +1,7 @@ /** * @param str A string to be validated as a Url. - * @return flag signifying validity. + * + * @return {boolean} flag signifying validity. * * @internal */ diff --git a/packages/core/src/utils/parse-external-remote-patterns.ts b/packages/core/src/utils/parse-external-remote-patterns.ts index f1f8b3b0..3e2f834a 100644 --- a/packages/core/src/utils/parse-external-remote-patterns.ts +++ b/packages/core/src/utils/parse-external-remote-patterns.ts @@ -1,7 +1,8 @@ /** * Parses given string into remote patterns. * @param str URLs for external image sources in a comma seperated fashion. - * @return an array of remote patterns to be used in next.config.js + * + * @return {Array} an array of remote patterns to be used in next.config.js * * @internal */ diff --git a/packages/core/src/utils/replace-host-url.ts b/packages/core/src/utils/replace-host-url.ts index 61aa1c0d..d8bc0ce6 100644 --- a/packages/core/src/utils/replace-host-url.ts +++ b/packages/core/src/utils/replace-host-url.ts @@ -4,7 +4,8 @@ * @param url - WP url. * @param hostUrl - Host url to be replaced. * @param newHostUrl - Host url to be replaced with. - * @return The internal url. + * + * @return {string} The internal url. * * @internal */ diff --git a/packages/core/src/utils/url-slash-modify.ts b/packages/core/src/utils/url-slash-modify.ts index c0f6ff07..14d5f6cf 100644 --- a/packages/core/src/utils/url-slash-modify.ts +++ b/packages/core/src/utils/url-slash-modify.ts @@ -3,7 +3,7 @@ * * @param url The URL to modify. * - * @return The modified URL. + * @return {string} The modified URL. * * @internal */ @@ -16,7 +16,7 @@ export function removeTrailingSlash( url: string ): string { * * @param url The URL to modify. * - * @return The modified URL. + * @return {string} The modified URL. * * @internal */ @@ -29,7 +29,7 @@ export function addTrailingSlash( url: string ): string { * * @param url The URL to modify. * - * @return The modified URL. + * @return {string} The modified URL. * * @internal */ @@ -42,7 +42,7 @@ export function removeLeadingSlash( url: string ): string { * * @param url The URL to modify. * - * @return The modified URL. + * @return {string} The modified URL. * * @internal */ diff --git a/packages/next/src/components/default-error.tsx b/packages/next/src/components/default-error.tsx index 51133669..63d2fa2c 100644 --- a/packages/next/src/components/default-error.tsx +++ b/packages/next/src/components/default-error.tsx @@ -12,7 +12,7 @@ import React from 'react'; * @param root0.error - The error. * @param root0.reset - The reset function. * - * @return The default error component. + * @return {React.JSX.Element} The default error component. */ export default function DefaultError( { error, diff --git a/packages/next/src/components/font.tsx b/packages/next/src/components/font.tsx index 45144d31..939880c1 100644 --- a/packages/next/src/components/font.tsx +++ b/packages/next/src/components/font.tsx @@ -5,7 +5,8 @@ import React from 'react'; * * @param props - Props for the Font component. * @param props.renderedFontFaces - Font face data as a string. - * @return A style tag with the rendered font faces. + * + * @return {React.JSX.Element} A style tag with the rendered font faces. * * @todo Implement next/font once a solution for handling literal types is determined. */ diff --git a/packages/next/src/components/image.tsx b/packages/next/src/components/image.tsx index d32c8deb..e5ec891c 100644 --- a/packages/next/src/components/image.tsx +++ b/packages/next/src/components/image.tsx @@ -46,7 +46,7 @@ interface ImageInterface { * @param props.fill - If true, fills the container. * @param props.src - Source URL for the image. * - * @return The rendered image. + * @return {React.JSX.Element|null} The rendered image. */ export default function Image( { alt, diff --git a/packages/next/src/components/link.tsx b/packages/next/src/components/link.tsx index ce13528e..fab86ec6 100644 --- a/packages/next/src/components/link.tsx +++ b/packages/next/src/components/link.tsx @@ -22,7 +22,7 @@ interface LinkInterface { * @param props.className - CSS class name. * @param props.children - Block's Children. * - * @return The rendered link. + * @return {React.JSX.Element} The rendered link. */ export default function Link( { href, diff --git a/packages/next/src/components/script-module.tsx b/packages/next/src/components/script-module.tsx index 43908558..f4b44ffc 100644 --- a/packages/next/src/components/script-module.tsx +++ b/packages/next/src/components/script-module.tsx @@ -32,7 +32,8 @@ interface ScriptModuleInterface { * @param props.src - The source URL for the script module * @param props.extraData - Additional data required by the script module * @param props.dependencies - Dependencies required by the script module - * @return The rendered script module elements + * + * @return {React.JSX.Element} The rendered script module elements */ export default function ScriptModule( { handle, diff --git a/packages/next/src/components/script.tsx b/packages/next/src/components/script.tsx index 35045497..ffa9e9a4 100644 --- a/packages/next/src/components/script.tsx +++ b/packages/next/src/components/script.tsx @@ -22,7 +22,8 @@ interface ScriptInterface { * @param props.loadingStrategy - The loading strategy for the script (async or defer). * @param props.groupLocation - The location where the script should be loaded. * @param props.src - The source URL for the script. - * @return The rendered script element. + * + * @return {React.JSX.Element} The rendered script element. */ export default function Script( { after, diff --git a/packages/next/src/config/with-snap-wp.ts b/packages/next/src/config/with-snap-wp.ts index bc9ae9dc..e89330ab 100644 --- a/packages/next/src/config/with-snap-wp.ts +++ b/packages/next/src/config/with-snap-wp.ts @@ -13,7 +13,8 @@ import { * TODO: Explore a better approach to support Turbopack. * * @param snapWPConfigPath The path to the SnapWP configuration file. - * @return A function that modifies the webpack configuration. + * + * @return {(config: any) => any} A function that modifies the webpack configuration. */ const modifyWebpackConfig = ( snapWPConfigPath: string ) => { /** @@ -21,7 +22,8 @@ const modifyWebpackConfig = ( snapWPConfigPath: string ) => { * * @param config The webpack configuration. Using `any` type as the parameter type is `any` in Next.js. * @see node_modules/next/dist/server/config-shared.js:169 - * @return The modified webpack configuration. + * + * @return {any} The modified webpack configuration. */ return ( config: any ) => { const configPath = ` @@ -36,7 +38,8 @@ const modifyWebpackConfig = ( snapWPConfigPath: string ) => { * Tests whether the module should be modified. * * @param normalModule The normal module being processed. - * @return `true` if the module should be modified, otherwise `false`. + * + * @return {boolean} `true` if the module should be modified, otherwise `false`. */ test: ( normalModule ) => { const userRequest = normalModule.userRequest || ''; @@ -74,7 +77,8 @@ const modifyWebpackConfig = ( snapWPConfigPath: string ) => { * Extends the Next.js configuration with SnapWP configuration. * * @param nextConfig The Next.js configuration object. - * @return The extended configuration object. + * + * @return {Promise} The extended configuration object. */ const withSnapWP = async ( nextConfig?: NextConfig ): Promise< NextConfig > => { const possibleSnapWPConfigPaths = [ diff --git a/packages/next/src/middleware/cors.ts b/packages/next/src/middleware/cors.ts index 30e0dbdd..c62ef528 100644 --- a/packages/next/src/middleware/cors.ts +++ b/packages/next/src/middleware/cors.ts @@ -16,7 +16,8 @@ import { Logger } from '@snapwp/core'; * assuming env vars NEXT_PUBLIC_URL had its value set to http://localhost:3000 and NEXT_PUBLIC_WORDPRESS_URL to https://examplewp.com * * @param next - Next middleware - * @return The response object with modified headers + * + * @return {(request:NextRequest, _next:NextFetchEvent) => Promise} The response object with modified headers. */ export const corsProxyMiddleware: MiddlewareFactory = ( next: NextMiddleware @@ -56,8 +57,8 @@ export const corsProxyMiddleware: MiddlewareFactory = ( 'Content-Security-Policy': "default-src 'self'", }, } ); - } catch ( error ) { - Logger.error( 'Proxy error:', error ); + } catch ( error: unknown ) { + Logger.error( 'Proxy error:', error as Error ); return NextResponse.json( { error: 'Internal Server Error' }, { status: 500 } diff --git a/packages/next/src/middleware/current-path.ts b/packages/next/src/middleware/current-path.ts index 3b3a0179..f5c660ea 100644 --- a/packages/next/src/middleware/current-path.ts +++ b/packages/next/src/middleware/current-path.ts @@ -8,7 +8,8 @@ import type { MiddlewareFactory } from './utils'; * which contains the current pathname of the request. * * @param next - Next middleware - * @return The response object with modified headers + * + * @return {(request:NextRequest, _next:NextFetchEvent) => Promise} The response object with modified headers */ export const currentPath: MiddlewareFactory = ( next: NextMiddleware ) => { return async ( request: NextRequest, _next: NextFetchEvent ) => { diff --git a/packages/next/src/middleware/proxies.ts b/packages/next/src/middleware/proxies.ts index 501b4234..677a746b 100644 --- a/packages/next/src/middleware/proxies.ts +++ b/packages/next/src/middleware/proxies.ts @@ -14,7 +14,8 @@ import type { MiddlewareFactory } from './utils'; * This middleware adds custom proxies. * * @param next - Next middleware - * @return Custom redirection or NextMiddleware. + * + * @return {(request:NextRequest, _next:NextFetchEvent) => Promise} Custom redirection or NextMiddleware. */ export const proxies: MiddlewareFactory = ( next: NextMiddleware ) => { return async ( request: NextRequest, _next: NextFetchEvent ) => { diff --git a/packages/next/src/middleware/utils.ts b/packages/next/src/middleware/utils.ts index 6695e7a1..ff99a529 100644 --- a/packages/next/src/middleware/utils.ts +++ b/packages/next/src/middleware/utils.ts @@ -17,7 +17,7 @@ export type MiddlewareFactory = ( * @param stackDefaultMiddlewares Weather to add load default middlewares with custom ones. * Pass false to skip loading default middlewares. * - * @return NextMiddleware + * @return {NextMiddleware} NextJS Middleware. */ export function appMiddlewares( functions: MiddlewareFactory[] = [], @@ -45,7 +45,7 @@ export function appMiddlewares( * * @param middlewares Array containing user defined Middlewares. * - * @return Array combining default middlewares and custom middlewares. + * @return {Array} Array combining default middlewares and custom middlewares. */ export function stackMiddlewares( middlewares: MiddlewareFactory[] = [] ) { const { useCorsProxy } = getConfig(); diff --git a/packages/next/src/react-parser/index.tsx b/packages/next/src/react-parser/index.tsx index b473a7f9..13911b6e 100644 --- a/packages/next/src/react-parser/index.tsx +++ b/packages/next/src/react-parser/index.tsx @@ -8,7 +8,8 @@ import type { HTMLReactParserOptions } from 'html-react-parser'; * * @param props - The props for the parser. * @param props.html - The HTML string to parse and render. - * @return The rendered React components. + * + * @return {React.JSX.Element} The rendered React components. */ export default function Parse( { html }: { html: string } ) { const { diff --git a/packages/next/src/react-parser/options.tsx b/packages/next/src/react-parser/options.tsx index 8714eedc..4cbbe81f 100644 --- a/packages/next/src/react-parser/options.tsx +++ b/packages/next/src/react-parser/options.tsx @@ -17,7 +17,8 @@ export const defaultOptions: HTMLReactParserOptions = { * Replaces anchor tags with Next.js Link components. * * @param domNode - The DOM node being processed. - * @return A React element if the node is an anchor tag, otherwise undefined. + * + * @return {React.JSX.Element|undefined} A React element if the node is an anchor tag, otherwise undefined. */ replace: ( domNode ) => { if ( domNode instanceof Element ) { diff --git a/packages/next/src/root-layout/global-head.tsx b/packages/next/src/root-layout/global-head.tsx index 6858792c..8e42afd0 100644 --- a/packages/next/src/root-layout/global-head.tsx +++ b/packages/next/src/root-layout/global-head.tsx @@ -10,7 +10,8 @@ import { type GlobalHeadProps } from '@snapwp/core'; * @param props.customCss - Custom CSS to be included. * @param props.globalStylesheet - Global stylesheet for the page. * @param props.renderedFontFaces - Font faces rendered locally. - * @return A head element containing the provided styles and links. + * + * @return {React.JSX.Element} A head element containing the provided styles and links. */ export function GlobalHead( { customCss, diff --git a/packages/next/src/root-layout/index.tsx b/packages/next/src/root-layout/index.tsx index dfb3f176..bf0c5c9e 100644 --- a/packages/next/src/root-layout/index.tsx +++ b/packages/next/src/root-layout/index.tsx @@ -12,7 +12,7 @@ export type RootLayoutProps = { * @param props.getGlobalStyles - A async callback to get global styles. * @param props.children - Child components. * - * @return The rendered template + * @return {React.JSX.Element} The rendered template. */ export async function RootLayout( { getGlobalStyles = QueryEngine.getGlobalStyles, diff --git a/packages/next/src/template-renderer/index.tsx b/packages/next/src/template-renderer/index.tsx index cb671583..bef14fed 100644 --- a/packages/next/src/template-renderer/index.tsx +++ b/packages/next/src/template-renderer/index.tsx @@ -18,7 +18,8 @@ export type TemplateRendererProps = { * @param props - The props for the component.. * @param props.getTemplateData - A async callback to get template styles and content. * @param props.children - The block content to render. - * @return A complete HTML document structure. + * + * @return {React.JSX.Element} A complete HTML document structure. */ export async function TemplateRenderer( { getTemplateData = QueryEngine.getTemplateData, diff --git a/packages/next/src/template-renderer/template-head.tsx b/packages/next/src/template-renderer/template-head.tsx index fa853c7e..fadeb852 100644 --- a/packages/next/src/template-renderer/template-head.tsx +++ b/packages/next/src/template-renderer/template-head.tsx @@ -6,7 +6,8 @@ import { type TemplateHeadProps } from '@snapwp/core'; * * @param props - The props for the component. * @param props.stylesheets - An array of additional stylesheets and inline styles. - * @return A head element containing the provided styles and links. + * + * @return {Array|null} A head element containing the provided styles and links. */ export function TemplateHead( { stylesheets }: TemplateHeadProps ) { if ( ! stylesheets ) { diff --git a/packages/next/src/template-renderer/template-scripts.tsx b/packages/next/src/template-renderer/template-scripts.tsx index c13ef5c7..61fa207a 100644 --- a/packages/next/src/template-renderer/template-scripts.tsx +++ b/packages/next/src/template-renderer/template-scripts.tsx @@ -10,7 +10,8 @@ import { getConfig } from '@snapwp/core/config'; * * @param props - The props for the component. * @param props.scripts - Array of script objects to be rendered. - * @return A collection of `