Skip to content

Commit

Permalink
Code style: Fix ESLint warnings reported for JSDoc definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Oct 22, 2019
1 parent 6da4593 commit 19c2d7f
Show file tree
Hide file tree
Showing 101 changed files with 387 additions and 348 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ _Parameters_

_Returns_

- `Array<WPBlock>`: Block objects.
- `null`: Block objects.

<a name="getBlockSelectionEnd" href="#getBlockSelectionEnd">#</a> **getBlockSelectionEnd**

Expand Down Expand Up @@ -345,7 +345,7 @@ _Parameters_

_Returns_

- `Array<Editor.InserterItem>`: Items that appear in inserter.
- `Array<EditorInserterItem>`: Items that appear in inserter.

<a name="getLastMultiSelectedBlockClientId" href="#getLastMultiSelectedBlockClientId">#</a> **getLastMultiSelectedBlockClientId**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ _Parameters_

- _state_ `Object`: Global application state.
- _preferenceKey_ `string`: Preference Key.
- _defaultValue_ `Mixed`: Default Value.
- _defaultValue_ `*`: Default Value.

_Returns_

- `Mixed`: Preference Value.
- `*`: Preference Value.

<a name="getPreferences" href="#getPreferences">#</a> **getPreferences**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ _Parameters_

_Returns_

- `Array<WPBlock>`: Filtered set of blocks for save.
- `null`: Filtered set of blocks for save.

<a name="getClientIdsOfDescendants" href="#getClientIdsOfDescendants">#</a> **getClientIdsOfDescendants**

Expand Down
2 changes: 1 addition & 1 deletion docs/designers-developers/developers/data/data-core-nux.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _Parameters_

_Returns_

- `?NUX.GuideInfo`: Information about the associated guide.
- `?NUXGuideInfo`: Information about the associated guide.

<a name="isTipVisible" href="#isTipVisible">#</a> **isTipVisible**

Expand Down
2 changes: 1 addition & 1 deletion docs/designers-developers/developers/data/data-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ a given URl has been received.
_Parameters_

- _url_ `string`: URL to preview the embed for.
- _preview_ `Mixed`: Preview data.
- _preview_ `*`: Preview data.

_Returns_

Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ _Parameters_

_Returns_

- `WPElement`: Rendered element.
- `null`: The component to be rendered.

<a name="BlockSelectionClearer" href="#BlockSelectionClearer">#</a> **BlockSelectionClearer**

Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/components/block-edit/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export { Provider as BlockEditContextProvider };
* expected to return object of props to
* merge with the component's own props.
*
* @return {Component} Enhanced component with injected context as props.
* @return {import('@wordpress/element').WPComponent} Enhanced component with injected context as props.
*/
export const withBlockEditContext = ( mapContextToProps ) => createHigherOrderComponent( ( OriginalComponent ) => {
return ( props ) => (
Expand All @@ -46,9 +46,9 @@ export const withBlockEditContext = ( mapContextToProps ) => createHigherOrderCo
* A Higher Order Component used to render conditionally the wrapped
* component only when the BlockEdit has selected state set.
*
* @param {Component} OriginalComponent Component to wrap.
* @param {import('@wordpress/element').WPComponent} OriginalComponent Component to wrap.
*
* @return {Component} Component which renders only when the BlockEdit is selected.
* @return {import('@wordpress/element').WPComponent} Component which renders only when the BlockEdit is selected.
*/
export const ifBlockEditSelected = createHigherOrderComponent( ( OriginalComponent ) => {
return ( props ) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import BlockTitle from '../block-title';
* the root block.
*
* @param {string} props.clientId Client ID of block.
* @return {WPElement} Block Breadcrumb.
* @return {import('@wordpress/element').WPComponent} The component to be rendered.
*/
const BlockBreadcrumb = forwardRef( ( { clientId }, ref ) => {
const { setNavigationMode } = useDispatch( 'core/block-editor' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function BlockPreview( { blocks, viewportWidth = 700, padding, settings }
*
* @param {Array|Object} blocks A block instance (object) or an array of blocks to be previewed.
* @param {number} viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.
* @return {WPElement} Rendered element.
* @return {import('@wordpress/element').WPComponent} The component to be rendered.
*/
export default withSelect( ( select ) => {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/colors/with-colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const withEditorColorPalette = () => withSelect( ( select ) => {
* @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
* @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
*
* @return {Component} The component that can be used as a HOC.
* @return {import('@wordpress/element').WPComponent} The component that can be used as a HOC.
*/
function createColorHOC( colorTypes, withColorPalette ) {
const colorMap = reduce( colorTypes, ( colorObject, colorType ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Component, forwardRef, createElement } from '@wordpress/element';
* element should stop propagation but not invoke a callback handler, since it
* would be assumed these are invoked by the child element.
*
* @type {Component}
* @type {import('@wordpress/element').WPComponent}
*/
export class IgnoreNestedEvents extends Component {
constructor() {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inserter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Inserter extends Component {
* pressed.
* @param {boolean} options.isOpen Whether dropdown is currently open.
*
* @return {WPElement} Dropdown toggle element.
* @return {import('@wordpress/element').WPElement} Dropdown toggle element.
*/
renderToggle( { onToggle, isOpen } ) {
const {
Expand All @@ -69,7 +69,7 @@ class Inserter extends Component {
* @param {Function} options.onClose Callback to invoke when dropdown is
* closed.
*
* @return {WPElement} Dropdown content element.
* @return {import('@wordpress/element').WPElement} Dropdown content element.
*/
renderContent( { onClose } ) {
const { rootClientId, clientId, isAppender, showInserterHelpPanel } = this.props;
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/inserter/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Inserter extends Component {
* pressed.
* @param {boolean} options.isOpen Whether dropdown is currently open.
*
* @return {WPElement} Dropdown toggle element.
* @return {import('@wordpress/element').WPElement} Dropdown toggle element.
*/
renderToggle( { onToggle, isOpen } ) {
const {
Expand All @@ -69,7 +69,7 @@ class Inserter extends Component {
* @param {Function} options.onClose Callback to invoke when dropdown is
* closed.
*
* @return {WPElement} Dropdown content element.
* @return {import('@wordpress/element').WPElement} Dropdown content element.
*/
renderContent( { onClose, isOpen } ) {
const { rootClientId, clientId, isAppender } = this.props;
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/media-upload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { withFilters } from '@wordpress/components';
* an integration with the core blocks that handle media files. By default it renders nothing but
* it provides a way to have it overridden with the `editor.MediaUpload` filter.
*
* @return {WPElement} Media upload element.
* @return {import('@wordpress/element').WPComponent} The component to be rendered.
*/
const MediaUpload = () => null;

Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/components/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class BlockEditorProvider extends Component {
* This needs to be done synchronously after state changes (instead of using
* `componentDidUpdate`) in order to avoid batching these changes.
*
* @param {WPDataRegistry} registry Registry from which block editor
* dispatch is to be overriden.
* @param {import('@wordpress/data').WPDataRegistry} registry Registry from which block editor
* dispatch is to be overridden.
*/
attachChangeObserver( registry ) {
if ( this.unsubscribe ) {
Expand Down
8 changes: 4 additions & 4 deletions packages/block-editor/src/components/provider/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { createHigherOrderComponent, compose } from '@wordpress/compose';
* Higher-order component which renders the original component with the current
* registry context passed as its `registry` prop.
*
* @param {WPComponent} OriginalComponent Original component.
* @param {import('@wordpress/element').WPComponent} OriginalComponent Original component.
*
* @return {WPComponent} Enhanced component.
* @return {import('@wordpress/element').WPComponent} Enhanced component.
*/
const withRegistry = createHigherOrderComponent(
( OriginalComponent ) => ( props ) => (
Expand Down Expand Up @@ -75,8 +75,8 @@ class BlockEditorProvider extends Component {
* This needs to be done synchronously after state changes (instead of using
* `componentDidUpdate`) in order to avoid batching these changes.
*
* @param {WPDataRegistry} registry Registry from which block editor
* dispatch is to be overriden.
* @param {import('@wordpress/data').WPDataRegistry} registry Registry from which block editor
* dispatch is to be overridden.
*/
attachChangeObserver( registry ) {
if ( this.unsubscribe ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const HANDLED_SHORTCUTS = [
* shortcuts. Since shortcuts never change, the element can be considered
* static, and can be skipped in reconciliation.
*
* @type {WPElement}
* @type {import('@wordpress/element').WPElement}
*/
const SHORTCUTS_ELEMENT = (
<KeyboardShortcuts
Expand All @@ -40,6 +40,6 @@ const SHORTCUTS_ELEMENT = (
* Component which registered keyboard event handlers to prevent default
* behaviors for key combinations otherwise handled internally by RichText.
*
* @return {WPElement} WordPress element.
* @return {import('@wordpress/element').WPComponent} The component to be rendered.
*/
export const RemoveBrowserShortcuts = () => SHORTCUTS_ELEMENT;
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/typewriter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Typewriter extends Component {
* Maintains the scroll position after a selection change caused by a
* keyboard event.
*
* @param {SyntheticEvent} event Synthetic keyboard event.
* @param {import('@wordpress/element').WPSyntheticEvent} event Synthetic keyboard event.
*/
maintainCaretPosition( { keyCode } ) {
if ( ! this.isSelectionEligibleForScroll() ) {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/hooks/anchor.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ export function addAttribute( settings ) {
* Override the default edit UI to include a new block inspector control for
* assigning the anchor ID, if block supports anchor.
*
* @param {Function|Component} BlockEdit Original component.
* @param {import('@wordpress/element').WPComponent} BlockEdit Original component.
*
* @return {string} Wrapped component.
* @return {import('@wordpress/element').WPComponent} Wrapped component.
*/
export const withInspectorControl = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/block-editor/src/hooks/custom-class-name.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export function addAttribute( settings ) {
* Override the default edit UI to include a new block inspector control for
* assigning the custom class name, if block supports custom class name.
*
* @param {Function|Component} BlockEdit Original component.
* @param {import('@wordpress/element').WPComponent} BlockEdit Original component.
*
* @return {string} Wrapped component.
* @return {import('@wordpress/element').WPComponent} Wrapped component.
*/
export const withInspectorControl = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
Expand Down
24 changes: 13 additions & 11 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ import {
} from '@wordpress/blocks';
import { SVG, Rect, G, Path } from '@wordpress/components';

/**
* A block selection object.
*
* @typedef {Object} WPBlockSelection
*
* @property {string} clientId A block client ID.
* @property {string} attributeKey A block attribute key.
* @property {number} offset A block attribute offset.
*/

// Module constants

/**
Expand Down Expand Up @@ -255,7 +265,7 @@ export const getGlobalBlockCount = createSelector(
* @param {Object} state Editor state.
* @param {string[]} clientIds Client IDs for which blocks are to be returned.
*
* @return {WPBlock[]} Block objects.
* @return {import('@wordpress/blocks').WPBlockType[]} Block objects.
*/
export const getBlocksByClientId = createSelector(
( state, clientIds ) => map(
Expand All @@ -281,14 +291,6 @@ export function getBlockCount( state, rootClientId ) {
return getBlockOrder( state, rootClientId ).length;
}

/**
* @typedef {WPBlockSelection} A block selection object.
*
* @property {string} clientId A block client ID.
* @property {string} attributeKey A block attribute key.
* @property {number} offset A block attribute offset.
*/

/**
* Returns the current selection start block client ID, attribute key and text
* offset.
Expand Down Expand Up @@ -1123,9 +1125,9 @@ const canIncludeBlockTypeInInserter = ( state, blockType, rootClientId ) => {
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {Editor.InserterItem[]} Items that appear in inserter.
* @return {EditorInserterItem[]} Items that appear in inserter.
*
* @typedef {Object} Editor.InserterItem
* @typedef {Object} EditorInserterItem
* @property {string} id Unique identifier for the item.
* @property {string} name The type of block to create.
* @property {Object} initialAttributes Attributes to pass to the newly created block.
Expand Down
38 changes: 19 additions & 19 deletions packages/block-library/src/columns/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export const toWidthPrecision = ( value ) =>
* when the given block is the last block in the set. For the last block, the
* behavior is reversed.
*
* @param {WPBlock[]} blocks Block objects.
* @param {string} clientId Client ID to consider for adjacent blocks.
* @param {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {string} clientId Client ID to consider for adjacent blocks.
*
* @return {WPBlock[]} Adjacent block objects.
* @return {import('@wordpress/blocks').WPBlockType[]} Adjacent block objects.
*/
export function getAdjacentBlocks( blocks, clientId ) {
const index = findIndex( blocks, { clientId } );
Expand All @@ -54,8 +54,8 @@ export function getAdjacentBlocks( blocks, clientId ) {
* Returns an effective width for a given block. An effective width is equal to
* its attribute value if set, or a computed value assuming equal distribution.
*
* @param {WPBlock} block Block object.
* @param {number} totalBlockCount Total number of blocks in Columns.
* @param {import('@wordpress/blocks').WPBlockType} block Block object.
* @param {number} totalBlockCount Total number of blocks in Columns.
*
* @return {number} Effective column width.
*/
Expand All @@ -67,9 +67,9 @@ export function getEffectiveColumnWidth( block, totalBlockCount ) {
/**
* Returns the total width occupied by the given set of column blocks.
*
* @param {WPBlock[]} blocks Block objects.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
* @param {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
*
* @return {number} Total width occupied by blocks.
*/
Expand All @@ -80,9 +80,9 @@ export function getTotalColumnsWidth( blocks, totalBlockCount = blocks.length )
/**
* Returns an object of `clientId` → `width` of effective column widths.
*
* @param {WPBlock[]} blocks Block objects.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
* @param {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
*
* @return {Object<string,number>} Column widths.
*/
Expand All @@ -98,10 +98,10 @@ export function getColumnWidths( blocks, totalBlockCount = blocks.length ) {
* proportional to their current widths, constrained or expanded to fit within
* the given available width.
*
* @param {WPBlock[]} blocks Block objects.
* @param {number} availableWidth Maximum width to fit within.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
* @param {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {number} availableWidth Maximum width to fit within.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
*
* @return {Object<string,number>} Redistributed column widths.
*/
Expand All @@ -120,7 +120,7 @@ export function getRedistributedColumnWidths( blocks, availableWidth, totalBlock
* Returns true if column blocks within the provided set are assigned with
* explicit widths, or false otherwise.
*
* @param {WPBlock[]} blocks Block objects.
* @param {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
*
* @return {boolean} Whether columns have explicit widths.
*/
Expand All @@ -132,10 +132,10 @@ export function hasExplicitColumnWidths( blocks ) {
* Returns a copy of the given set of blocks with new widths assigned from the
* provided object of redistributed column widths.
*
* @param {WPBlock[]} blocks Block objects.
* @param {Object<string,number>} widths Redistributed column widths.
* @param {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {Object<string,number>} widths Redistributed column widths.
*
* @return {WPBlock[]} blocks Mapped block objects.
* @return {import('@wordpress/blocks').WPBlockType[]} blocks Mapped block objects.
*/
export function getMappedColumnWidths( blocks, widths ) {
return blocks.map( ( block ) => merge( {}, block, {
Expand Down
Loading

0 comments on commit 19c2d7f

Please sign in to comment.