Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
67bb02d
feat: add jsdoc/require-param-type eslint rule
Pathan-Amaankhan Feb 25, 2025
13a8d1e
Merge branch 'develop' of github.com:Pathan-Amaankhan/snapwp into fea…
Pathan-Amaankhan Mar 11, 2025
aaed9e7
refactor: convert root0 to props
Pathan-Amaankhan Mar 11, 2025
60e5dbd
refactor: add param type
Pathan-Amaankhan Mar 11, 2025
9252280
refactor: converts enum to JS object
Pathan-Amaankhan Mar 12, 2025
c3dca20
refactor: update LOGTYPE to string union
Pathan-Amaankhan Mar 13, 2025
76a2852
Merge branch 'develop' of github.com:rtCamp/snapwp into feat/jsdoc-re…
Pathan-Amaankhan Mar 13, 2025
0a43049
refactor: add param type
Pathan-Amaankhan Mar 13, 2025
3bdef83
Merge branch 'develop' into feat/jsdoc-require-param-type
justlevine Mar 18, 2025
0f0b144
Merge branch 'develop' into feat/jsdoc-require-param-type
Ta5r Apr 3, 2025
2f1055a
merge : Fix merge resolution mistake.
Ta5r Apr 3, 2025
07a0a88
fix : Add missing JSDoc param types
Ta5r Apr 3, 2025
faaea02
fix : JSDoc param-types for object like formats.
Ta5r Apr 3, 2025
c997b23
Merge branch 'develop' into feat/jsdoc-require-param-type
Ta5r Apr 3, 2025
cb99d0b
fix : JSDoc param-types in core-list-item
Ta5r Apr 3, 2025
c297cfe
fix : format for mentioning Arrays in param-types
Ta5r Apr 3, 2025
13e175a
fix : formatting in doc comments
Ta5r Apr 3, 2025
61d9636
chore : add changeset
Ta5r Apr 3, 2025
4e13dca
chore : update changeset to patch instead of minor
Ta5r Apr 3, 2025
52ac955
Merge branch 'develop' into feat/jsdoc-require-param-type
justlevine Apr 3, 2025
a8e39ac
chore: update changelog message
justlevine Apr 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/wet-geckos-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@snapwp/e2e-tests": patch
"@snapwp/blocks": patch
"@snapwp/query": patch
"@snapwp/core": patch
"@snapwp/next": patch
---

chore: Enforce `jsdoc/require-param-type` ESLint rule in repository ruleset.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ module.exports = {

// Turn of JSdoc types and use TypeScript types instead.
'jsdoc/no-types': [ 'off' ],
'jsdoc/require-param-type': [ 'error' ],
'jsdoc/require-returns': [ 'warn' ],

// Restrict the use of empty functions.
Expand Down
14 changes: 9 additions & 5 deletions packages/blocks/src/block-manager/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default class BlockManager {

/**
* Update block definitions to be used while rendering blocks.
* @param blockDefinitions - rendering implementaion for blocks.
*
* @param {BlockDefinitions} blockDefinitions Rendering implementation for blocks.
*/
public static addBlockDefinitions(
blockDefinitions: BlockDefinitions
Expand All @@ -25,8 +26,9 @@ 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.
* Function to convert a flat list of blocks to a tree depending on `clientId` and `parentClientId`.
*
* @param {Array<BlockData>} blockList A flat list of blocks.
*
* @return A tree of blocks.
*/
Expand All @@ -50,7 +52,8 @@ export default class BlockManager {
/**
* Mutates the passed the node by adding a render function to a node of block tree.
* if a node uses default renderer(which uses renderedHtml) prunes its children which does not need to be rendered.
* @param node - A flat list of blocks.
*
* @param {BlockTreeNode} node A flat list of blocks.
*/
public static attachRendererToTreeNode = ( node: BlockTreeNode ): void => {
const customBlockDefinition =
Expand Down Expand Up @@ -79,7 +82,8 @@ export default class BlockManager {

/**
* Pre processes a flat list of blocks for rendering.
* @param blockList - A flat list of blocks.
*
* @param {Array<BlockData>} blockList A flat list of blocks.
*
* @return A tree of blocks with render functions.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/src/blocks/core-audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import type { ReactNode } from 'react';
/**
* Renders the core/audio block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreAudioProps['attributes']} props.attributes Block attributes.
* @param {CoreAudioProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/blocks/core-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type { ButtonHTMLAttributes, ReactNode } from 'react';
/**
* Renders the core/button block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param {Object} props The props for the block component.
* @param {CoreButtonProps['attributes']} props.attributes Block attributes.
*
* @return The rendered block.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/src/blocks/core-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type { ReactNode } from 'react';
/**
* Renders the core/buttons block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param {Object} props The props for the block component.
* @param {CoreButtonsProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
*
* @return The rendered block.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/blocks/core-code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import type { ReactNode } from 'react';
/**
* Renders the core/code block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param {Object} props The props for the block component.
* @param {CoreCodeProps['attributes']} props.attributes Block attributes.
*
* @return The rendered block.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/src/blocks/core-column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type { CSSProperties, ReactNode } from 'react';
/**
* Renders the core/column block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param {Object} props The props for the block component.
* @param {CoreColumnProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
*
* @return The rendered block.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/src/blocks/core-columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import type { ReactNode } from 'react';
/**
* Renders the core/columns block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param {Object} props The props for the block component.
* @param {CoreColumnsProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
*
* @return The rendered block.
*/
Expand Down
15 changes: 8 additions & 7 deletions packages/blocks/src/blocks/core-cover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };
*
* @see https://github.com/WordPress/gutenberg/blob/887243c1cb2b3280934fbff05d4af8e46a3feddc/packages/block-library/src/cover/shared.js#L27
*
* @param focalPoint - The focal point coordinates object containing x and y values.
* @param {FocalPoint} focalPoint The focal point coordinates object containing x and y values.
*
* @return CSS position string or undefined if no focal point
*/
Expand All @@ -39,12 +39,13 @@ const mediaPosition = (

/**
* Renders the core/cover block.
* @param root0 - The component props object
* @param root0.attributes - Block attributes including styling and media settings
* @param root0.children - Child elements to render inside the cover
* @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
*
* @param {Object} props The component props object
* @param {CoreCoverProps['attributes']} props.attributes Block attributes including styling and media settings
* @param {ReactNode} props.children Child elements to render inside the cover
* @param {CoreCoverProps['renderedHtml']} props.renderedHtml Pre-rendered HTML string for class extraction
* @param {CoreCoverProps['connectedMediaItem']} props.connectedMediaItem The connected media item object
* @param {CoreCoverProps['mediaDetails']} props.mediaDetails The media details object
*
* @return The rendered cover block or null if using featured image
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/blocks/src/blocks/core-details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type { ReactNode } from 'react';
/**
* Renders the core/details block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreDetailsProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
* @param {CoreDetailsProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/src/blocks/core-file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ const FALLBACK_ARIA_LABEL = 'PDF embed';
/**
* Renders the core/file block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreFileProps['attributes']} props.attributes Block attributes.
* @param {CoreFileProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/blocks/core-freeform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import type { ReactNode } from 'react';
/**
* Renders the core/freeform block.
*
* @param props - The props for the block component.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreFreeformProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/blocks/src/blocks/core-gallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import type { ReactNode } from 'react';
/**
* Renders the core/gallery block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreGalleryProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
* @param {CoreGalleryProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
18 changes: 9 additions & 9 deletions packages/blocks/src/blocks/core-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import type { CoreGroup as CoreGroupType, CoreGroupProps } from '@snapwp/types';
/**
* Renders an HTML element with the specified tag name.
*
* @param props - The props for the block component.
* @param props.name - The tag name of the HTML element.
* @param props.className - Class names.
* @param props.style - Inline styles.
* @param props.children - The content to render inside the element.
* @param {Object} props The props for the block component.
* @param {TagProps['name']} props.name The tag name of the HTML element.
* @param {TagProps['className']} props.className Class names.
* @param {TagProps['style']} props.style Inline styles.
* @param {ReactNode} props.children The content to render inside the element.
*
* @return The rendered HTML element or the children if no tag name is provided.
*/
Expand All @@ -43,10 +43,10 @@ const Tag = ( {
/**
* Renders the core/group block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreGroupProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
* @param {CoreGroupProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/blocks/core-heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import type { JSX, ReactNode } from 'react';
/**
* Renders the core/heading block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param {Object} props The props for the block component.
* @param {CoreHeadingProps['attributes']} props.attributes Block attributes.
*
* @return The rendered block.
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/blocks/src/blocks/core-html.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { ReactNode } from 'react';
/**
* Renders the core/html block.
*
* @param props - The props for the block component.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreHtmlProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
44 changes: 22 additions & 22 deletions packages/blocks/src/blocks/core-image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import type { ComponentProps, CSSProperties, ReactNode } from 'react';
/**
* Renders a figure element with optional link and caption.
*
* @param props - The properties for the figure element.
* @param [props.children] - The children of the figure element.
* @param [props.classNames] - The class names for the figure element.
* @param [props.renderedHtml] - The rendered HTML.
* @param [props.href] - The href for the link.
* @param [props.linkClass] - The class for the link.
* @param [props.linkTarget] - The target for the link.
* @param [props.rel] - The rel for the link.
* @param [props.lightbox] - The lightbox attribute.
* @param {Object} props The properties for the figure element.
* @param {ReactNode} props.children The children of the figure element.
* @param {FigureProps['classNames']} props.classNames The class names for the figure element.
* @param {FigureProps['renderedHtml']} props.renderedHtml The rendered HTML.
* @param {FigureProps['href']} props.href The href for the link.
* @param {FigureProps['linkClass']} props.linkClass The class for the link.
* @param {FigureProps['linkTarget']} props.linkTarget The target for the link.
* @param {FigureProps['rel']} props.rel The rel for the link.
* @param {FigureProps['lightbox']} props.lightbox The lightbox attribute.
*
* @return The rendered figure element.
*/
Expand Down Expand Up @@ -73,11 +73,11 @@ const Figure = ( {
*
* @todo Expose context and state to frontend for lightbox functionality.
*
* @param props - The properties for the core image block.
* @param [props.attributes] - The attributes for the image.
* @param [props.connectedMediaItem] - The connected media item.
* @param [props.mediaDetails] - The media details.
* @param [props.renderedHtml] - The rendered HTML.
* @param {Object} props The properties for the core image block.
* @param {CoreImageProps['attributes']} props.attributes The attributes for the image.
* @param {CoreImageProps['connectedMediaItem']} props.connectedMediaItem The connected media item.
* @param {CoreImageProps['mediaDetails']} props.mediaDetails The media details.
* @param {CoreImageProps['renderedHtml']} props.renderedHtml The rendered HTML.
*
* @return The rendered core image block or null if no URL is provided.
*/
Expand Down Expand Up @@ -168,9 +168,9 @@ const CoreImage: CoreImageType = ( {
/**
* Returns the props for the image component.
*
* @param [attributes] The attributes for the image.
* @param [connectedMediaItem] The connected media item.
* @param [mediaDetails] The media details.
* @param {CoreImageAttributes} attributes The attributes for the image.
* @param {CoreImageConnectedMediaItem} connectedMediaItem The connected media item.
* @param {CoreImageMediaDetails} mediaDetails The media details.
*
* @return The props for the image component.
*/
Expand Down Expand Up @@ -244,7 +244,7 @@ const getImageProps = (
/**
* Is Lightbox enabled for the image.
*
* @param lightbox - The lightbox attribute.
* @param {string} lightbox The lightbox attribute.
*
* @return Whether the lightbox is enabled.
*/
Expand All @@ -264,8 +264,8 @@ const isLightboxEnabled = ( lightbox?: string | null ): boolean => {
/**
* Extracts interactivity attributes from the rendered HTML for a given element.
*
* @param element - The element to extract attributes for.
* @param renderedHtml - The rendered HTML.
* @param {string} element The element to extract attributes for.
* @param {string} renderedHtml The rendered HTML.
*
* @return The extracted interactivity attributes.
*/
Expand Down Expand Up @@ -304,8 +304,8 @@ const extractInteractivityAttributesForElement = (
/**
* Extracts ARIA attributes from the rendered HTML for a given element.
*
* @param element - The element to extract attributes for.
* @param renderedHtml - The rendered HTML.
* @param {string} element The element to extract attributes for.
* @param {string} renderedHtml The rendered HTML.
*
* @return The extracted ARIA attributes.
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/blocks/src/blocks/core-list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import type { ReactNode } from 'react';
/**
* Renders the core/list-item block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param props.renderedHtml - The block's rendered HTML.
* @param {Object} props The props for the block component.
* @param {CoreListItemProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
* @param {CoreListItemProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
*
* @return The rendered block.
*/
Expand Down
6 changes: 3 additions & 3 deletions packages/blocks/src/blocks/core-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type { CSSProperties, ReactNode } from 'react';
/**
* Renders the core/list block.
*
* @param props - The props for the block component.
* @param props.attributes - Block attributes.
* @param props.children - The block's children.
* @param {Object} props The props for the block component.
* @param {CoreListProps['attributes']} props.attributes Block attributes.
* @param {ReactNode} props.children The block's children.
*
* @return The rendered block.
*/
Expand Down
Loading