Spread and indent string-concatenations
authorEd Sanders <esanders@wikimedia.org>
Mon, 1 May 2017 13:56:04 +0000 (14:56 +0100)
committerEd Sanders <esanders@wikimedia.org>
Mon, 1 May 2017 13:56:04 +0000 (14:56 +0100)
Avoids single lint string concatenations and multi-line strings.

Change-Id: Iada91c1019cda87d48b13bdcff963d1950b54874

resources/src/jquery/jquery.tablesorter.js
resources/src/mediawiki/mediawiki.util.js
tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index f84c091..8d019e5 100644 (file)
 
                // We allow a trailing percent sign, which we just strip. This works fine
                // if percents and regular numbers aren't being mixed.
-               ts.numberRegex = new RegExp( '^(' + '[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?' + // Fortran-style scientific
-               '|' + '[-+\u2212]?' + digitClass + '+[\\s\\xa0]*%?' + // Generic localised
-               ')$', 'i' );
+               ts.numberRegex = new RegExp(
+                       '^(' +
+                               '[-+\u2212]?[0-9][0-9,]*(\\.[0-9,]*)?(E[-+\u2212]?[0-9][0-9,]*)?' + // Fortran-style scientific
+                               '|' +
+                               '[-+\u2212]?' + digitClass + '+[\\s\\xa0]*%?' + // Generic localised
+                       ')$',
+                       'i'
+               );
        }
 
        function buildDateTable() {
                ts.dateRegex[ 0 ] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i );
 
                // Written Month name, dmy
-               ts.dateRegex[ 1 ] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
+               ts.dateRegex[ 1 ] = new RegExp(
+                       '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' +
+                               regex +
+                       ')' +
+                       '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$',
+                       'i'
+               );
 
                // Written Month name, mdy
-               ts.dateRegex[ 2 ] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
+               ts.dateRegex[ 2 ] = new RegExp(
+                       '^\\s*(' + regex + ')' +
+                       '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$',
+                       'i'
+               );
 
        }
 
index 67e2ebb..a9c0942 100644 (file)
                        block = allowBlock ? '(?:\\/(?:12[0-8]|1[01][0-9]|[1-9]?\\d))?' : '';
                        RE_IPV6_ADD =
                                '(?:' + // starts with "::" (including "::")
-                               ':(?::|(?::' + '[0-9A-Fa-f]{1,4}' + '){1,7})' +
-                               '|' + // ends with "::" (except "::")
-                               '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){0,6}::' +
-                               '|' + // contains no "::"
-                               '[0-9A-Fa-f]{1,4}' + '(?::' + '[0-9A-Fa-f]{1,4}' + '){7}' +
+                                       ':(?::|(?::' +
+                                               '[0-9A-Fa-f]{1,4}' +
+                                       '){1,7})' +
+                                       '|' + // ends with "::" (except "::")
+                                       '[0-9A-Fa-f]{1,4}' +
+                                       '(?::' +
+                                               '[0-9A-Fa-f]{1,4}' +
+                                       '){0,6}::' +
+                                       '|' + // contains no "::"
+                                       '[0-9A-Fa-f]{1,4}' +
+                                       '(?::' +
+                                               '[0-9A-Fa-f]{1,4}' +
+                                       '){7}' +
                                ')';
 
                        if ( new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) ) {
                        }
 
                        // contains one "::" in the middle (single '::' check below)
-                       RE_IPV6_ADD = '[0-9A-Fa-f]{1,4}' + '(?:::?' + '[0-9A-Fa-f]{1,4}' + '){1,6}';
+                       RE_IPV6_ADD =
+                               '[0-9A-Fa-f]{1,4}' +
+                               '(?:::?' +
+                                       '[0-9A-Fa-f]{1,4}' +
+                               '){1,6}';
 
                        return (
                                new RegExp( '^' + RE_IPV6_ADD + block + '$' ).test( address ) &&
index c7b7cc0..5c1be67 100644 (file)
                $input: $( '<input>' ).attr( 'type', 'text' )
                        .byteLimit( 12 ),
                sample: mbSample,
-               expected: '1234567890' + '12'
+               expected: '123456789012'
        } );
 
        byteLimitTest( {
index 1bc4c06..d6fe744 100644 (file)
                        title = mw.Title.newFromImg( { src: thisCase.url } );
 
                        if ( thisCase.nameText !== undefined ) {
-                               prefix = '[' + thisCase.typeOfUrl + ' URL' + '] ';
+                               prefix = '[' + thisCase.typeOfUrl + ' URL] ';
 
                                assert.notStrictEqual( title, null, prefix + 'Parses successfully' );
                                assert.equal( title.getNameText(), thisCase.nameText, prefix + 'Filename matches original' );
index 0e88740..da04c8d 100644 (file)
                var pTestTb, pCustom, vectorTabs, tbRL, cuQuux, $cuQuux, tbMW, $tbMW, tbRLDM, caFoo,
                        addedAfter, tbRLDMnonexistentid, tbRLDMemptyjquery;
 
-               pTestTb = '\
-               <div class="portlet" id="p-test-tb">\
-                       <h3>Toolbox</h3>\
-                       <ul class="body"></ul>\
-               </div>';
-               pCustom = '\
-               <div class="portlet" id="p-test-custom">\
-                       <h3>Views</h3>\
-                       <ul class="body">\
-                               <li id="c-foo"><a href="#">Foo</a></li>\
-                               <li id="c-barmenu">\
-                                       <ul>\
-                                               <li id="c-bar-baz"><a href="#">Baz</a></a>\
-                                       </ul>\
-                               </li>\
-                       </ul>\
-               </div>';
-               vectorTabs = '\
-               <div id="p-test-views" class="vectorTabs">\
-                       <h3>Views</h3>\
-                       <ul></ul>\
-               </div>';
+               pTestTb =
+                       '<div class="portlet" id="p-test-tb">' +
+                               '<h3>Toolbox</h3>' +
+                               '<ul class="body"></ul>' +
+                       '</div>';
+               pCustom =
+                       '<div class="portlet" id="p-test-custom">' +
+                               '<h3>Views</h3>' +
+                               '<ul class="body">' +
+                                       '<li id="c-foo"><a href="#">Foo</a></li>' +
+                                       '<li id="c-barmenu">' +
+                                               '<ul>' +
+                                                       '<li id="c-bar-baz"><a href="#">Baz</a></a>' +
+                                               '</ul>' +
+                                       '</li>' +
+                               '</ul>' +
+                       '</div>';
+               vectorTabs =
+                       '<div id="p-test-views" class="vectorTabs">' +
+                               '<h3>Views</h3>' +
+                               '<ul></ul>' +
+                       '</div>';
 
                $( '#qunit-fixture' ).append( pTestTb, pCustom, vectorTabs );