Skip to content

Commit 57280d0

Browse files
authored
Merge pull request #4563 from WordPress/update/eslint-jsdoc
JSDoc fixes
2 parents e97b65f + eb954da commit 57280d0

File tree

48 files changed

+659
-613
lines changed

Some content is hidden

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

48 files changed

+659
-613
lines changed

blocks/api/categories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const categories = [
2121
];
2222

2323
/**
24-
* Returns all the block categories
24+
* Returns all the block categories.
2525
*
2626
* @returns {Array} Block categories.
2727
*/

blocks/api/factory.js

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import { getBlockType, getBlockTypes } from './registration';
3030
/**
3131
* Returns a block object given its type and attributes.
3232
*
33-
* @param {String} name Block name
34-
* @param {Object} blockAttributes Block attributes
33+
* @param {string} name Block name.
34+
* @param {Object} blockAttributes Block attributes.
3535
*
3636
* @returns {Object} Block object.
3737
*/
@@ -63,11 +63,12 @@ export function createBlock( name, blockAttributes = {} ) {
6363
}
6464

6565
/**
66-
* Returns a predicate that receives a transformation and returns true if the given
67-
* transformation is able to execute in the situation specified in the params
66+
* Returns a predicate that receives a transformation and returns true if the
67+
* given transformation is able to execute in the situation specified in the
68+
* params.
6869
*
69-
* @param {String} sourceName Block name
70-
* @param {Boolean} isMultiBlock Array of possible block transformations
70+
* @param {string} sourceName Block name.
71+
* @param {boolean} isMultiBlock Array of possible block transformations.
7172
*
7273
* @returns {Function} Predicate that receives a block type.
7374
*/
@@ -78,11 +79,12 @@ const isTransformForBlockSource = ( sourceName, isMultiBlock = false ) => ( tran
7879
);
7980

8081
/**
81-
* Returns a predicate that receives a block type and returns true if the given block type contains a
82-
* transformation able to execute in the situation specified in the params
82+
* Returns a predicate that receives a block type and returns true if the given
83+
* block type contains a transformation able to execute in the situation
84+
* specified in the params.
8385
*
84-
* @param {String} sourceName Block name
85-
* @param {Boolean} isMultiBlock Array of possible block transformations
86+
* @param {string} sourceName Block name.
87+
* @param {boolean} isMultiBlock Array of possible block transformations.
8688
*
8789
* @returns {Function} Predicate that receives a block type.
8890
*/
@@ -94,9 +96,10 @@ const createIsTypeTransformableFrom = ( sourceName, isMultiBlock = false ) => (
9496
);
9597

9698
/**
97-
* Returns an array of possible block transformations that could happen on the set of blocks received as argument.
99+
* Returns an array of possible block transformations that could happen on the
100+
* set of blocks received as argument.
98101
*
99-
* @param {Array} blocks Blocks array
102+
* @param {Array} blocks Blocks array.
100103
*
101104
* @returns {Array} Array of possible block transformations.
102105
*/
@@ -143,8 +146,8 @@ export function getPossibleBlockTransformations( blocks ) {
143146
/**
144147
* Switch one or more blocks into one or more blocks of the new block type.
145148
*
146-
* @param {Array|Object} blocks Blocks array or block object
147-
* @param {string} name Block name
149+
* @param {Array|Object} blocks Blocks array or block object.
150+
* @param {string} name Block name.
148151
*
149152
* @returns {Array} Array of blocks.
150153
*/
@@ -221,8 +224,10 @@ export function switchToBlockType( blocks, name ) {
221224
/**
222225
* Creates a new reusable block.
223226
*
224-
* @param {String} type The type of the block referenced by the reusable block
225-
* @param {Object} attributes The attributes of the block referenced by the reusable block
227+
* @param {string} type The type of the block referenced by the reusable
228+
* block.
229+
* @param {Object} attributes The attributes of the block referenced by the
230+
* reusable block.
226231
*
227232
* @returns {Object} A reusable block object.
228233
*/

blocks/api/parser.js

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ import { getCommentDelimitedContent } from './serializer';
1515
import { attr, prop, html, text, query, node, children } from './matchers';
1616

1717
/**
18-
* Returns value coerced to the specified JSON schema type string
18+
* Returns value coerced to the specified JSON schema type string.
1919
*
2020
* @see http://json-schema.org/latest/json-schema-validation.html#rfc.section.6.25
2121
*
22-
* @param {*} value Original value
23-
* @param {String} type Type to coerce
22+
* @param {*} value Original value.
23+
* @param {string} type Type to coerce.
2424
*
2525
* @returns {*} Coerced value.
2626
*/
@@ -54,11 +54,11 @@ export function asType( value, type ) {
5454
}
5555

5656
/**
57-
* Returns an hpq matcher given a source object
57+
* Returns an hpq matcher given a source object.
5858
*
59-
* @param {Object} sourceConfig Attribute Source object
59+
* @param {Object} sourceConfig Attribute Source object.
6060
*
61-
* @returns {Function} hpq Matcher.
61+
* @returns {Function} A hpq Matcher.
6262
*/
6363
export function matcherFromSource( sourceConfig ) {
6464
switch ( sourceConfig.source ) {
@@ -84,13 +84,14 @@ export function matcherFromSource( sourceConfig ) {
8484
}
8585

8686
/**
87-
* Given an attribute key, an attribute's schema, a block's raw content and the commentAttributes
88-
* returns the attribute value depending on its source definition of the given attribute key
87+
* Given an attribute key, an attribute's schema, a block's raw content and the
88+
* commentAttributes returns the attribute value depending on its source
89+
* definition of the given attribute key.
8990
*
90-
* @param {string} attributeKey Attribute key
91-
* @param {Object} attributeSchema Attribute's schema
92-
* @param {string} innerHTML Block's raw content
93-
* @param {Object} commentAttributes Block's comment attributes
91+
* @param {string} attributeKey Attribute key.
92+
* @param {Object} attributeSchema Attribute's schema.
93+
* @param {string} innerHTML Block's raw content.
94+
* @param {Object} commentAttributes Block's comment attributes.
9495
*
9596
* @returns {*} Attribute value.
9697
*/
@@ -118,9 +119,9 @@ export function getBlockAttribute( attributeKey, attributeSchema, innerHTML, com
118119
/**
119120
* Returns the block attributes of a registered block node given its type.
120121
*
121-
* @param {?Object} blockType Block type
122-
* @param {string} innerHTML Raw block content
123-
* @param {?Object} attributes Known block attributes (from delimiters)
122+
* @param {?Object} blockType Block type.
123+
* @param {string} innerHTML Raw block content.
124+
* @param {?Object} attributes Known block attributes (from delimiters).
124125
*
125126
* @returns {Object} All block attributes.
126127
*/
@@ -133,11 +134,12 @@ export function getBlockAttributes( blockType, innerHTML, attributes ) {
133134
}
134135

135136
/**
136-
* Attempt to parse the innerHTML using using a supplied `deprecated` definition.
137+
* Attempt to parse the innerHTML using using a supplied `deprecated`
138+
* definition.
137139
*
138-
* @param {?Object} blockType Block type
139-
* @param {string} innerHTML Raw block content
140-
* @param {?Object} attributes Known block attributes (from delimiters)
140+
* @param {?Object} blockType Block type.
141+
* @param {string} innerHTML Raw block content.
142+
* @param {?Object} attributes Known block attributes (from delimiters).
141143
*
142144
* @returns {Object} Block attributes.
143145
*/
@@ -162,9 +164,9 @@ export function getAttributesFromDeprecatedVersion( blockType, innerHTML, attrib
162164
/**
163165
* Creates a block with fallback to the unknown type handler.
164166
*
165-
* @param {?String} name Block type name
166-
* @param {String} innerHTML Raw block content
167-
* @param {?Object} attributes Attributes obtained from block delimiters
167+
* @param {?String} name Block type name.
168+
* @param {string} innerHTML Raw block content.
169+
* @param {?Object} attributes Attributes obtained from block delimiters.
168170
*
169171
* @returns {?Object} An initialized block object (if possible).
170172
*/
@@ -232,7 +234,7 @@ export function createBlockWithFallback( name, innerHTML, attributes ) {
232234
/**
233235
* Parses the post content with a PegJS grammar and returns a list of blocks.
234236
*
235-
* @param {String} content The post content
237+
* @param {string} content The post content.
236238
*
237239
* @returns {Array} Block list.
238240
*/

blocks/api/raw-handling/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ import shortcodeConverter from './shortcode-converter';
2828
/**
2929
* Converts an HTML string to known blocks. Strips everything else.
3030
*
31-
* @param {String} options.HTML The HTML to convert.
32-
* @param {String} [options.plainText] Plain text version.
33-
* @param {String} [options.mode] Handle content as blocks or inline content.
34-
* * 'AUTO': Decide based on the content passed.
35-
* * 'INLINE': Always handle as inline content, and return string.
36-
* * 'BLOCKS': Always handle as blocks, and return array of blocks.
37-
* @param {Array} [options.tagName] The tag into which content will be inserted.
31+
* @param {string} [options.HTML] The HTML to convert.
32+
* @param {string} [options.plainText] Plain text version.
33+
* @param {string} [options.mode] Handle content as blocks or inline content.
34+
* * 'AUTO': Decide based on the content passed.
35+
* * 'INLINE': Always handle as inline content, and return string.
36+
* * 'BLOCKS': Always handle as blocks, and return array of blocks.
37+
* @param {Array} [options.tagName] The tag into which content will be
38+
* inserted.
3839
*
3940
* @returns {Array|String} A list of blocks or a string, depending on `handlerMode`.
4041
*/

blocks/api/raw-handling/utils.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export function isAttributeWhitelisted( tag, attribute ) {
8282
* Checks if nodeName should be treated as inline when being added to tagName.
8383
* This happens if nodeName and tagName are in the same group defined in inlineWhitelistTagGroups.
8484
*
85-
* @param {String} nodeName Node name.
86-
* @param {String} tagName Tag name.
85+
* @param {string} nodeName Node name.
86+
* @param {string} tagName Tag name.
8787
*
88-
* @returns {Boolean} True if nodeName is inline in the context of tagName and
88+
* @returns {boolean} True if nodeName is inline in the context of tagName and
8989
* false otherwise.
9090
*/
9191
function isInlineForTag( nodeName, tagName ) {
@@ -197,9 +197,9 @@ export function isPlain( HTML ) {
197197
/**
198198
* Given node filters, deeply filters and mutates a NodeList.
199199
*
200-
* @param {NodeList} nodeList The nodeList to filter.
201-
* @param {Array} filters An array of functions that can mutate with the provided node.
202-
* @param {Document} doc The document of the nodeList.
200+
* @param {NodeList} nodeList The nodeList to filter.
201+
* @param {Array} filters An array of functions that can mutate with the provided node.
202+
* @param {Document} doc The document of the nodeList.
203203
*/
204204
export function deepFilterNodeList( nodeList, filters, doc ) {
205205
Array.from( nodeList ).forEach( ( node ) => {
@@ -219,10 +219,10 @@ export function deepFilterNodeList( nodeList, filters, doc ) {
219219
/**
220220
* Given node filters, deeply filters HTML tags.
221221
*
222-
* @param {String} HTML The HTML to filter.
223-
* @param {Array} filters An array of functions that can mutate with the provided node.
222+
* @param {string} HTML The HTML to filter.
223+
* @param {Array} filters An array of functions that can mutate with the provided node.
224224
*
225-
* @returns {String} The filtered HTML.
225+
* @returns {string} The filtered HTML.
226226
*/
227227
export function deepFilterHTML( HTML, filters = [] ) {
228228
const doc = document.implementation.createHTMLDocument( '' );

blocks/api/registration.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ let defaultBlockName;
4343
* behavior. Once registered, the block is made available as an option to any
4444
* editor interface where blocks are implemented.
4545
*
46-
* @param {string} name Block name
47-
* @param {Object} settings Block settings
46+
* @param {string} name Block name.
47+
* @param {Object} settings Block settings.
4848
*
4949
* @returns {?WPBlock} The block, if it has been successfully registered;
5050
* otherwise `undefined`.
@@ -128,7 +128,7 @@ export function registerBlockType( name, settings ) {
128128
/**
129129
* Unregisters a block.
130130
*
131-
* @param {string} name Block name
131+
* @param {string} name Block name.
132132
*
133133
* @returns {?WPBlock} The previous block value, if it has been successfully
134134
* unregistered; otherwise `undefined`.
@@ -148,7 +148,7 @@ export function unregisterBlockType( name ) {
148148
/**
149149
* Assigns name of block handling unknown block types.
150150
*
151-
* @param {string} name Block name
151+
* @param {string} name Block name.
152152
*/
153153
export function setUnknownTypeHandlerName( name ) {
154154
unknownTypeHandlerName = name;
@@ -165,16 +165,16 @@ export function getUnknownTypeHandlerName() {
165165
}
166166

167167
/**
168-
* Assigns the default block name
168+
* Assigns the default block name.
169169
*
170-
* @param {string} name Block name
170+
* @param {string} name Block name.
171171
*/
172172
export function setDefaultBlockName( name ) {
173173
defaultBlockName = name;
174174
}
175175

176176
/**
177-
* Retrieves the default block name
177+
* Retrieves the default block name.
178178
*
179179
* @returns {?string} Blog name.
180180
*/
@@ -185,7 +185,7 @@ export function getDefaultBlockName() {
185185
/**
186186
* Returns a registered block type.
187187
*
188-
* @param {string} name Block name
188+
* @param {string} name Block name.
189189
*
190190
* @returns {?Object} Block type.
191191
*/
@@ -203,14 +203,14 @@ export function getBlockTypes() {
203203
}
204204

205205
/**
206-
* Returns true if the block defines support for a feature, or false otherwise
206+
* Returns true if the block defines support for a feature, or false otherwise.
207207
*
208-
* @param {(String|Object)} nameOrType Block name or type object
209-
* @param {String} feature Feature to test
210-
* @param {Boolean} defaultSupports Whether feature is supported by
211-
* default if not explicitly defined
208+
* @param {(string|Object)} nameOrType Block name or type object.
209+
* @param {string} feature Feature to test.
210+
* @param {boolean} defaultSupports Whether feature is supported by
211+
* default if not explicitly defined.
212212
*
213-
* @returns {Boolean} Whether block supports feature.
213+
* @returns {boolean} Whether block supports feature.
214214
*/
215215
export function hasBlockSupport( nameOrType, feature, defaultSupports ) {
216216
const blockType = 'string' === typeof nameOrType ?
@@ -225,12 +225,12 @@ export function hasBlockSupport( nameOrType, feature, defaultSupports ) {
225225

226226
/**
227227
* Determines whether or not the given block is a reusable block. This is a
228-
* special block type that is used to point to a global block stored via the
229-
* API.
228+
* special block type that is used to point to a global block stored via
229+
* the API.
230230
*
231-
* @param {Object} blockOrType Block or Block Type to test
231+
* @param {Object} blockOrType Block or Block Type to test.
232232
*
233-
* @returns {Boolean} Whether the given block is a reusable block.
233+
* @returns {boolean} Whether the given block is a reusable block.
234234
*/
235235
export function isReusableBlock( blockOrType ) {
236236
return blockOrType.name === 'core/block';

0 commit comments

Comments
 (0)