Make WordPress Core

Changeset 63766


Ignore:
Timestamp:
09/21/2026 06:34:17 AM (8 weeks ago)
Author:
afercia
Message:

General: Enable the JSDoc rule valid-types.

Enables the JSDoc rule valid-types and fixes all the reported violations.
Part of the effort to improve JS inline documentation for 7.2.

Developed in ​https://github.com/WordPress/wordpress-develop/pull/13486

See #66033.

Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/.eslintrc-jsdoc.js

    r63600 r63766  
    7676                        'jsdoc/require-returns-description': 'error',
    7777                        'jsdoc/require-returns-type': 'error',
     78                        'jsdoc/valid-types': 'error',
    7879                },
    7980        },
  • trunk/src/js/_enqueues/admin/comment.js

    r63406 r63766  
    2525         * Adds event that opens the time stamp form if the form is hidden.
    2626         *
    27          * @listens $edittimestamp:click
    28          *
    2927         * @param {Event} event The event object.
    3028         * @return {void}
    … …  
    4341        /**
    4442         * Resets the time stamp values when the cancel button is clicked.
    45          *
    46          * @listens .cancel-timestamp:click
    4743         *
    4844         * @param {Event} event The event object.
    … …  
    6561        /**
    6662         * Sets the time stamp values when the ok button is clicked.
    67          *
    68          * @listens .save-timestamp:click
    6963         *
    7064         * @param {Event} event The event object.
    … …  
    111105         * @since 7.1.0
    112106         *
    113          * @listens $editcommentparent:click
    114          *
    115107         * @param {Event} event The event object.
    116108         * @return {void}
    … …  
    132124         * @since 7.1.0
    133125         *
    134          * @listens .cancel-comment-parent:click
    135          *
    136126         * @param {Event} event The event object.
    137127         * @return {void}
    … …  
    150140         *
    151141         * @since 7.1.0
    152          *
    153          * @listens .save-comment-parent:click
    154142         *
    155143         * @param {Event} event The event object.
  • trunk/src/js/_enqueues/admin/inline-edit-tax.js

    r63600 r63766  
    3030         * @since 2.7.0
    3131         *
    32          * @this inlineEditTax
     32         * @this {inlineEditTax}
    3333         * @memberof inlineEditTax
    3434         * @return {void}
    … …  
    9494         * @since 2.7.0
    9595         *
    96          * @this inlineEditTax
     96         * @this {inlineEditTax}
    9797         * @memberof inlineEditTax
    9898         *
    … …  
    112112         * @since 2.7.0
    113113         *
    114          * @this inlineEditTax
     114         * @this {inlineEditTax}
    115115         * @memberof inlineEditTax
    116116         *
    … …  
    159159         * @since 2.7.0
    160160         *
    161          * @this inlineEditTax
     161         * @this {inlineEditTax}
    162162         * @memberof inlineEditTax
    163163         *
    … …  
    256256         * @since 2.7.0
    257257         *
    258          * @this inlineEditTax
     258         * @this {inlineEditTax}
    259259         * @memberof inlineEditTax
    260260         * @return {void}
  • trunk/src/js/_enqueues/admin/user-profile.js

    r63556 r63766  
    187187         * Helper function to insert an inline notice of success or failure.
    188188         *
    189          * @param {jQuery Object} $this   The button element: the message will be inserted
    190          *                                above this button
    191          * @param {boolean}       success Whether the message is a success message.
    192          * @param {string}        message The message to insert.
     189         * @param {jQuery} $this   The button element: the message will be inserted
     190         *                          above this button
     191         * @param {boolean} success Whether the message is a success message.
     192         * @param {string}  message The message to insert.
    193193         */
    194194        function addInlineNotice( $this, success, message ) {
  • trunk/src/js/_enqueues/lib/lists.js

    r63600 r63766  
    813813 * Initializes wpList object.
    814814 *
    815  * @param {Object}           settings             The settings for the wpList instance.
    816  * @param {string}           settings.url         URL for ajax calls. Default: ajaxurl.
    817  * @param {string}           settings.type        The HTTP method to use for Ajax requests. Default: 'POST'.
    818  * @param {string}           settings.response    ID of the element the parsed ajax response will be stored in.
    819  *                                                Default: 'ajax-response'.
     815 * @param {Object}   settings             The settings for the wpList instance.
     816 * @param {string}   settings.url         URL for ajax calls. Default: ajaxurl.
     817 * @param {string}   settings.type        The HTTP method to use for Ajax requests. Default: 'POST'.
     818 * @param {string}   settings.response    ID of the element the parsed ajax response will be stored in.
     819 *                                        Default: 'ajax-response'.
    820820 *
    821  * @param {string}           settings.what        Default: ''.
    822  * @param {string}           settings.alt         CSS class name for alternate styling. Default: 'alternate'.
    823  * @param {number}           settings.altOffset   Offset to start alternate styling from. Default: 0.
    824  * @param {string}           settings.addColor    Hex code or 'none' to disable animation. Default: '#ffff33'.
    825  * @param {string}           settings.delColor    Hex code or 'none' to disable animation. Default: '#faafaa'.
    826  * @param {string}           settings.dimAddColor Hex code or 'none' to disable animation. Default: '#ffff33'.
    827  * @param {string}           settings.dimDelColor Hex code or 'none' to disable animation. Default: '#ff3333'.
     821 * @param {string}   settings.what        Default: ''.
     822 * @param {string}   settings.alt         CSS class name for alternate styling. Default: 'alternate'.
     823 * @param {number}   settings.altOffset   Offset to start alternate styling from. Default: 0.
     824 * @param {string}   settings.addColor    Hex code or 'none' to disable animation. Default: '#ffff33'.
     825 * @param {string}   settings.delColor    Hex code or 'none' to disable animation. Default: '#faafaa'.
     826 * @param {string}   settings.dimAddColor Hex code or 'none' to disable animation. Default: '#ffff33'.
     827 * @param {string}   settings.dimDelColor Hex code or 'none' to disable animation. Default: '#ff3333'.
    828828 *
    829  * @param {wpList~confirm}  settings.confirm     Callback that's run before a request is made. Default: null.
    830  * @param {wpList~addBefore} settings.addBefore   Callback that's run before an item gets added to the list.
    831  *                                                Default: null.
    832  * @param {wpList~addAfter} settings.addAfter    Callback that's run after an item got added to the list.
    833  *                                                Default: null.
    834  * @param {wpList~delBefore} settings.delBefore   Callback that's run before an item gets deleted from the list.
    835  *                                                Default: null.
    836  * @param {wpList~delAfter} settings.delAfter    Callback that's run after an item got deleted from the list.
    837  *                                                Default: null.
    838  * @param {wpList~dimBefore} settings.dimBefore   Callback that's run before an item gets dim'd. Default: null.
    839  * @param {wpList~dimAfter} settings.dimAfter    Callback that's run after an item got dim'd. Default: null.
     829 * @param {Function} settings.confirm     Callback that's run before a request is made. Default: null.
     830 * @param {Function} settings.addBefore   Callback that's run before an item gets added to the list.
     831 *                                        Default: null.
     832 * @param {Function} settings.addAfter    Callback that's run after an item got added to the list.
     833 *                                        Default: null.
     834 * @param {Function} settings.delBefore   Callback that's run before an item gets deleted from the list.
     835 *                                        Default: null.
     836 * @param {Function} settings.delAfter    Callback that's run after an item got deleted from the list.
     837 *                                        Default: null.
     838 * @param {Function} settings.dimBefore   Callback that's run before an item gets dim'd. Default: null.
     839 * @param {Function} settings.dimAfter    Callback that's run after an item got dim'd. Default: null.
    840840 * @return {$.fn} wpList API function.
    841841 */
  • trunk/src/js/_enqueues/wp/api.js

    r63600 r63766  
    6161         *
    6262         * @param {string} route The API route.
    63          * @return {Backbone Model} The model found at given route. Undefined if not found.
     63         * @return {Backbone.Model|undefined} The model found at given route. Undefined if not found.
    6464         */
    6565        wp.api.getModelByRoute = function( route ) {
    … …  
    7373         *
    7474         * @param {string} route The API route.
    75          * @return {Backbone Model} The collection found at given route. Undefined if not found.
     75         * @return {Backbone.Collection|undefined} The collection found at given route. Undefined if not found.
    7676         */
    7777        wp.api.getCollectionByRoute = function( route ) {
    … …  
    312312         * Add mixins and helpers to models depending on their defaults.
    313313         *
    314          * @param {Backbone Model} model          The model to attach helpers and mixins to.
     314         * @param {Backbone.Model} model          The model to attach helpers and mixins to.
    315315         * @param {string}         modelClassName The classname of the constructed model.
    316316         * @param {Object}         loadingObjects An object containing the models and collections we are building.
    … …  
    869869                         * Set nonce header before every Backbone sync.
    870870                         *
    871                          * @param {string}          method  The CRUD method ("create", "read", "update", or "delete") to be performed.
    872                          * @param {Backbone.Model}  model   The model to be synced.
    873                          * @param {{beforeSend}, *} options Additional options for the sync.
     871                         * @param {string}         method  The CRUD method ("create", "read", "update", or "delete") to be performed.
     872                         * @param {Backbone.Model} model   The model to be synced.
     873                         * @param {Object}        options Additional options for the sync.
    874874                         * @return {*}.
    875875                         */
    … …  
    10341034                         * @param {string}         method  The CRUD method ("create", "read", "update", or "delete") to be performed.
    10351035                         * @param {Backbone.Model} model   The model to be synced.
    1036                          * @param {{success}, *}   options Additional options for the sync.
     1036                         * @param {Object}         options Additional options for the sync.
    10371037                         * @return {*}.
    10381038                         */
    … …  
    11091109                         * Fetches the next page of objects if a new page exists.
    11101110                         *
    1111                          * @param {data: {page}} options An object containing the page number to fetch. If not provided, the next page will be fetched.
    1112                          * @return {*}.
     1111                         * @param {Object} [options]           An object containing the page number to fetch. If not provided, the next page will be fetched.
     1112                         * @param {number} [options.data.page] The page number to fetch.
     1113                         * @return {JQuery.Promise} A promise that resolves when the fetch operation completes.
    11131114                         */
    11141115                        more: function( options ) {
  • trunk/src/js/_enqueues/wp/media/editor.js

    r63600 r63766  
    491491                         *                         shortcode markup matching the passed tag name,
    492492                         *
    493                          * @this wp.media.{prop}
     493                         * @this {wp.media.view.MediaFrame.Select}
    494494                         *
    495495                         * @return {void|wp.media.view.MediaFrame.Select} A media workflow.
    … …  
    650650                 * The Featured Image workflow
    651651                 *
    652                  * @this wp.media.featuredImage
     652                 * @this {wp.media.featuredImage}
    653653                 *
    654654                 * @return {wp.media.view.MediaFrame.Select} A media workflow.
    … …  
    667667                        this._frame.on( 'toolbar:create:featured-image', function( toolbar ) {
    668668                                /**
    669                                  * @this wp.media.view.MediaFrame.Select
     669                                 * @this {wp.media.view.MediaFrame.Select}
    670670                                 */
    671671                                this.createSelectToolbar( toolbar, {
    … …  
    692692                 * the 'Set Featured Image' button is clicked in the media modal.
    693693                 *
    694                  * @this wp.media.controller.FeaturedImage
     694                 * @this {wp.media.controller.FeaturedImage}
    695695                 */
    696696                select: function() {
    … …  
    790790                 * @param {Object} [options={}] The options for the media workflow.
    791791                 *
    792                  * @this wp.media.editor
     792                 * @this {wp.media.editor}
    793793                 *
    794794                 * @return {wp.media.view.MediaFrame.Select} A media workflow.
    … …  
    821821                                        var display = state.display( attachment ).toJSON();
    822822                                        /**
    823                                          * @this wp.media.editor
     823                                         * @this {wp.media.editor}
    824824                                         */
    825825                                        return this.send.attachment( display, attachment.toJSON() );
    … …  
    831831                        workflow.state('gallery-edit').on( 'update', function( selection ) {
    832832                                /**
    833                                  * @this wp.media.editor
     833                                 * @this {wp.media.editor}
    834834                                 */
    835835                                this.insert( wp.media.gallery.shortcode( selection ).string() );
    … …  
    838838                        workflow.state('playlist-edit').on( 'update', function( selection ) {
    839839                                /**
    840                                  * @this wp.media.editor
     840                                 * @this {wp.media.editor}
    841841                                 */
    842842                                this.insert( wp.media.playlist.shortcode( selection ).string() );
    … …  
    845845                        workflow.state('video-playlist-edit').on( 'update', function( selection ) {
    846846                                /**
    847                                  * @this wp.media.editor
     847                                 * @this {wp.media.editor}
    848848                                 */
    849849                                this.insert( wp.media.playlist.shortcode( selection ).string() );
    … …  
    852852                        workflow.state('embed').on( 'select', function() {
    853853                                /**
    854                                  * @this wp.media.editor
     854                                 * @this {wp.media.editor}
    855855                                 */
    856856                                var state = workflow.state(),
    … …  
    921921                 * @param {string} id A slug used to identify the workflow.
    922922                 *
    923                  * @this wp.media.editor
     923                 * @this {wp.media.editor}
    924924                 *
    925925                 * @return {wp.media.view.MediaFrame} A media workflow.
    … …  
    934934                 * @param {string} id A slug used to identify the workflow.
    935935                 *
    936                  * @this wp.media.editor
     936                 * @this {wp.media.editor}
    937937                 */
    938938                remove: function( id ) {
    … …  
    10211021                 * @param {Object} [options={}]   The options for the media workflow.
    10221022                 *
    1023                  * @this wp.media.editor
     1023                 * @this {wp.media.editor}
    10241024                 *
    10251025                 * @return {wp.media.view.MediaFrame} A media workflow.
  • trunk/src/js/_enqueues/wp/theme.js

    r63658 r63766  
    276276         */
    277277        query: function( request ) {
    278                 /**
    279                  * @static
    280                  * @type Array
    281                  */
    282278                var queries = this.queries,
    283279                        self = this,
  • trunk/src/js/_enqueues/wp/widgets/media.js

    r63600 r63766  
    376376                                 * @ignore
    377377                                 *
    378                                  * @fires wp.media.controller.State#insert()
     378                                 * @fires wp.media.controller.State#insert
    379379                                 * @return {void}
    380380                                 */
  • trunk/src/js/media/models/attachment.js

    r63600 r63766  
    119119         * @param {Object} options Sync options. e.g. patch, wait, success, error.
    120120         *
    121          * @this Backbone.Model
     121         * @this {Backbone.Model}
    122122         *
    123123         * @return {jQuery.Promise} A jQuery Promise that is resolved or rejected based on the success of the sync operation.
  • trunk/src/js/media/models/attachments.js

    r63600 r63766  
    545545                 * @param {wp.media.model.Attachment} attachment The attachment to filter based on the search query.
    546546                 *
    547                  * @this wp.media.model.Attachments
     547                 * @this {wp.media.model.Attachments}
    548548                 *
    549549                 * @return {boolean} True if the attachment matches the search filter, false otherwise.
    … …  
    565565                 * @param {wp.media.model.Attachment} attachment The attachment to filter based on its type.
    566566                 *
    567                  * @this wp.media.model.Attachments
     567                 * @this {wp.media.model.Attachments}
    568568                 *
    569569                 * @return {boolean} True if the attachment matches the type filter, false otherwise.
    … …  
    594594                 * @param {wp.media.model.Attachment} attachment The attachment to filter based on its uploadedTo property.
    595595                 *
    596                  * @this wp.media.model.Attachments
     596                 * @this {wp.media.model.Attachments}
    597597                 *
    598598                 * @return {boolean} True if the attachment matches the uploadedTo filter, false otherwise.
    … …  
    612612                 * @param {wp.media.model.Attachment} attachment The attachment to filter based on its status property.
    613613                 *
    614                  * @this wp.media.model.Attachments
     614                 * @this {wp.media.model.Attachments}
    615615                 *
    616616                 * @return {boolean} True if the attachment matches the status filter, false otherwise.
  • trunk/src/js/media/models/query.js

    r63600 r63766  
    232232         */
    233233        get: (function(){
    234                 /**
    235                  * @static
    236                  * @type Array
    237                  */
    238234                var queries = [];
    239235
  • trunk/src/js/media/models/selection.js

    r63598 r63766  
    5353         * Fired when toggling (clicking on) an attachment in the modal.
    5454         *
     55         * Fires `selection:single` and `selection:unsingle` events on the model and collection.
     56         *
    5557         * @param {undefined|boolean|wp.media.model.Attachment} model The model to set as the single selection, or a boolean to clear it.
    56          *
    57          * @fires wp.media.model.Selection#selection:single
    58          * @fires wp.media.model.Selection#selection:unsingle
    59          *
    6058         * @return {Backbone.Model} The single model in the selection, or the last model as a fallback.
    6159         */
  • trunk/src/js/media/views/attachment/details.js

    r63409 r63766  
    247247         * This event can be used to make sure to move the focus correctly.
    248248         *
     249         * Fires `attachment:details:shift-tab` and `attachment:keydown:arrow` events on the controller.
     250         *
    249251         * @since 4.0.0
    250          *
    251          * @fires wp.media.controller.MediaLibrary#attachment:details:shift-tab
    252          * @fires wp.media.controller.MediaLibrary#attachment:keydown:arrow
    253252         *
    254253         * @param {KeyboardEvent} event A keyboard event.
  • trunk/src/js/media/views/attachments.js

    r63612 r63766  
    1919         * adding or removing attachments or resetting the entire collection.
    2020         *
     21         * Listens for `collection:add`, `collection:remove`, `collection:reset`,
     22         * `controller:library:selection:add`, `scrollElement:scroll`, `this:ready`,
     23         * and `controller:open` events.
     24         *
    2125         * @since 3.5.0
    2226         *
    … …  
    2529         *
    2630         * @augments wp.media.View
    27          *
    28          * @listens collection:add
    29          * @listens collection:remove
    30          * @listens collection:reset
    31          * @listens controller:library:selection:add
    32          * @listens scrollElement:scroll
    33          * @listens this:ready
    34          * @listens controller:open
    3531         */
    3632        initialize: function() {
    … …  
    122118         * handlers to prevent duplicate listeners.
    123119         *
     120         * Listens for the `window:resize` event.
     121         *
    124122         * @since 4.0.0
    125          *
    126          * @listens window:resize
    127123         *
    128124         * @return {void}
    … …  
    270266         * in the options.
    271267         *
    272          * @since 3.5.0
    273          *
    274          * @fires collection:reset
     268         * Fires `collection:reset`.
     269         *
     270         * @since 3.5.0
    275271         *
    276272         * @return {void}
  • trunk/src/js/media/views/frame.js

    r63598 r63766  
    145145                this.activeModes.remove( this.activeModes.where( { id: mode } ) );
    146146                this.$el.removeClass( 'mode-' + mode );
    147                 /**
    148                  * Frame mode deactivation event.
    149                  *
    150                  * @event wp.media.view.Frame#{mode}:deactivate
    151                  */
     147
     148                // Fires a `#{mode}:deactivate` event on the frame.
    152149                this.trigger( mode + ':deactivate' );
    153150
  • trunk/src/js/media/views/frame/manage.js

    r63516 r63766  
    252252         * @param {Object} contentRegion Basic object with a `view` property, which
    253253         *                               should be set with the proper region view.
    254          * @this wp.media.controller.Region
     254         * @this {wp.media.controller.Region}
    255255         */
    256256        browseContent: function( contentRegion ) {
  • trunk/src/js/media/views/frame/select.js

    r63598 r63766  
    170170         * @param {Object} toolbar      The toolbar object for the `select` mode.
    171171         * @param {Object} [options={}] The options for creating the select toolbar view.
    172          * @this wp.media.controller.Region
     172         * @this {wp.media.controller.Region}
    173173         */
    174174        createSelectToolbar: function( toolbar, options ) {
  • trunk/src/js/media/views/media-details.js

    r63598 r63766  
    6060         * Removes a setting's UI when the model unsets it
    6161         *
    62          * @fires wp.media.view.MediaDetails#media:setting:remove
     62         * Fires `wp.media.view.MediaDetails#media:setting:remove` when a setting is removed.
    6363         *
    6464         * @param {JQuery.Event} e The jQuery event object.
    … …  
    7979         * Sets the tracks for the media details view.
    8080         *
    81          * @fires wp.media.view.MediaDetails#media:setting:remove
     81         * Fires `wp.media.view.MediaDetails#media:setting:remove` when the tracks are updated.
    8282         */
    8383        setTracks : function() {
  • trunk/src/js/media/views/media-frame.js

    r63612 r63766  
    162162         *
    163163         * @param {Object} title The title object for creating the title view.
    164          * @this wp.media.controller.Region
     164         * @this {wp.media.controller.Region}
    165165         */
    166166        createTitle: function( title ) {
    … …  
    176176         *
    177177         * @param {Object} menu The menu object for creating the menu view.
    178          * @this wp.media.controller.Region
     178         * @this {wp.media.controller.Region}
    179179         */
    180180        createMenu: function( menu ) {
    … …  
    207207         *
    208208         * @param {Object} toolbar The toolbar object for creating the toolbar view.
    209          * @this wp.media.controller.Region
     209         * @this {wp.media.controller.Region}
    210210         */
    211211        createToolbar: function( toolbar ) {
    … …  
    218218         *
    219219         * @param {Object} router The router object for creating the router view.
    220          * @this wp.media.controller.Region
     220         * @this {wp.media.controller.Region}
    221221         */
    222222        createRouter: function( router ) {
    … …  
    275275         *
    276276         * @param {Object} content The content object for creating the iframe content view.
    277          * @this wp.media.controller.Region
     277         * @this {wp.media.controller.Region}
    278278         */
    279279        iframeContent: function( content ) {
Note: See TracChangeset for help on using the changeset viewer.