Skip to content

Commit

Permalink
Add WordPress type definitions to the list of names recognized by JSD…
Browse files Browse the repository at this point in the history
…oc linter
  • Loading branch information
gziolo committed Oct 23, 2019
1 parent 920ec1d commit 0aeb619
Show file tree
Hide file tree
Showing 88 changed files with 356 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ _Parameters_

_Returns_

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

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

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

_Returns_

- `Array<EditorInserterItem>`: Items that appear in inserter.
- `Array<WPEditorInserterItem>`: 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 @@ -203,7 +203,7 @@ _Parameters_

_Returns_

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

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

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_

- `null`: The component to be rendered.
- `WPComponent`: 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 {import('@wordpress/element').WPComponent} Enhanced component with injected context as props.
* @return {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 {import('@wordpress/element').WPComponent} OriginalComponent Component to wrap.
* @param {WPComponent} OriginalComponent Component to wrap.
*
* @return {import('@wordpress/element').WPComponent} Component which renders only when the BlockEdit is selected.
* @return {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 {import('@wordpress/element').WPComponent} The component to be rendered.
* @return {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 {import('@wordpress/element').WPComponent} The component to be rendered.
* @return {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 {import('@wordpress/element').WPComponent} The component that can be used as a HOC.
* @return {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 {import('@wordpress/element').WPComponent}
* @type {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 {import('@wordpress/element').WPElement} Dropdown toggle element.
* @return {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 {import('@wordpress/element').WPElement} Dropdown content element.
* @return {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 {import('@wordpress/element').WPElement} Dropdown toggle element.
* @return {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 {import('@wordpress/element').WPElement} Dropdown content element.
* @return {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 {import('@wordpress/element').WPComponent} The component to be rendered.
* @return {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 {import('@wordpress/data').WPDataRegistry} registry Registry from which block editor
* dispatch is to be overridden.
* @param {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 {import('@wordpress/element').WPComponent} OriginalComponent Original component.
* @param {WPComponent} OriginalComponent Original component.
*
* @return {import('@wordpress/element').WPComponent} Enhanced component.
* @return {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 {import('@wordpress/data').WPDataRegistry} registry Registry from which block editor
* dispatch is to be overridden.
* @param {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 {import('@wordpress/element').WPElement}
* @type {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 {import('@wordpress/element').WPComponent} The component to be rendered.
* @return {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 {import('@wordpress/element').WPSyntheticEvent} event Synthetic keyboard event.
* @param {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 {import('@wordpress/element').WPComponent} BlockEdit Original component.
* @param {WPComponent} BlockEdit Original component.
*
* @return {import('@wordpress/element').WPComponent} Wrapped component.
* @return {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 {import('@wordpress/element').WPComponent} BlockEdit Original component.
* @param {WPComponent} BlockEdit Original component.
*
* @return {import('@wordpress/element').WPComponent} Wrapped component.
* @return {WPComponent} Wrapped component.
*/
export const withInspectorControl = createHigherOrderComponent( ( BlockEdit ) => {
return ( props ) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/block-editor/src/store/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,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 {import('@wordpress/blocks').WPBlockType[]} Block objects.
* @return {WPBlock[]} Block objects.
*/
export const getBlocksByClientId = createSelector(
( state, clientIds ) => map(
Expand Down Expand Up @@ -1125,9 +1125,9 @@ const canIncludeBlockTypeInInserter = ( state, blockType, rootClientId ) => {
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {EditorInserterItem[]} Items that appear in inserter.
* @return {WPEditorInserterItem[]} Items that appear in inserter.
*
* @typedef {Object} EditorInserterItem
* @typedef {Object} WPEditorInserterItem
* @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 {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {string} clientId Client ID to consider for adjacent blocks.
* @param {WPBlock[]} blocks Block objects.
* @param {string} clientId Client ID to consider for adjacent blocks.
*
* @return {import('@wordpress/blocks').WPBlockType[]} Adjacent block objects.
* @return {WPBlock[]} 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 {import('@wordpress/blocks').WPBlockType} block Block object.
* @param {number} totalBlockCount Total number of blocks in Columns.
* @param {WPBlock} 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 {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
* @param {WPBlock[]} 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 {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {?number} totalBlockCount Total number of blocks in Columns.
* Defaults to number of blocks passed.
* @param {WPBlock[]} 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 {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.
* @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.
*
* @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 {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {WPBlock[]} 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 {import('@wordpress/blocks').WPBlockType[]} blocks Block objects.
* @param {Object<string,number>} widths Redistributed column widths.
* @param {WPBlock[]} blocks Block objects.
* @param {Object<string,number>} widths Redistributed column widths.
*
* @return {import('@wordpress/blocks').WPBlockType[]} blocks Mapped block objects.
* @return {WPBlock[]} blocks Mapped block objects.
*/
export function getMappedColumnWidths( blocks, widths ) {
return blocks.map( ( block ) => merge( {}, block, {
Expand Down
12 changes: 6 additions & 6 deletions packages/blocks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ which means the block is unmodified.

_Parameters_

- _block_ `null`: Block Object
- _block_ `WPBlock`: Block Object

_Returns_

Expand Down Expand Up @@ -561,11 +561,11 @@ in the codebase.

_Parameters_

- _icon_ `null`: Render behavior of a block type icon; one of a Dashicon slug, an element, or a component.
- _icon_ `WPBlockTypeIconRender`: Render behavior of a block type icon; one of a Dashicon slug, an element, or a component.

_Returns_

- `null`: Object describing the icon.
- `WPBlockTypeIconDescriptor`: Object describing the icon.

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

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

_Returns_

- `?WPBlockType`: The block, if it has been successfully registered; otherwise `undefined`.
- `?WPBlock`: The block, if it has been successfully registered; otherwise `undefined`.

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

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

_Returns_

- `?WPBlockType`: The previous block value, if it has been successfully unregistered; otherwise `undefined`.
- `?WPBlock`: The previous block value, if it has been successfully unregistered; otherwise `undefined`.

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

Expand All @@ -768,7 +768,7 @@ wrapped component.

_Returns_

- `null`: Enhanced component with injected BlockContent as prop.
- `WPComponent`: Enhanced component with injected BlockContent as prop.


<!-- END TOKEN(Autogenerated API docs) -->
Expand Down
Loading

0 comments on commit 0aeb619

Please sign in to comment.