build: Enable jscs jsDoc rule 'checkTypes' and make pass
authorJames D. Forrester <jforrester@wikimedia.org>
Sat, 5 Sep 2015 19:47:33 +0000 (12:47 -0700)
committerJames D. Forrester <jforrester@wikimedia.org>
Thu, 1 Oct 2015 22:28:06 +0000 (15:28 -0700)
Change-Id: I64c3b5bd7afc4686355c80ef68009d978f7b3097

19 files changed:
.jscsrc
resources/src/jquery/jquery.autoEllipsis.js
resources/src/jquery/jquery.expandableField.js
resources/src/jquery/jquery.qunit.completenessTest.js
resources/src/jquery/jquery.tablesorter.js
resources/src/mediawiki.special/mediawiki.special.preferences.js
resources/src/mediawiki.toolbar/toolbar.js
resources/src/mediawiki/api/edit.js
resources/src/mediawiki/mediawiki.experiments.js
resources/src/mediawiki/mediawiki.inspect.js
resources/src/mediawiki/mediawiki.jqueryMsg.js
resources/src/mediawiki/mediawiki.js
resources/src/mediawiki/mediawiki.log.js
resources/src/mediawiki/mediawiki.storage.js
resources/src/mediawiki/mediawiki.template.js
tests/qunit/data/testrunner.js
tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js
tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
tests/qunit/suites/resources/jquery/jquery.textSelection.test.js

diff --git a/.jscsrc b/.jscsrc
index 7226091..c1fbc9a 100644 (file)
--- a/.jscsrc
+++ b/.jscsrc
@@ -9,6 +9,7 @@
        "jsDoc": {
                "checkParamNames": true,
                "checkRedundantReturns": true,
+               "checkTypes": "strictNativeCase",
                "requireNewlineAfterDescription": true,
                "requireParamTypes": true,
                "requireReturnTypes": true
index e1115d6..fd7e8d1 100644 (file)
@@ -10,11 +10,13 @@ var
        // Use a separate cache when match highlighting is enabled
        matchTextCache = {};
 
+// Due to <https://github.com/jscs-dev/jscs-jsdoc/issues/136>
+// jscs:disable jsDoc
 /**
  * Automatically truncate the plain text contents of an element and add an ellipsis
  *
  * @param {Object} options
- * @param {'center'|'left'|'right'} [options.position='center'] Where to remove text.
+ * @param {'left'|'center'|'right'} [options.position='center'] Where to remove text.
  * @param {boolean} [options.tooltip=false] Whether to show a tooltip with the remainder
  * of the text.
  * @param {boolean} [options.restoreText=false] Whether to save the text for restoring
@@ -159,6 +161,7 @@ $.fn.autoEllipsis = function ( options ) {
 
        } );
 };
+// jscs:enable jsDoc
 
 /**
  * @class jQuery
index 4f67b87..f9db72f 100644 (file)
@@ -41,7 +41,7 @@
                 * Sets the value of a property, and updates the widget accordingly
                 *
                 * @param {Object} context
-                * @param {String} property Name of property
+                * @param {string} property Name of property
                 * @param {Mixed} value Value to set property with
                 */
                configure: function ( context, property, value ) {
index 25cc057..8d263fb 100644 (file)
                 * Depending on the action it either injects our listener into the methods, or
                 * reads from our tracker and records which methods have not been called by the test suite.
                 *
-                * @param {mixed} currObj The variable to check (initially an object,
+                * @param {Mixed} currObj The variable to check (initially an object,
                 *  further down it could be anything).
-                * @param {String|Null} currName Name of the given object member (Initially this is null).
+                * @param {string|null} currName Name of the given object member (Initially this is null).
                 * @param {Object} masterVariable Throughout our interation, always keep track of the master/root.
                 *  Initially this is the same as currVar.
                 * @param {Array} parentPathArray Array of names that indicate our breadcrumb path starting at
                 * was called during the test suite (as far as the tracker knows).
                 * If not it adds it to missingTests.
                 *
-                * @param {String} fnName
-                * @return {Boolean}
+                * @param {string} fnName
+                * @return {boolean}
                 */
                hasTest: function ( fnName ) {
                        if ( !( fnName in this.methodCallTracker ) ) {
index f6857e8..0eefae6 100644 (file)
         * in default (ascending) order when their header cell is clicked the next time.
         *
         * @param {jQuery} $headers
-        * @param {Number[][]} sortList
-        * @param {Number[][]} headerToColumns
+        * @param {number[][]} sortList
+        * @param {number[][]} headerToColumns
         */
        function setHeadersOrder( $headers, sortList, headerToColumns ) {
                // Loop through all headers to retrieve the indices of the columns the header spans across:
index bad1c08..9b790e0 100644 (file)
@@ -51,8 +51,8 @@ jQuery( function ( $ ) {
         * It uses document.getElementById for security reasons (HTML injections in $()).
         *
         * @ignore
-        * @param {String} name the name of a tab without the prefix ("mw-prefsection-")
-        * @param {String} [mode] A hash will be set according to the current
+        * @param {string} name the name of a tab without the prefix ("mw-prefsection-")
+        * @param {string} [mode] A hash will be set according to the current
         *  open section. Set mode 'noHash' to surpress this.
         */
        function switchPrefTab( name, mode ) {
index 0469cc5..bb26c0f 100644 (file)
                 *     addButtons( [ { .. }, { .. }, { .. } ] );
                 *     addButtons( { .. }, { .. } );
                 *
-                * @param {Object|Array...} [buttons] An array of button objects or the first
+                * @param {...Object|Array} [buttons] An array of button objects or the first
                 *  button object in a list of variadic arguments.
                 */
                addButtons: function ( buttons ) {
index e43285f..22affb1 100644 (file)
@@ -33,7 +33,7 @@
                 * Post a new section to the page.
                 *
                 * @see #postWithEditToken
-                * @param {mw.Title|String} title Target page
+                * @param {mw.Title|string} title Target page
                 * @param {string} header
                 * @param {string} message wikitext message
                 * @param {Object} [additionalParams] Additional API parameters, e.g. `{ redirect: true }`
index 75b1f80..b62e8d1 100644 (file)
@@ -9,8 +9,8 @@
         *
         * @see http://en.wikipedia.org/wiki/Jenkins_hash_function
         *
-        * @param {String} string String to hash
-        * @return {Number} The hash as a 32-bit unsigned integer
+        * @param {string} string String to hash
+        * @return {number} The hash as a 32-bit unsigned integer
         * @ignore
         *
         * @author Ori Livneh <ori@wikimedia.org>
                 * This function is based on the deprecated `mw.user.bucket` function.
                 *
                 * @param {Object} experiment
-                * @param {String} experiment.name The name of the experiment
-                * @param {Boolean} experiment.enabled Whether or not the experiment is
+                * @param {string} experiment.name The name of the experiment
+                * @param {boolean} experiment.enabled Whether or not the experiment is
                 *  enabled. If the experiment is disabled, then the user is always assigned
                 *  to the control bucket
                 * @param {Object} experiment.buckets A map of bucket name to probability
                 *  that the user will be assigned to that bucket
-                * @param {String} token A token that uniquely identifies the user for the
+                * @param {string} token A token that uniquely identifies the user for the
                 *  duration of the experiment
-                * @returns {String} The bucket
+                * @returns {string} The bucket
                 */
                getBucket: function ( experiment, token ) {
                        var buckets = experiment.buckets,
index 4859953..514a3dd 100644 (file)
                 * Generate and print one more reports. When invoked with no arguments,
                 * print all reports.
                 *
-                * @param {string...} [reports] Report names to run, or unset to print
+                * @param {...string} [reports] Report names to run, or unset to print
                 *  all available reports.
                 */
                runReports: function () {
index 9463ac8..c9c0455 100644 (file)
                 *
                 * @param {Array} nodes List of one element, integer, n >= 0
                 * @param {Array} replacements List of at least n strings
-                * @return {String} replacement
+                * @return {string} replacement
                 */
                replace: function ( nodes, replacements ) {
                        var index = parseInt( nodes[ 0 ], 10 );
                 * from the server, since the replacement is done at save time.
                 * It may, though, if the wikitext appears in extension-controlled content.
                 *
-                * @param {String[]} nodes
+                * @param {string[]} nodes
                 */
                wikilink: function ( nodes ) {
                        var page, anchor, url;
                 *
                 * TODO: throw an error if nodes.length > 2 ?
                 *
-                * @param {Array} nodes List of two elements, {jQuery|Function|String} and {String}
+                * @param {Array} nodes List of two elements, {jQuery|Function|String} and {string}
                 * @return {jQuery}
                 */
                extlink: function ( nodes ) {
index ed81b0d..2eecbab 100644 (file)
                 *
                 * @since 1.25
                 * @param {string} formatString Format string
-                * @param {Mixed...} parameters Values for $N replacements
+                * @param {...Mixed} parameters Values for $N replacements
                 * @return {string} Formatted string
                 */
                format: function ( formatString ) {
                 *
                 * @see mw.Message
                 * @param {string} key Key of message to get
-                * @param {Mixed...} parameters Values for $N replacements
+                * @param {...Mixed} parameters Values for $N replacements
                 * @return {mw.Message}
                 */
                message: function ( key ) {
                 *
                 * @see mw.Message
                 * @param {string} key Key of message to get
-                * @param {Mixed...} parameters Values for $N replacements
+                * @param {...Mixed} parameters Values for $N replacements
                 * @return {string}
                 */
                msg: function () {
                         * Write a message the console's warning channel.
                         * Actions not supported by the browser console are silently ignored.
                         *
-                        * @param {string...} msg Messages to output to console
+                        * @param {...string} msg Messages to output to console
                         */
                        log.warn = function () {
                                var console = window.console;
                         * is a caught Error object.
                         *
                         * @since 1.26
-                        * @param {Error|string...} msg Messages to output to console
+                        * @param {Error|...string} msg Messages to output to console
                         */
                        log.error = function () {
                                var console = window.console;
                                        /**
                                         * Register a hook handler
                                         *
-                                        * @param {Function...} handler Function to bind.
+                                        * @param {...Function} handler Function to bind.
                                         * @chainable
                                         */
                                        add: list.add,
                                        /**
                                         * Unregister a hook handler
                                         *
-                                        * @param {Function...} handler Function to unbind.
+                                        * @param {...Function} handler Function to unbind.
                                         * @chainable
                                         */
                                        remove: list.remove,
                                        /**
                                         * Run a hook.
                                         *
-                                        * @param {Mixed...} data
+                                        * @param {...Mixed} data
                                         * @chainable
                                         */
                                        fire: function () {
index 053fb1a..93fb470 100644 (file)
@@ -22,7 +22,7 @@
         * messages to that, instead of the console.
         *
         * @member mw.log
-        * @param {string...} msg Messages to output to console.
+        * @param {...string} msg Messages to output to console.
         */
        mw.log = function () {
                // Turn arguments into an array
index 3958392..cb62fbf 100644 (file)
@@ -30,7 +30,7 @@
                  *
                  * @param {string} key Key name to store under
                  * @param {string} value Value to be stored
-                 * @returns {boolean} Whether the save succeeded or not
+                 * @return {boolean} Whether the save succeeded or not
                  */
                set: function ( key, value ) {
                        try {
@@ -44,7 +44,7 @@
                  * Remove a value from device storage.
                  *
                  * @param {string} key Key of item to remove
-                 * @returns {boolean} Whether the save succeeded or not
+                 * @return {boolean} Whether the save succeeded or not
                  */
                remove: function ( key ) {
                        try {
index c3db69e..91f1aff 100644 (file)
@@ -24,7 +24,7 @@
                 * Get the name of the compiler associated with a template based on its name.
                 *
                 * @param {string} templateName Name of template (including file suffix)
-                * @return {String} Name of compiler
+                * @return {string} Name of compiler
                 */
                getCompilerName: function ( templateName ) {
                        var templateParts = templateName.split( '.' );
index 01f9625..e7b45bd 100644 (file)
@@ -8,9 +8,9 @@
        /**
         * Add bogus to url to prevent IE crazy caching
         *
-        * @param {String} value a relative path (eg. 'data/foo.js'
+        * @param {string} value a relative path (eg. 'data/foo.js'
         * or 'data/test.php?foo=bar').
-        * @return {String} Such as 'data/foo.js?131031765087663960'
+        * @return {string} Such as 'data/foo.js?131031765087663960'
         */
        QUnit.fixurl = function ( value ) {
                return value + ( /\?/.test( value ) ? '&' : '?' )
index 1726a48..cab4080 100644 (file)
@@ -44,9 +44,9 @@
        /**
         * For a value, check if the parser recognizes it and how it transforms it
         *
-        * @param {String} msg text to pass on to qunit describing the test case
-        * @param {String[]} parserId of the parser that will be tested
-        * @param {String[][]} data Array of testcases. Each testcase, array of
+        * @param {string} msg text to pass on to qunit describing the test case
+        * @param {string[]} parserId of the parser that will be tested
+        * @param {string[][]} data Array of testcases. Each testcase, array of
         *              inputValue: The string value that we want to test the parser for
         *              recognized: If we expect that this value's type is detectable by the parser
         *              outputValue: The value the parser has converted the input to
index 054bf01..6805eab 100644 (file)
         * Create an HTML table from an array of row arrays containing text strings.
         * First row will be header row. No fancy rowspan/colspan stuff.
         *
-        * @param {String[]} header
-        * @param {String[][]} data
+        * @param {string[]} header
+        * @param {string[][]} data
         * @return {jQuery}
         */
        function tableCreate( header, data ) {
         * Extract text from table.
         *
         * @param {jQuery} $table
-        * @return {String[][]}
+        * @return {string[][]}
         */
        function tableExtract( $table ) {
                var data = [];
         * Run a table test by building a table with the given data,
         * running some callback on it, then checking the results.
         *
-        * @param {String} msg text to pass on to qunit for the comparison
-        * @param {String[]} header cols to make the table
-        * @param {String[][]} data rows/cols to make the table
-        * @param {String[][]} expected rows/cols to compare against at end
+        * @param {string} msg text to pass on to qunit for the comparison
+        * @param {string[]} header cols to make the table
+        * @param {string[][]} data rows/cols to make the table
+        * @param {string[][]} expected rows/cols to compare against at end
         * @param {function($table)} callback something to do with the table before we compare
         */
        function tableTest( msg, header, data, expected, callback ) {
         * Run a table test by building a table with the given HTML,
         * running some callback on it, then checking the results.
         *
-        * @param {String} msg text to pass on to qunit for the comparison
-        * @param {String} html HTML to make the table
-        * @param {String[][]} expected Rows/cols to compare against at end
+        * @param {string} msg text to pass on to qunit for the comparison
+        * @param {string} html HTML to make the table
+        * @param {string[][]} expected Rows/cols to compare against at end
         * @param {function($table)} callback Something to do with the table before we compare
         */
        function tableTestHTML( msg, html, expected, callback ) {
index 2e6f05e..1001679 100644 (file)
@@ -11,7 +11,7 @@
         * @param {string} options.output Output
         * @param {int} options.start Starting char for selection
         * @param {int} options.end Ending char for selection
-        * @param {object} options.params Additional parameters for $().textSelection( 'encapsulateText' )
+        * @param {Object} options.params Additional parameters for $().textSelection( 'encapsulateText' )
         */
        function encapsulateTest( options ) {
                var opt = $.extend( {