Skip to content

Commit c460b31

Browse files
Ta5rPathan-Amaankhanjustlevine
authored
chore: Add jsdoc/require-param-type eslint rule (#142)
* feat: add jsdoc/require-param-type eslint rule * refactor: convert root0 to props * refactor: add param type * refactor: converts enum to JS object * refactor: update LOGTYPE to string union * refactor: add param type * merge : Fix merge resolution mistake. * fix : Add missing JSDoc param types * fix : JSDoc param-types for object like formats. * fix : JSDoc param-types in core-list-item * fix : format for mentioning Arrays in param-types * fix : formatting in doc comments * chore : add changeset * chore : update changeset to patch instead of minor * chore: update changelog message --------- Co-authored-by: Amaan Khan <[email protected]> Co-authored-by: Dovid Levine <[email protected]>
1 parent 6324467 commit c460b31

File tree

77 files changed

+310
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+310
-297
lines changed

.changeset/wet-geckos-check.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@snapwp/e2e-tests": patch
3+
"@snapwp/blocks": patch
4+
"@snapwp/query": patch
5+
"@snapwp/core": patch
6+
"@snapwp/next": patch
7+
---
8+
9+
chore: Enforce `jsdoc/require-param-type` ESLint rule in repository ruleset.

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ module.exports = {
7171

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

7677
// Restrict the use of empty functions.

packages/blocks/src/block-manager/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export default class BlockManager {
1313

1414
/**
1515
* Update block definitions to be used while rendering blocks.
16-
* @param blockDefinitions - rendering implementaion for blocks.
16+
*
17+
* @param {BlockDefinitions} blockDefinitions Rendering implementation for blocks.
1718
*/
1819
public static addBlockDefinitions(
1920
blockDefinitions: BlockDefinitions
@@ -25,8 +26,9 @@ export default class BlockManager {
2526
}
2627

2728
/**
28-
* Function to convert a flat list of blocks to a tree depending on `clientId` and `parentClientId`
29-
* @param blockList - A flat list of blocks.
29+
* Function to convert a flat list of blocks to a tree depending on `clientId` and `parentClientId`.
30+
*
31+
* @param {Array<BlockData>} blockList A flat list of blocks.
3032
*
3133
* @return A tree of blocks.
3234
*/
@@ -50,7 +52,8 @@ export default class BlockManager {
5052
/**
5153
* Mutates the passed the node by adding a render function to a node of block tree.
5254
* if a node uses default renderer(which uses renderedHtml) prunes its children which does not need to be rendered.
53-
* @param node - A flat list of blocks.
55+
*
56+
* @param {BlockTreeNode} node A flat list of blocks.
5457
*/
5558
public static attachRendererToTreeNode = ( node: BlockTreeNode ): void => {
5659
const customBlockDefinition =
@@ -79,7 +82,8 @@ export default class BlockManager {
7982

8083
/**
8184
* Pre processes a flat list of blocks for rendering.
82-
* @param blockList - A flat list of blocks.
85+
*
86+
* @param {Array<BlockData>} blockList A flat list of blocks.
8387
*
8488
* @return A tree of blocks with render functions.
8589
*/

packages/blocks/src/blocks/core-audio.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import type { ReactNode } from 'react';
99
/**
1010
* Renders the core/audio block.
1111
*
12-
* @param props - The props for the block component.
13-
* @param props.attributes - Block attributes.
14-
* @param props.renderedHtml - The block's rendered HTML.
12+
* @param {Object} props The props for the block component.
13+
* @param {CoreAudioProps['attributes']} props.attributes Block attributes.
14+
* @param {CoreAudioProps['renderedHtml']} props.renderedHtml The block's rendered HTML.
1515
*
1616
* @return The rendered block.
1717
*/

packages/blocks/src/blocks/core-button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import type { ButtonHTMLAttributes, ReactNode } from 'react';
99
/**
1010
* Renders the core/button block.
1111
*
12-
* @param props - The props for the block component.
13-
* @param props.attributes - Block attributes.
12+
* @param {Object} props The props for the block component.
13+
* @param {CoreButtonProps['attributes']} props.attributes Block attributes.
1414
*
1515
* @return The rendered block.
1616
*/

packages/blocks/src/blocks/core-buttons.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import type { ReactNode } from 'react';
88
/**
99
* Renders the core/buttons block.
1010
*
11-
* @param props - The props for the block component.
12-
* @param props.attributes - Block attributes.
13-
* @param props.children - The block's children.
11+
* @param {Object} props The props for the block component.
12+
* @param {CoreButtonsProps['attributes']} props.attributes Block attributes.
13+
* @param {ReactNode} props.children The block's children.
1414
*
1515
* @return The rendered block.
1616
*/

packages/blocks/src/blocks/core-code.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import type { ReactNode } from 'react';
66
/**
77
* Renders the core/code block.
88
*
9-
* @param props - The props for the block component.
10-
* @param props.attributes - Block attributes.
9+
* @param {Object} props The props for the block component.
10+
* @param {CoreCodeProps['attributes']} props.attributes Block attributes.
1111
*
1212
* @return The rendered block.
1313
*/

packages/blocks/src/blocks/core-column.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import type { CSSProperties, ReactNode } from 'react';
88
/**
99
* Renders the core/column block.
1010
*
11-
* @param props - The props for the block component.
12-
* @param props.attributes - Block attributes.
13-
* @param props.children - The block's children.
11+
* @param {Object} props The props for the block component.
12+
* @param {CoreColumnProps['attributes']} props.attributes Block attributes.
13+
* @param {ReactNode} props.children The block's children.
1414
*
1515
* @return The rendered block.
1616
*/

packages/blocks/src/blocks/core-columns.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import type { ReactNode } from 'react';
88
/**
99
* Renders the core/columns block.
1010
*
11-
* @param props - The props for the block component.
12-
* @param props.attributes - Block attributes.
13-
* @param props.children - The block's children.
11+
* @param {Object} props The props for the block component.
12+
* @param {CoreColumnsProps['attributes']} props.attributes Block attributes.
13+
* @param {ReactNode} props.children The block's children.
1414
*
1515
* @return The rendered block.
1616
*/

packages/blocks/src/blocks/core-cover.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };
2222
*
2323
* @see https://github.com/WordPress/gutenberg/blob/887243c1cb2b3280934fbff05d4af8e46a3feddc/packages/block-library/src/cover/shared.js#L27
2424
*
25-
* @param focalPoint - The focal point coordinates object containing x and y values.
25+
* @param {FocalPoint} focalPoint The focal point coordinates object containing x and y values.
2626
*
2727
* @return CSS position string or undefined if no focal point
2828
*/
@@ -39,12 +39,13 @@ const mediaPosition = (
3939

4040
/**
4141
* Renders the core/cover block.
42-
* @param root0 - The component props object
43-
* @param root0.attributes - Block attributes including styling and media settings
44-
* @param root0.children - Child elements to render inside the cover
45-
* @param root0.renderedHtml - Pre-rendered HTML string for class extraction
46-
* @param root0.connectedMediaItem - The connected media item object
47-
* @param root0.mediaDetails - The media details object
42+
*
43+
* @param {Object} props The component props object
44+
* @param {CoreCoverProps['attributes']} props.attributes Block attributes including styling and media settings
45+
* @param {ReactNode} props.children Child elements to render inside the cover
46+
* @param {CoreCoverProps['renderedHtml']} props.renderedHtml Pre-rendered HTML string for class extraction
47+
* @param {CoreCoverProps['connectedMediaItem']} props.connectedMediaItem The connected media item object
48+
* @param {CoreCoverProps['mediaDetails']} props.mediaDetails The media details object
4849
*
4950
* @return The rendered cover block or null if using featured image
5051
*/

0 commit comments

Comments
 (0)