From: James D. Forrester Date: Sat, 5 Sep 2015 19:47:33 +0000 (-0700) Subject: build: Enable jscs jsDoc rule 'checkTypes' and make pass X-Git-Tag: 1.31.0-rc.0~9593^2 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=e8608b94a51eeccdf692e7fd1907f28fdf814f18;p=lhc%2Fweb%2Fwiklou.git build: Enable jscs jsDoc rule 'checkTypes' and make pass Change-Id: I64c3b5bd7afc4686355c80ef68009d978f7b3097 --- diff --git a/.jscsrc b/.jscsrc index 7226091dbe..c1fbc9ae49 100644 --- a/.jscsrc +++ b/.jscsrc @@ -9,6 +9,7 @@ "jsDoc": { "checkParamNames": true, "checkRedundantReturns": true, + "checkTypes": "strictNativeCase", "requireNewlineAfterDescription": true, "requireParamTypes": true, "requireReturnTypes": true diff --git a/resources/src/jquery/jquery.autoEllipsis.js b/resources/src/jquery/jquery.autoEllipsis.js index e1115d6504..fd7e8d1e39 100644 --- a/resources/src/jquery/jquery.autoEllipsis.js +++ b/resources/src/jquery/jquery.autoEllipsis.js @@ -10,11 +10,13 @@ var // Use a separate cache when match highlighting is enabled matchTextCache = {}; +// Due to +// 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 diff --git a/resources/src/jquery/jquery.expandableField.js b/resources/src/jquery/jquery.expandableField.js index 4f67b878ad..f9db72f91e 100644 --- a/resources/src/jquery/jquery.expandableField.js +++ b/resources/src/jquery/jquery.expandableField.js @@ -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 ) { diff --git a/resources/src/jquery/jquery.qunit.completenessTest.js b/resources/src/jquery/jquery.qunit.completenessTest.js index 25cc0572ea..8d263fbf2e 100644 --- a/resources/src/jquery/jquery.qunit.completenessTest.js +++ b/resources/src/jquery/jquery.qunit.completenessTest.js @@ -186,9 +186,9 @@ * 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 @@ -258,8 +258,8 @@ * 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 ) ) { diff --git a/resources/src/jquery/jquery.tablesorter.js b/resources/src/jquery/jquery.tablesorter.js index f6857e850f..0eefae6c90 100644 --- a/resources/src/jquery/jquery.tablesorter.js +++ b/resources/src/jquery/jquery.tablesorter.js @@ -426,8 +426,8 @@ * 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: diff --git a/resources/src/mediawiki.special/mediawiki.special.preferences.js b/resources/src/mediawiki.special/mediawiki.special.preferences.js index bad1c0837d..9b790e0361 100644 --- a/resources/src/mediawiki.special/mediawiki.special.preferences.js +++ b/resources/src/mediawiki.special/mediawiki.special.preferences.js @@ -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 ) { diff --git a/resources/src/mediawiki.toolbar/toolbar.js b/resources/src/mediawiki.toolbar/toolbar.js index 0469cc5058..bb26c0fc2e 100644 --- a/resources/src/mediawiki.toolbar/toolbar.js +++ b/resources/src/mediawiki.toolbar/toolbar.js @@ -115,7 +115,7 @@ * 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 ) { diff --git a/resources/src/mediawiki/api/edit.js b/resources/src/mediawiki/api/edit.js index e43285ff11..22affb1dab 100644 --- a/resources/src/mediawiki/api/edit.js +++ b/resources/src/mediawiki/api/edit.js @@ -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 }` diff --git a/resources/src/mediawiki/mediawiki.experiments.js b/resources/src/mediawiki/mediawiki.experiments.js index 75b1f80de4..b62e8d1037 100644 --- a/resources/src/mediawiki/mediawiki.experiments.js +++ b/resources/src/mediawiki/mediawiki.experiments.js @@ -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 @@ -68,15 +68,15 @@ * 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, diff --git a/resources/src/mediawiki/mediawiki.inspect.js b/resources/src/mediawiki/mediawiki.inspect.js index 4859953dbe..514a3dd15e 100644 --- a/resources/src/mediawiki/mediawiki.inspect.js +++ b/resources/src/mediawiki/mediawiki.inspect.js @@ -170,7 +170,7 @@ * 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 () { diff --git a/resources/src/mediawiki/mediawiki.jqueryMsg.js b/resources/src/mediawiki/mediawiki.jqueryMsg.js index 9463ac8d86..c9c0455c5a 100644 --- a/resources/src/mediawiki/mediawiki.jqueryMsg.js +++ b/resources/src/mediawiki/mediawiki.jqueryMsg.js @@ -1008,7 +1008,7 @@ * * @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 ); @@ -1033,7 +1033,7 @@ * 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; @@ -1097,7 +1097,7 @@ * * 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 ) { diff --git a/resources/src/mediawiki/mediawiki.js b/resources/src/mediawiki/mediawiki.js index ed81b0da9d..2eecbabb4e 100644 --- a/resources/src/mediawiki/mediawiki.js +++ b/resources/src/mediawiki/mediawiki.js @@ -416,7 +416,7 @@ * * @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 ) { @@ -558,7 +558,7 @@ * * @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 ) { @@ -573,7 +573,7 @@ * * @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 () { @@ -599,7 +599,7 @@ * 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; @@ -615,7 +615,7 @@ * 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; @@ -2528,7 +2528,7 @@ /** * Register a hook handler * - * @param {Function...} handler Function to bind. + * @param {...Function} handler Function to bind. * @chainable */ add: list.add, @@ -2536,7 +2536,7 @@ /** * Unregister a hook handler * - * @param {Function...} handler Function to unbind. + * @param {...Function} handler Function to unbind. * @chainable */ remove: list.remove, @@ -2544,7 +2544,7 @@ /** * Run a hook. * - * @param {Mixed...} data + * @param {...Mixed} data * @chainable */ fire: function () { diff --git a/resources/src/mediawiki/mediawiki.log.js b/resources/src/mediawiki/mediawiki.log.js index 053fb1a12e..93fb470aa9 100644 --- a/resources/src/mediawiki/mediawiki.log.js +++ b/resources/src/mediawiki/mediawiki.log.js @@ -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 diff --git a/resources/src/mediawiki/mediawiki.storage.js b/resources/src/mediawiki/mediawiki.storage.js index 39583926bb..cb62fbf26c 100644 --- a/resources/src/mediawiki/mediawiki.storage.js +++ b/resources/src/mediawiki/mediawiki.storage.js @@ -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 { diff --git a/resources/src/mediawiki/mediawiki.template.js b/resources/src/mediawiki/mediawiki.template.js index c3db69e6f4..91f1aff7ce 100644 --- a/resources/src/mediawiki/mediawiki.template.js +++ b/resources/src/mediawiki/mediawiki.template.js @@ -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( '.' ); diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index 01f9625204..e7b45bd70a 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -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 ) ? '&' : '?' ) diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js index 1726a48d4c..cab408095a 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js @@ -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 diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js index 054bf017ac..6805eabc23 100644 --- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js @@ -209,8 +209,8 @@ * 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 ) { @@ -242,7 +242,7 @@ * Extract text from table. * * @param {jQuery} $table - * @return {String[][]} + * @return {string[][]} */ function tableExtract( $table ) { var data = []; @@ -261,10 +261,10 @@ * 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 ) { @@ -286,9 +286,9 @@ * 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 ) { diff --git a/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js b/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js index 2e6f05edea..100167928f 100644 --- a/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.textSelection.test.js @@ -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( {