From f7226c4b51b580607de28253460b3ef9a69191ff Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 3 Dec 2024 17:59:17 +0000 Subject: [PATCH] Fix: Invalid JSDoc for optional string parameter and return value. (#67489) Co-authored-by: jorgefilipecosta --- docs/reference-guides/data/data-core-blocks.md | 8 ++++---- docs/reference-guides/data/data-core-editor.md | 2 +- .../reference-guides/data/data-core-keyboard-shortcuts.md | 4 ++-- packages/block-editor/src/hooks/gap.js | 2 +- packages/block-library/src/list-item/hooks/use-merge.js | 4 ++-- packages/blocks/src/store/selectors.js | 8 ++++---- packages/date/README.md | 2 +- packages/date/src/index.js | 2 +- packages/e2e-test-utils/README.md | 8 ++++---- packages/e2e-test-utils/src/delete-theme.js | 4 ++-- packages/e2e-test-utils/src/get-current-user.js | 2 +- packages/e2e-test-utils/src/install-plugin.js | 2 +- packages/e2e-test-utils/src/install-theme.js | 2 +- packages/editor/src/store/selectors.js | 2 +- packages/keyboard-shortcuts/src/store/selectors.js | 6 +++--- 15 files changed, 29 insertions(+), 29 deletions(-) diff --git a/docs/reference-guides/data/data-core-blocks.md b/docs/reference-guides/data/data-core-blocks.md index 084c9c1d7a5fbc..158b7f92529122 100644 --- a/docs/reference-guides/data/data-core-blocks.md +++ b/docs/reference-guides/data/data-core-blocks.md @@ -385,7 +385,7 @@ _Parameters_ _Returns_ -- `string?`: Default block name. +- `?string`: Default block name. ### getDefaultBlockVariation @@ -464,7 +464,7 @@ _Parameters_ _Returns_ -- `string?`: Name of the block for handling non-block content. +- `?string`: Name of the block for handling non-block content. ### getGroupingBlockName @@ -502,7 +502,7 @@ _Parameters_ _Returns_ -- `string?`: Name of the block for handling the grouping of blocks. +- `?string`: Name of the block for handling the grouping of blocks. ### getUnregisteredFallbackBlockName @@ -540,7 +540,7 @@ _Parameters_ _Returns_ -- `string?`: Name of the block for handling unregistered blocks. +- `?string`: Name of the block for handling unregistered blocks. ### hasBlockSupport diff --git a/docs/reference-guides/data/data-core-editor.md b/docs/reference-guides/data/data-core-editor.md index 44078ab284e94f..a9f07104bd3b6e 100644 --- a/docs/reference-guides/data/data-core-editor.md +++ b/docs/reference-guides/data/data-core-editor.md @@ -272,7 +272,7 @@ _Parameters_ _Returns_ -- `string?`: Template ID. +- `?string`: Template ID. ### getDeviceType diff --git a/docs/reference-guides/data/data-core-keyboard-shortcuts.md b/docs/reference-guides/data/data-core-keyboard-shortcuts.md index d7d5cf853f7865..426fb316021a42 100644 --- a/docs/reference-guides/data/data-core-keyboard-shortcuts.md +++ b/docs/reference-guides/data/data-core-keyboard-shortcuts.md @@ -239,7 +239,7 @@ _Parameters_ _Returns_ -- `string?`: Shortcut description. +- `?string`: Shortcut description. ### getShortcutKeyCombination @@ -335,7 +335,7 @@ _Parameters_ _Returns_ -- `string?`: Shortcut representation. +- `?string`: Shortcut representation. diff --git a/packages/block-editor/src/hooks/gap.js b/packages/block-editor/src/hooks/gap.js index debe1ad1690782..887325e6409dde 100644 --- a/packages/block-editor/src/hooks/gap.js +++ b/packages/block-editor/src/hooks/gap.js @@ -27,7 +27,7 @@ export function getGapBoxControlValueFromStyle( blockGapValue ) { * Returns a CSS value for the `gap` property from a given blockGap style. * * @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}. - * @param {string?} defaultValue A default gap value. + * @param {?string} defaultValue A default gap value. * @return {string|null} The concatenated gap value (row and column). */ export function getGapCSSValue( blockGapValue, defaultValue = '0' ) { diff --git a/packages/block-library/src/list-item/hooks/use-merge.js b/packages/block-library/src/list-item/hooks/use-merge.js index 9ca4d5372ee6e8..3fe755868df37d 100644 --- a/packages/block-library/src/list-item/hooks/use-merge.js +++ b/packages/block-library/src/list-item/hooks/use-merge.js @@ -49,7 +49,7 @@ export default function useMerge( clientId, onMerge ) { * return the next list item of the parent list item if it exists. * * @param {string} id A list item client ID. - * @return {string?} The client ID of the next list item. + * @return {?string} The client ID of the next list item. */ function _getNextId( id ) { const next = getNextBlockClientId( id ); @@ -68,7 +68,7 @@ export default function useMerge( clientId, onMerge ) { * line, regardless of indentation level. * * @param {string} id The client ID of the current list item. - * @return {string?} The client ID of the next list item. + * @return {?string} The client ID of the next list item. */ function getNextId( id ) { const order = getBlockOrder( id ); diff --git a/packages/blocks/src/store/selectors.js b/packages/blocks/src/store/selectors.js index 79e88073ba20de..c4589ce8232f66 100644 --- a/packages/blocks/src/store/selectors.js +++ b/packages/blocks/src/store/selectors.js @@ -437,7 +437,7 @@ export function getCollections( state ) { * }; * ``` * - * @return {string?} Default block name. + * @return {?string} Default block name. */ export function getDefaultBlockName( state ) { return state.defaultBlockName; @@ -473,7 +473,7 @@ export function getDefaultBlockName( state ) { * }; * ``` * - * @return {string?} Name of the block for handling non-block content. + * @return {?string} Name of the block for handling non-block content. */ export function getFreeformFallbackBlockName( state ) { return state.freeformFallbackBlockName; @@ -509,7 +509,7 @@ export function getFreeformFallbackBlockName( state ) { * }; * ``` * - * @return {string?} Name of the block for handling unregistered blocks. + * @return {?string} Name of the block for handling unregistered blocks. */ export function getUnregisteredFallbackBlockName( state ) { return state.unregisteredFallbackBlockName; @@ -545,7 +545,7 @@ export function getUnregisteredFallbackBlockName( state ) { * }; * ``` * - * @return {string?} Name of the block for handling the grouping of blocks. + * @return {?string} Name of the block for handling the grouping of blocks. */ export function getGroupingBlockName( state ) { return state.groupingBlockName; diff --git a/packages/date/README.md b/packages/date/README.md index ed2dfdd4790324..4f0a64c24aa713 100644 --- a/packages/date/README.md +++ b/packages/date/README.md @@ -75,7 +75,7 @@ Create and return a JavaScript Date Object from a date string in the WP timezone _Parameters_ -- _dateString_ `string?`: Date formatted in the WP timezone. +- _dateString_ `?string`: Date formatted in the WP timezone. _Returns_ diff --git a/packages/date/src/index.js b/packages/date/src/index.js index b632de3a7431f6..8d8f53fd8bc10f 100644 --- a/packages/date/src/index.js +++ b/packages/date/src/index.js @@ -588,7 +588,7 @@ export function isInTheFuture( dateValue ) { /** * Create and return a JavaScript Date Object from a date string in the WP timezone. * - * @param {string?} dateString Date formatted in the WP timezone. + * @param {?string} dateString Date formatted in the WP timezone. * * @return {Date} Date */ diff --git a/packages/e2e-test-utils/README.md b/packages/e2e-test-utils/README.md index 196768b0e2487c..30548961db26a4 100644 --- a/packages/e2e-test-utils/README.md +++ b/packages/e2e-test-utils/README.md @@ -253,8 +253,8 @@ _Parameters_ - _slug_ `string`: Theme slug. - _settings_ `Object?`: Optional settings object. -- _settings.newThemeSlug_ `string?`: A theme to switch to if the theme to delete is active. Required if the theme to delete is active. -- _settings.newThemeSearchTerm_ `string?`: A search term to use if the new theme is not findable by its slug. +- _settings.newThemeSlug_ `?string`: A theme to switch to if the theme to delete is active. Required if the theme to delete is active. +- _settings.newThemeSearchTerm_ `?string`: A search term to use if the new theme is not findable by its slug. ### deleteUser @@ -479,7 +479,7 @@ Installs a plugin from the WP.org repository. _Parameters_ - _slug_ `string`: Plugin slug. -- _searchTerm_ `string?`: If the plugin is not findable by its slug use an alternative term to search. +- _searchTerm_ `?string`: If the plugin is not findable by its slug use an alternative term to search. ### installTheme @@ -489,7 +489,7 @@ _Parameters_ - _slug_ `string`: Theme slug. - _settings_ `Object?`: Optional settings object. -- _settings.searchTerm_ `string?`: Search term to use if the theme is not findable by its slug. +- _settings.searchTerm_ `?string`: Search term to use if the theme is not findable by its slug. ### isCurrentURL diff --git a/packages/e2e-test-utils/src/delete-theme.js b/packages/e2e-test-utils/src/delete-theme.js index 98b7e2b4589234..8b59c9f1e7a112 100644 --- a/packages/e2e-test-utils/src/delete-theme.js +++ b/packages/e2e-test-utils/src/delete-theme.js @@ -13,8 +13,8 @@ import { isThemeInstalled } from './theme-installed'; * * @param {string} slug Theme slug. * @param {Object?} settings Optional settings object. - * @param {string?} settings.newThemeSlug A theme to switch to if the theme to delete is active. Required if the theme to delete is active. - * @param {string?} settings.newThemeSearchTerm A search term to use if the new theme is not findable by its slug. + * @param {?string} settings.newThemeSlug A theme to switch to if the theme to delete is active. Required if the theme to delete is active. + * @param {?string} settings.newThemeSearchTerm A search term to use if the new theme is not findable by its slug. */ export async function deleteTheme( slug, diff --git a/packages/e2e-test-utils/src/get-current-user.js b/packages/e2e-test-utils/src/get-current-user.js index d59ec0da2dd5da..6777c842be01f1 100644 --- a/packages/e2e-test-utils/src/get-current-user.js +++ b/packages/e2e-test-utils/src/get-current-user.js @@ -1,7 +1,7 @@ /** * Get the username of the user that's currently logged into WordPress (if any). * - * @return {string?} username The user that's currently logged into WordPress (if any). + * @return {?string} username The user that's currently logged into WordPress (if any). */ export async function getCurrentUser() { const cookies = await page.cookies(); diff --git a/packages/e2e-test-utils/src/install-plugin.js b/packages/e2e-test-utils/src/install-plugin.js index 5edfbb54f6642a..239909953d518f 100644 --- a/packages/e2e-test-utils/src/install-plugin.js +++ b/packages/e2e-test-utils/src/install-plugin.js @@ -9,7 +9,7 @@ import { visitAdminPage } from './visit-admin-page'; * Installs a plugin from the WP.org repository. * * @param {string} slug Plugin slug. - * @param {string?} searchTerm If the plugin is not findable by its slug use an alternative term to search. + * @param {?string} searchTerm If the plugin is not findable by its slug use an alternative term to search. */ export async function installPlugin( slug, searchTerm ) { await switchUserToAdmin(); diff --git a/packages/e2e-test-utils/src/install-theme.js b/packages/e2e-test-utils/src/install-theme.js index 7d001d395bda7f..7f11e5da88ef83 100644 --- a/packages/e2e-test-utils/src/install-theme.js +++ b/packages/e2e-test-utils/src/install-theme.js @@ -11,7 +11,7 @@ import { isThemeInstalled } from './theme-installed'; * * @param {string} slug Theme slug. * @param {Object?} settings Optional settings object. - * @param {string?} settings.searchTerm Search term to use if the theme is not findable by its slug. + * @param {?string} settings.searchTerm Search term to use if the theme is not findable by its slug. */ export async function installTheme( slug, { searchTerm } = {} ) { await switchUserToAdmin(); diff --git a/packages/editor/src/store/selectors.js b/packages/editor/src/store/selectors.js index a090fee0abd641..4ab0a47210353b 100644 --- a/packages/editor/src/store/selectors.js +++ b/packages/editor/src/store/selectors.js @@ -206,7 +206,7 @@ export function getCurrentPostId( state ) { * * @param {Object} state Global application state. * - * @return {string?} Template ID. + * @return {?string} Template ID. */ export function getCurrentTemplateId( state ) { return state.templateId; diff --git a/packages/keyboard-shortcuts/src/store/selectors.js b/packages/keyboard-shortcuts/src/store/selectors.js index 99309d3e24085c..1e4872b46a4a77 100644 --- a/packages/keyboard-shortcuts/src/store/selectors.js +++ b/packages/keyboard-shortcuts/src/store/selectors.js @@ -40,7 +40,7 @@ const FORMATTING_METHODS = { * @param {keyof FORMATTING_METHODS} representation Type of representation * (display, raw, ariaLabel). * - * @return {string?} Shortcut representation. + * @return {?string} Shortcut representation. */ function getKeyCombinationRepresentation( shortcut, representation ) { if ( ! shortcut ) { @@ -135,7 +135,7 @@ export function getShortcutKeyCombination( state, name ) { * }; *``` * - * @return {string?} Shortcut representation. + * @return {?string} Shortcut representation. */ export function getShortcutRepresentation( state, @@ -172,7 +172,7 @@ export function getShortcutRepresentation( * ); * }; *``` - * @return {string?} Shortcut description. + * @return {?string} Shortcut description. */ export function getShortcutDescription( state, name ) { return state[ name ] ? state[ name ].description : null;