Arlolra has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/202241

Change subject: [jscs] Enforce requireSpaceBeforeBinaryOperators
......................................................................

[jscs] Enforce requireSpaceBeforeBinaryOperators

 * This was auto-corrected with jscs -x .

Change-Id: I13df3896e8130743eb31581e80d4c7909e48768d
---
M .jscsrc
M lib/LogData.js
M lib/XMLSerializer.js
M lib/dom.computeDSR.js
M lib/dom.handlePres.js
M lib/dom.linter.js
M lib/dom.t.TableFixups.js
M lib/dom.wrapTemplates.js
M lib/ext.Cite.js
M lib/ext.core.AttributeExpander.js
M lib/ext.core.LinkHandler.js
M lib/ext.core.ListHandler.js
M lib/ext.core.ParagraphWrapper.js
M lib/ext.core.ParserFunctions.js
M lib/ext.core.PreHandler.js
M lib/ext.core.QuoteTransformer.js
M lib/ext.util.TokenCollector.js
M lib/jsutils.js
M lib/mediawiki.ApiRequest.js
M lib/mediawiki.DOMPostProcessor.js
M lib/mediawiki.DOMUtils.js
M lib/mediawiki.TokenTransformManager.js
M lib/mediawiki.Util.js
M lib/mediawiki.WikiConfig.js
M lib/mediawiki.WikitextSerializer.js
M lib/mediawiki.parser.defines.js
M lib/mediawiki.parser.environment.js
M lib/mediawiki.parser.js
M lib/mediawiki.tokenizer.utils.js
M lib/pegTokenizer.pegjs.txt
M lib/wts.ConstrainedText.js
M lib/wts.LinkHandler.js
M lib/wts.SerializerState.js
M lib/wts.TagHandlers.js
M lib/wts.escapeWikitext.js
M tests/client/client.js
M tests/fetch-parserTests.txt.js
M tests/mocha/parse.js
M tests/parserTests.js
M tests/server/diff.js
M tests/server/server.js
M tests/server/static/js/commitList.js
M tests/sync-parserTests.js
43 files changed, 167 insertions(+), 168 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/parsoid 
refs/changes/41/202241/1

diff --git a/.jscsrc b/.jscsrc
index 046678e..1f1795c 100644
--- a/.jscsrc
+++ b/.jscsrc
@@ -21,7 +21,6 @@
        ],
        "requireSpaceAfterLineComment": null,
        "requireSpaceAfterBinaryOperators": null,
-       "requireSpaceBeforeBinaryOperators": null,
        "requireTrailingComma": null,
        "validateIndentation": null,
        "validateQuoteMarks": null,
diff --git a/lib/LogData.js b/lib/LogData.js
index 0c1fa8c..fdff696 100644
--- a/lib/LogData.js
+++ b/lib/LogData.js
@@ -151,7 +151,7 @@
                        f.code = o.code;
                }
                return f;
-       } else if (typeof (o)==='function') {
+       } else if (typeof (o) ==='function') {
                return self._flatten(o());
        } else if (typeof (o) === 'object' && o.hasOwnProperty('msg')) {
                return o;
diff --git a/lib/XMLSerializer.js b/lib/XMLSerializer.js
index f8ef3b9..6cae0b8 100644
--- a/lib/XMLSerializer.js
+++ b/lib/XMLSerializer.js
@@ -88,7 +88,7 @@
                var nodeName = node.tagName.toLowerCase(),
                        localName = node.localName;
                cb('<' + localName);
-               for (var i=0;i<len;i++) {
+               for (var i =0;i <len;i++) {
                        var attr = attrs.item(i),
                                singleQuotes, doubleQuotes,
                                useSingleQuotes = false;
diff --git a/lib/dom.computeDSR.js b/lib/dom.computeDSR.js
index e638a16..fb7194b 100644
--- a/lib/dom.computeDSR.js
+++ b/lib/dom.computeDSR.js
@@ -209,7 +209,7 @@
                cs = ce,
                rtTestMode = env.conf.parsoid.rtTestMode;
 
-       for (var i = numChildren-1; i >= 0; i--) {
+       for (var i = numChildren -1; i >= 0; i--) {
                var isMarkerTag = false,
                        origCE = ce,
                        child = children[i],
diff --git a/lib/dom.handlePres.js b/lib/dom.handlePres.js
index 9914399..2912262 100644
--- a/lib/dom.handlePres.js
+++ b/lib/dom.handlePres.js
@@ -16,10 +16,10 @@
        for (var i = 0, n = children.length; i < n; i++) {
                var c = children[i];
                if (DU.isText(c)) {
-                       c.data = fixedIndentPreText(c.data, isLastChild && i 
=== n-1);
+                       c.data = fixedIndentPreText(c.data, isLastChild && i 
=== n -1);
                } else {
                        // recurse
-                       reinsertLeadingSpace(c, isLastChild && i === n-1);
+                       reinsertLeadingSpace(c, isLastChild && i === n -1);
                }
        }
 }
diff --git a/lib/dom.linter.js b/lib/dom.linter.js
index 34f11b0..5074140 100644
--- a/lib/dom.linter.js
+++ b/lib/dom.linter.js
@@ -94,13 +94,13 @@
                DU.hasLiteralHTMLMarker(dp) &&
                dsr) ) {
 
-               if (dp.autoInsertedEnd === true && (tmpl || dsr[2]>0) ) {
+               if (dp.autoInsertedEnd === true && (tmpl || dsr[2] >0) ) {
                        lintObj = { src: env.page.src, dsr: dsr,
                                                tip: 'Add End Tag to Fix this', 
inTransclusion: inTransclusion};
                        env.log('lint/missing-end-tag', lintObj);
                }
 
-               if (dp.autoInsertedStart === true && (tmpl ||  dsr[3]>0) ) {
+               if (dp.autoInsertedStart === true && (tmpl ||  dsr[3] >0) ) {
                        lintObj = { src: env.page.src, dsr: dsr,
                                                tip: 'Add Start Tag to Fix 
this', inTransclusion: inTransclusion};
                        env.log('lint/missing-start-tag', lintObj);
diff --git a/lib/dom.t.TableFixups.js b/lib/dom.t.TableFixups.js
index a2268d5..a08bb76 100644
--- a/lib/dom.t.TableFixups.js
+++ b/lib/dom.t.TableFixups.js
@@ -374,7 +374,7 @@
                                var match1 = 
child.textContent.match(/^(.*?[^|])?\|\|([^|].*)?$/);
                                var match2 = 
child.textContent.match(/^(.*?[^!])?\!\!([^!].*)?$/);
                                if (match1 && match2) {
-                                       match = (match1[1]||'').length < 
(match2[1]||'').length ? match1 : match2;
+                                       match = (match1[1] ||'').length < 
(match2[1] ||'').length ? match1 : match2;
                                } else {
                                        match = match1 || match2;
                                }
diff --git a/lib/dom.wrapTemplates.js b/lib/dom.wrapTemplates.js
index 86c31c3..e69252c 100644
--- a/lib/dom.wrapTemplates.js
+++ b/lib/dom.wrapTemplates.js
@@ -297,7 +297,7 @@
                        dsr = dp.dsr;
 
                if (tplArray.length > 0) {
-                       var prevTplInfo = tplArray[tplArray.length-1];
+                       var prevTplInfo = tplArray[tplArray.length -1];
                        if (prevTplInfo.dsr[1] < dsr[0]) {
                                tplArray.push({ wt: 
env.page.src.substring(prevTplInfo.dsr[1], dsr[0]) });
                        }
@@ -690,7 +690,7 @@
                        }
 
                        // Add any trailing wikitext
-                       var lastTplInfo = tplArray[tplArray.length-1];
+                       var lastTplInfo = tplArray[tplArray.length -1];
                        if (lastTplInfo.dsr[1] < dp1.dsr[1]) {
                                tplArray.push({ wt: 
env.page.src.substring(lastTplInfo.dsr[1], dp1.dsr[1]) });
                        }
diff --git a/lib/ext.Cite.js b/lib/ext.Cite.js
index 80f6076..6e0cfd8 100644
--- a/lib/ext.Cite.js
+++ b/lib/ext.Cite.js
@@ -48,7 +48,7 @@
                opts.pipelineOpts = Util.extendProps({}, opts.pipelineOpts, { 
wrapTemplates: true });
 
                var tsr = extToken.dataAttribs.tsr;
-               opts.srcOffsets = [ tsr[0]+tagWidths[0]+leadingWS.length, 
tsr[1]-tagWidths[1] ];
+               opts.srcOffsets = [ tsr[0] +tagWidths[0] +leadingWS.length, 
tsr[1] -tagWidths[1] ];
 
                // Process ref content
                Util.processContentInPipeline(manager.env, manager.frame, 
content, opts);
@@ -251,7 +251,7 @@
                // Notes (references) whose ref doesn't have a name are 
'cite_note-' + index
                // Notes whose ref has a name are 'cite_note-' + name + '-' + 
index
                var n = this.index,
-                       refKey = (1+n) + '',
+                       refKey = (1 +n) + '',
                        refIdBase = 'cite_ref-' + (refName ? refName + '_' + 
refKey : refKey),
                        noteId = 'cite_note-' + (refName ? refName + '-' + 
refKey : refKey);
 
diff --git a/lib/ext.core.AttributeExpander.js 
b/lib/ext.core.AttributeExpander.js
index 6f42b33..1703941 100644
--- a/lib/ext.core.AttributeExpander.js
+++ b/lib/ext.core.AttributeExpander.js
@@ -332,7 +332,7 @@
                                                        expandedK = kvs[0].k;
                                                        reparsedKV = true;
                                                        if (!newAttrs) {
-                                                               newAttrs = i 
=== 0 ? [] : expandedAttrs.slice(0, i-1);
+                                                               newAttrs = i 
=== 0 ? [] : expandedAttrs.slice(0, i -1);
                                                        }
                                                        newAttrs = 
newAttrs.concat(kvs);
                                                }
@@ -427,7 +427,7 @@
                                // Rebuild flattened k-v pairs.
                                var expandedAttrs = [];
                                for (var i = 0; i < eVals.length; i += 2) {
-                                       expandedAttrs.push([eVals[i], 
eVals[i+1]]);
+                                       expandedAttrs.push([eVals[i], eVals[i 
+1]]);
                                }
 
                                // Mark token as having expanded attrs.
diff --git a/lib/ext.core.LinkHandler.js b/lib/ext.core.LinkHandler.js
index 88dbd97..dd39daa 100644
--- a/lib/ext.core.LinkHandler.js
+++ b/lib/ext.core.LinkHandler.js
@@ -209,7 +209,7 @@
                        // adjust TSR of the DOM-fragment by 2 each on both end.
                        var tsr = token.dataAttribs && token.dataAttribs.tsr;
                        if (tsr && typeof (tsr[0]) === 'number' && typeof 
(tsr[1]) === 'number') {
-                               tsr = [tsr[0]+2, tsr[1]-2];
+                               tsr = [tsr[0] +2, tsr[1] -2];
                        } else {
                                tsr = null;
                        }
@@ -358,8 +358,8 @@
                        toks = toks.filter(function(token) { return token !== 
''; });
                        toks = toks.map(function(token, i) {
                                if (token.constructor === TagTk && token.name 
=== 'a') {
-                                       if (toks[i+1] && toks[i+1].constructor 
=== EndTagTk &&
-                                               toks[i+1].name === 'a') {
+                                       if (toks[i +1] && toks[i 
+1].constructor === EndTagTk &&
+                                               toks[i +1].name === 'a') {
                                                // autonumbered links in the 
stream get rendered
                                                // as an <a> tag with no 
content -- but these ought
                                                // to be treated as plaintext 
since we don't allow
@@ -383,7 +383,7 @@
                if (buildDOMFragment) {
                        // content = [part 0, .. part l-1]
                        // offsets = [start(part-0), end(part l-1)]
-                       var offsets = dataAttribs.tsr ? 
[content[0].srcOffsets[0], content[l-1].srcOffsets[1]] : null;
+                       var offsets = dataAttribs.tsr ? 
[content[0].srcOffsets[0], content[l -1].srcOffsets[1]] : null;
                        content = [ Util.getDOMFragmentToken(out, offsets, 
{noPWrapping: true, noPre: true, token: token}) ];
                } else {
                        content = out;
diff --git a/lib/ext.core.ListHandler.js b/lib/ext.core.ListHandler.js
index 2e591e7..756d514 100644
--- a/lib/ext.core.ListHandler.js
+++ b/lib/ext.core.ListHandler.js
@@ -392,12 +392,12 @@
                                this.env.log("trace/list", 
this.manager.pipelineId,
                                        "    -> increased nesting: first");
                                listDP     = makeDP(0,0);
-                               listItemDP = makeDP(0,i+1);
+                               listItemDP = makeDP(0,i +1);
                        } else {
                                this.env.log("trace/list", 
this.manager.pipelineId,
                                        "    -> increased nesting: 2nd and 
higher");
                                listDP     = makeDP(i,i);
-                               listItemDP = makeDP(i,i+1);
+                               listItemDP = makeDP(i,i +1);
                        }
 
                        tokens = tokens.concat( this.pushList(
diff --git a/lib/ext.core.ParagraphWrapper.js b/lib/ext.core.ParagraphWrapper.js
index 2067125..45e67bd 100644
--- a/lib/ext.core.ParagraphWrapper.js
+++ b/lib/ext.core.ParagraphWrapper.js
@@ -91,14 +91,14 @@
        var newRes = null;
        for (var i = 0, n = res.length; i < n; i++) {
                var t = res[i];
-               if (i+2 < n && t.constructor === TagTk && t.name === 'p' && 
!t.isHTMLTag() &&
-                       Consts.HTML.FormattingTags.has((res[i+1].name || 
'').toUpperCase()) &&
-                       res[i+2].constructor === EndTagTk && res[i+2].name === 
'p' && !res[i+2].isHTMLTag()) {
+               if (i +2 < n && t.constructor === TagTk && t.name === 'p' && 
!t.isHTMLTag() &&
+                       Consts.HTML.FormattingTags.has((res[i +1].name || 
'').toUpperCase()) &&
+                       res[i +2].constructor === EndTagTk && res[i +2].name 
=== 'p' && !res[i +2].isHTMLTag()) {
                        // Init newRes
                        if (newRes === null) {
                                newRes = i === 0 ? [] : res.slice(0, i);
                        }
-                       newRes.push(res[i+1]);
+                       newRes.push(res[i +1]);
                        i += 2;
                } else if (newRes !== null) {
                        newRes.push(t);
@@ -223,7 +223,7 @@
                                break;
                        }
                }
-               out.splice( i+1, 0, new EndTagTk('p') );
+               out.splice( i +1, 0, new EndTagTk('p') );
                this.hasOpenPTag = false;
        }
 };
@@ -252,7 +252,7 @@
                                // here will eliminate useless array copying. 
Not sure if this
                                // optimization is worth this check.
                                if (!t.name || 
!Consts.HTML.FormattingTags.has(t.name.toUpperCase())
-                                       || !(i+1 < n && 
Util.isBlockToken(toks[i+1]))) {
+                                       || !(i +1 < n && 
Util.isBlockToken(toks[i +1]))) {
                                        newToks.push(new TagTk('p'));
                                        this.hasOpenPTag = true;
                                }
diff --git a/lib/ext.core.ParserFunctions.js b/lib/ext.core.ParserFunctions.js
index 172c39f..93e1eb3 100644
--- a/lib/ext.core.ParserFunctions.js
+++ b/lib/ext.core.ParserFunctions.js
@@ -190,7 +190,7 @@
                                        cb: function( i, val ) {
                                                setImmediate(
                                                        
self._switchLookupFallback.bind( self, frame,
-                                                               kvs.slice(i+1), 
key, dict, cb, val )
+                                                               kvs.slice(i 
+1), key, dict, cb, val )
                                                );
                                        }.bind( self, i ),
                                        asyncCB: cb
@@ -457,11 +457,11 @@
  ['time','H:i'], ['hour','H'], ['week','W'],
  ['timestamp', 'YmdHis']].forEach(function(a) {
         var name = a[0], format = a[1];
-        ParserFunctions.prototype['pf_current'+name] =
+        ParserFunctions.prototype['pf_current' +name] =
                 function ( token, frame, cb, args ) {
                         cb( this._pf_time_tokens( format, [], {} ) );
                 };
-        ParserFunctions.prototype['pf_local'+name] =
+        ParserFunctions.prototype['pf_local' +name] =
                 function ( token, frame, cb, args ) {
                         cb( this._pf_timel_tokens( format, [], {} ) );
                 };
@@ -528,11 +528,11 @@
        var offset = date.getTimezoneOffset();
        // XXX: parse forcetime and change date
        // when testing, look aside to other date?
-       if (typeof (env.conf.wiki.fakeTimestamp)==='number') {
+       if (typeof (env.conf.wiki.fakeTimestamp) ==='number') {
                // php time stamps are in seconds; js timestamps are in 
milliseconds
                date.setTime(env.conf.wiki.fakeTimestamp * 1000);
        }
-       if (typeof (env.conf.wiki.timezoneOffset)==='number') {
+       if (typeof (env.conf.wiki.timezoneOffset) ==='number') {
                // this is the wiki's $wgLocaltimezone (if set)
                offset = env.conf.wiki.timezoneOffset;
        }
@@ -565,7 +565,7 @@
        return this.format('D, d M Y H:i:s O');
 };
 ParsoidDate.prototype.getTimezoneOffset = function() {
-       return (this._date.getTime() - this._localdate.getTime())/(60*1000);
+       return (this._date.getTime() - this._localdate.getTime()) /(60 *1000);
 };
 var getJan1 = function(d) {
        d = new Date(d.getTime());
@@ -640,7 +640,7 @@
     M: function() { return 
ParsoidDate.replaceChars.shortMonths[this.getMonth()]; },
     n: function() { return this.getMonth() + 1; },
     t: function() {
-               return new Date(this.getFullYear(), this.getMonth()+1, 
0).getDate();
+               return new Date(this.getFullYear(), this.getMonth() +1, 
0).getDate();
        },
     // Year
     L: function() {
diff --git a/lib/ext.core.PreHandler.js b/lib/ext.core.PreHandler.js
index db3895b..ee54a1b 100644
--- a/lib/ext.core.PreHandler.js
+++ b/lib/ext.core.PreHandler.js
@@ -210,7 +210,7 @@
        if (this.tokens.length > 0) {
                var da = null;
                if (this.preTSR !== -1) {
-                       da = { tsr: [this.preTSR, this.preTSR+1] };
+                       da = { tsr: [this.preTSR, this.preTSR +1] };
                }
                ret = [ new TagTk('pre', [], da) ].concat( this.tokens );
                ret.push(new EndTagTk('pre'));
diff --git a/lib/ext.core.QuoteTransformer.js b/lib/ext.core.QuoteTransformer.js
index 9cebb54..92f3ab1 100644
--- a/lib/ext.core.QuoteTransformer.js
+++ b/lib/ext.core.QuoteTransformer.js
@@ -75,7 +75,7 @@
                this.currentChunk.push( prevToken ? prevToken : '' );
        }
 
-       if (qlen===2 || qlen===3 || qlen===5) {
+       if (qlen ===2 || qlen ===3 || qlen ===5) {
                        this._startNewChunk();
                        this.currentChunk.push( token );
                        this._startNewChunk();
@@ -106,10 +106,10 @@
        // count number of bold and italics
        var numbold = 0, numitalics = 0;
        for (i = 1; i < this.chunks.length; i += 2) {
-               console.assert(this.chunks[i].length===1); // quote token
+               console.assert(this.chunks[i].length ===1); // quote token
                qlen = this.chunks[i][0].value.length;
-               if (qlen===2 || qlen===5) { numitalics++; }
-               if (qlen===3 || qlen===5) { numbold++; }
+               if (qlen ===2 || qlen ===5) { numitalics++; }
+               if (qlen ===3 || qlen ===5) { numbold++; }
        }
 
        // balance out tokens, convert placeholders into tags
@@ -123,7 +123,7 @@
                        // find the first previous token which is text
                        // (this is an approximation, since the wikitext 
algorithm looks
                        // at the raw unparsed source here)
-                       var prevChunk = this.chunks[i-1], ctxPrevToken = '';
+                       var prevChunk = this.chunks[i -1], ctxPrevToken = '';
                        for (var j = prevChunk.length - 1;
                                 ctxPrevToken.length < 2 && j >= 0;
                                 j--) {
@@ -194,14 +194,14 @@
 // italic tags. In the process, one quote needs to be converted back to text.
 QuoteTransformer.prototype.convertBold = function ( i ) {
        // this should be a bold tag.
-       console.assert(i > 0 && this.chunks[i].length===1 &&
+       console.assert(i > 0 && this.chunks[i].length ===1 &&
                                   this.chunks[i][0].value.length === 3);
        // we're going to convert it to a single plain text ' plus an italic tag
-       this.chunks[i-1].push( "'" );
+       this.chunks[i -1].push( "'" );
        var oldbold = this.chunks[i][0];
        var tsr = oldbold.dataAttribs ? oldbold.dataAttribs.tsr : null;
        if ( tsr ) {
-               tsr = [ tsr[0]+1, tsr[1] ];
+               tsr = [ tsr[0] +1, tsr[1] ];
        }
        var newbold = new SelfclosingTagTk( 'mw-quote', [], { tsr: tsr });
        newbold.value = "''"; // italic!
@@ -307,9 +307,9 @@
        // make tsr
        var tsr = oldtag.dataAttribs ? oldtag.dataAttribs.tsr : null;
        var startpos = tsr ? tsr[0] : null, endpos = tsr ? tsr[1] : null;
-       for (var i=0; i<tags.length; i++) {
+       for (var i =0; i <tags.length; i++) {
                if (tsr) {
-                       if ( i===0 && ignoreBogusTwo ) {
+                       if ( i ===0 && ignoreBogusTwo ) {
                                
this.last[tags[i].name].dataAttribs.autoInsertedEnd = true;
                        } else if ( i === 2 && ignoreBogusTwo ) {
                                tags[i].dataAttribs.autoInsertedStart = true;
diff --git a/lib/ext.util.TokenCollector.js b/lib/ext.util.TokenCollector.js
index 683694c..a95b5a3 100644
--- a/lib/ext.util.TokenCollector.js
+++ b/lib/ext.util.TokenCollector.js
@@ -144,7 +144,7 @@
  */
 TokenCollector.prototype._onAnyToken = function ( token, frame, cb ) {
        // Simply collect anything ordinary in between
-       this.scopeStack[this.scopeStack.length-1].push( token );
+       this.scopeStack[this.scopeStack.length -1].push( token );
        return { };
 };
 
diff --git a/lib/jsutils.js b/lib/jsutils.js
index 892b5b8..1b2b420 100644
--- a/lib/jsutils.js
+++ b/lib/jsutils.js
@@ -75,8 +75,8 @@
        // an object, with a `flags` property (as shown in the example above).
        rejoin: function() {
                var regexps = Array.prototype.slice.call(arguments);
-               var last = regexps[regexps.length-1], flags;
-               if (typeof (last)==='object') {
+               var last = regexps[regexps.length -1], flags;
+               if (typeof (last) ==='object') {
                        if (last instanceof RegExp) {
                                flags = /\/([gimy]*)$/.exec(last.toString())[1];
                        } else {
@@ -161,7 +161,7 @@
        //
        mkPromised: function( callback, names ) {
                var res, rej;
-               var p = new Promise(function( _res, _rej ) { res=_res; 
rej=_rej; });
+               var p = new Promise(function( _res, _rej ) { res =_res; rej 
=_rej; });
                var f = function( e, v ) {
                        if ( e ) {
                                rej( e );
diff --git a/lib/mediawiki.ApiRequest.js b/lib/mediawiki.ApiRequest.js
index 2661961..1dbeab6 100644
--- a/lib/mediawiki.ApiRequest.js
+++ b/lib/mediawiki.ApiRequest.js
@@ -468,8 +468,8 @@
        // Ditto for page properties (like DISPLAYTITLE and DEFAULTSORT)
        if (Array.isArray(data.expandtemplates.properties)) {
                data.expandtemplates.properties.forEach(function(prop) {
-                       if (prop.name==='displaytitle' || 
prop.name==='defaultsort') {
-                               src += '\n{{'+prop.name.toUpperCase()+':' + 
prop['*'] + '}}';
+                       if (prop.name ==='displaytitle' || prop.name 
==='defaultsort') {
+                               src += '\n{{' +prop.name.toUpperCase() +':' + 
prop['*'] + '}}';
                        }
                });
        }
@@ -931,7 +931,7 @@
 if (typeof module === "object") {
        module.exports.ConfigRequest = ConfigRequest;
        module.exports.TemplateRequest = TemplateRequest;
-       module.exports.PreprocessorRequest= PreprocessorRequest;
+       module.exports.PreprocessorRequest = PreprocessorRequest;
        module.exports.PHPParseRequest = PHPParseRequest;
        module.exports.ParsoidCacheRequest = ParsoidCacheRequest;
        module.exports.ImageInfoRequest = ImageInfoRequest;
diff --git a/lib/mediawiki.DOMPostProcessor.js 
b/lib/mediawiki.DOMPostProcessor.js
index 08c7496..f2d77a5 100644
--- a/lib/mediawiki.DOMPostProcessor.js
+++ b/lib/mediawiki.DOMPostProcessor.js
@@ -279,7 +279,7 @@
        var mwrPrefix = url.resolve('http://',
                                    env.conf.wiki.baseURI + 'Special:Redirect/' 
);
        document.documentElement.setAttribute('prefix', prefixes.join(' '));
-       document.head.setAttribute('prefix', 'mwr: '+mwrPrefix);
+       document.head.setAttribute('prefix', 'mwr: ' +mwrPrefix);
 
        // add <head> content based on page meta data:
 
@@ -307,7 +307,7 @@
                Object.keys( mdm ).forEach(function( k ) {
                        // evaluate a function, or perform sprintf-style 
formatting, or
                        // use string directly, depending on value in 
metadataMap
-                       var v = ( typeof (mdm[k])==='function' ) ? mdm[k]( m ) :
+                       var v = ( typeof (mdm[k]) ==='function' ) ? mdm[k]( m ) 
:
                                mdm[k].indexOf('%') >= 0 ? util.format( mdm[k], 
m.get(f) ) :
                                mdm[k];
                        attrs[k] = v;
diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js
index dc5fb61..719b0f2 100644
--- a/lib/mediawiki.DOMUtils.js
+++ b/lib/mediawiki.DOMUtils.js
@@ -807,9 +807,9 @@
                                // We dont want the trailing newline of the 
last child of the pre
                                // to contribute a pre-correction since it 
doesn't add new content
                                // in the pre-node after the text
-                               numNLs = 
(textNode.nodeValue.match(/\n./g)||[]).length;
+                               numNLs = (textNode.nodeValue.match(/\n./g) 
||[]).length;
                        } else {
-                               numNLs = 
(textNode.nodeValue.match(/\n/g)||[]).length;
+                               numNLs = (textNode.nodeValue.match(/\n/g) 
||[]).length;
                        }
                        return numNLs;
                } else {
@@ -2096,7 +2096,7 @@
                        innerXML: false
                };
        }
-       if (doc.nodeName==='#document') {
+       if (doc.nodeName ==='#document') {
                html = XMLSerializer.serializeToString(doc.documentElement, 
options);
        } else {
                html = XMLSerializer.serializeToString(doc, options);
@@ -2202,11 +2202,11 @@
                // reassemble text nodes split by a comment or span, if 
necessary
                node.normalize();
                // now recurse.
-               if (node.nodeName==='PRE') {
+               if (node.nodeName ==='PRE') {
                        // hack, since PHP adds a newline before </pre>
                        stripLeadingWS = false;
                        stripTrailingWS = true;
-               } else if (node.nodeName==='SPAN' &&
+               } else if (node.nodeName ==='SPAN' &&
                                   /^mw[:]/.test(node.getAttribute('typeof') || 
'')) {
                        // SPAN is transparent; pass the strip parameters down 
to kids
                        /* jshint noempty: false */
diff --git a/lib/mediawiki.TokenTransformManager.js 
b/lib/mediawiki.TokenTransformManager.js
index b91488c..b187efa 100644
--- a/lib/mediawiki.TokenTransformManager.js
+++ b/lib/mediawiki.TokenTransformManager.js
@@ -44,7 +44,7 @@
 
        if (ret.tokens && !Array.isArray(ret.tokens)) {
                var errors = [
-                       'ret.tokens is not an array: '+ 
ret.tokens.constructor.name,
+                       'ret.tokens is not an array: ' + 
ret.tokens.constructor.name,
                        'ret.tokens: ' + JSON.stringify( ret )
                ];
                env.log("error", errors.join("\n"));
@@ -1170,7 +1170,7 @@
        if (this.siblingChunks.length) {
                for (var i = 0, len = this.siblingChunks.length; i < len; i++) {
                        this._callParentCB({tokens: this.siblingChunks[i],
-                               async: (i < len-1)? true : async});
+                               async: (i < len -1)? true : async});
                }
                this.siblingChunks = [];
        } else {
diff --git a/lib/mediawiki.Util.js b/lib/mediawiki.Util.js
index a004dbd..ed63c57 100644
--- a/lib/mediawiki.Util.js
+++ b/lib/mediawiki.Util.js
@@ -196,7 +196,7 @@
                        obj.usePHPPreProcessor = obj.fetchTemplates && 
Util.booleanOption( opts.usephppreprocessor );
                }
                if (opts.maxDepth !== undefined) {
-                       obj.maxDepth = typeof (opts.maxdepth)==='number' ? 
opts.maxdepth : obj.maxDepth;
+                       obj.maxDepth = typeof (opts.maxdepth) ==='number' ? 
opts.maxdepth : obj.maxDepth;
                }
                if (opts.dp !== undefined) {
                        obj.storeDataParsoid = Util.booleanOption( opts.dp );
@@ -493,12 +493,12 @@
                        tsr = tsr0;
 
                // Add one NlTk between each pair, hence toks.length-1
-               for (var i = 0, n = toks.length-1; i < n; i++) {
+               for (var i = 0, n = toks.length -1; i < n; i++) {
                        ret.push(toks[i]);
                        var nlTk = new pd.NlTk();
                        if (tsr !== undefined) {
                                tsr += toks[i].length;
-                               nlTk.dataAttribs = { tsr: [tsr, tsr+1] };
+                               nlTk.dataAttribs = { tsr: [tsr, tsr +1] };
                        }
                        ret.push(nlTk);
                }
diff --git a/lib/mediawiki.WikiConfig.js b/lib/mediawiki.WikiConfig.js
index be15739..5c20096 100644
--- a/lib/mediawiki.WikiConfig.js
+++ b/lib/mediawiki.WikiConfig.js
@@ -179,7 +179,7 @@
                        var matches = s.match(regExp);
                        if (matches) {
                                var groups = matches.slice(1);
-                               for (var i=0; i<groups.length; i++) {
+                               for (var i =0; i <groups.length; i++) {
                                        if (groups[i] !== undefined) {
                                                // The interwiki prefix: 'en', 
'de' etc
                                                var key = keys[i];
@@ -535,7 +535,7 @@
                }
                first = false;
                aliases = this._interpolatedMagicWordAliases[option];
-               if (aliases === undefined) { aliases = ['UNKNOWN_'+option]; }
+               if (aliases === undefined) { aliases = ['UNKNOWN_' +option]; }
                regexString += aliases.join( '|' )
                        .replace( /((?:^|\|)(?:[^\$]|\$[^1])*)($|\|)/g, 
'$1$$1$2' )
                        .replace( /\$1/g, '(.*)' );
@@ -613,7 +613,7 @@
                var matches = s.match(regExp);
                if (matches) {
                        var groups = matches.slice(1);
-                       for (var i=0; i<groups.length; i++) {
+                       for (var i =0; i <groups.length; i++) {
                                if (groups[i] !== undefined) {
                                        return [
                                                // The key: 'PMID', 'RFC' etc
diff --git a/lib/mediawiki.WikitextSerializer.js 
b/lib/mediawiki.WikitextSerializer.js
index 422455b..ff32339 100644
--- a/lib/mediawiki.WikitextSerializer.js
+++ b/lib/mediawiki.WikitextSerializer.js
@@ -138,7 +138,7 @@
 WSP._serializeHTMLTag = function ( state, node, wrapperUnmodified ) {
        if (wrapperUnmodified) {
                var dsr = DU.getDataParsoid( node ).dsr;
-               return state.getOrigSrc(dsr[0], dsr[0]+dsr[2]);
+               return state.getOrigSrc(dsr[0], dsr[0] +dsr[2]);
        }
 
        var token = DU.mkTagTk(node);
@@ -169,7 +169,7 @@
 WSP._serializeHTMLEndTag = function ( state, node, wrapperUnmodified ) {
        if (wrapperUnmodified) {
                var dsr = DU.getDataParsoid( node ).dsr;
-               return state.getOrigSrc(dsr[1]-dsr[3], dsr[1]);
+               return state.getOrigSrc(dsr[1] -dsr[3], dsr[1]);
        }
 
        var token = DU.mkEndTagTk(node);
@@ -591,14 +591,14 @@
                                                href = 
firstA.getAttribute('href');
                                                ref = 
node.ownerDocument.querySelector(href);
                                                if (ref) {
-                                                       extraDebug += ' [own 
doc: '+ref.outerHTML+']';
+                                                       extraDebug += ' [own 
doc: ' +ref.outerHTML +']';
                                                }
                                                ref = 
state.env.page.dom.ownerDocument.querySelector(href);
                                                if (ref) {
-                                                       extraDebug += ' [main 
doc: '+ref.outerHTML+']';
+                                                       extraDebug += ' [main 
doc: ' +ref.outerHTML +']';
                                                }
                                                if (!extraDebug) {
-                                                       extraDebug = ' 
[reference '+href+' not found]';
+                                                       extraDebug = ' 
[reference ' +href +' not found]';
                                                }
                                        }
                                        // Bail out of here since we cannot 
meaningfully recover
@@ -1220,7 +1220,7 @@
        var out = pieces[0];
        for (var i = 1; i < pieces.length; i += 4) {
                out += pieces[i];
-               var nowiki = pieces[i+1], rest = pieces[i+2];
+               var nowiki = pieces[i +1], rest = pieces[i +2];
                // Ignore comments
                var htmlTags = rest.match(/<[^!][^<>]*>/g) || [];
 
@@ -1249,7 +1249,7 @@
                if ( !reqd ) {
                        nowiki = nowiki.replace(/^<nowiki>(\s+)<\/nowiki>/, 
'$1');
                }
-               out = out + nowiki + rest + pieces[i+3];
+               out = out + nowiki + rest + pieces[i +3];
        }
        return out;
 }
@@ -1286,40 +1286,40 @@
                var stack = [], quotesOnStack = 0;
                var n = p.length;
                var nowiki = false, ref = false, tag, selfClose;
-               for (var j=1; j<n; j+=2) {
+               for (var j =1; j <n; j +=2) {
                        // For HTML tags, pull out just the tag name for 
clearer code below.
                        tag = (/^<(\/?\w+)/.exec(p[j]) || '' )[1] || p[j];
                        selfClose = false;
                        if (/\/>$/.test(p[j])) { tag += '/'; selfClose = true; }
                        // Ignore <ref>..</ref> sections
-                       if (tag==='ref') { ref = true; continue; }
+                       if (tag ==='ref') { ref = true; continue; }
                        if (ref) {
-                               if (tag==='/ref') { ref = false; }
+                               if (tag ==='/ref') { ref = false; }
                                continue;
                        }
 
                        // Ignore <nowiki>..</nowiki> sections
-                       if (tag==='nowiki') { nowiki = true; continue; }
+                       if (tag ==='nowiki') { nowiki = true; continue; }
                        if (nowiki) {
-                               if (tag==='/nowiki') { nowiki = false; }
+                               if (tag ==='/nowiki') { nowiki = false; }
                                continue;
                        }
 
-                       if (tag===']]') {
-                               if (stack.pop()!=='[[') { return line; }
-                       } else if (tag==='}}') {
-                               if (stack.pop()!=='{{') { return line; }
-                       } else if (tag[0]==='/') { // closing html tag
+                       if (tag ===']]') {
+                               if (stack.pop() !=='[[') { return line; }
+                       } else if (tag ==='}}') {
+                               if (stack.pop() !=='{{') { return line; }
+                       } else if (tag[0] ==='/') { // closing html tag
                                // match html/ext tags
                                var opentag = stack.pop();
-                               if (tag !== ('/'+opentag)) {
+                               if (tag !== ('/' +opentag)) {
                                        return line;
                                }
-                       } else if (tag==='nowiki/') {
+                       } else if (tag ==='nowiki/') {
                                // We only want to process:
                                // - trailing single quotes (bar')
                                // - or single quotes by themselves without a 
preceding '' sequence
-                               if (/'$/.test(p[j-1]) && !(p[j-1]==="'" && 
/''$/.test(p[j-2])) &&
+                               if (/'$/.test(p[j -1]) && !(p[j -1] ==="'" && 
/''$/.test(p[j -2])) &&
                                        // Consider <b>foo<i>bar'</i>baz</b> or 
<b>foo'<i>bar'</i>baz</b>.
                                        // The <nowiki/> before the <i> or </i> 
cannot be stripped
                                        // if the <i> is embedded inside 
another quote.
@@ -1327,11 +1327,11 @@
                                        // The only strippable scenario with a 
single quote elt on stack
                                        // is: ''bar'<nowiki/>''
                                        //   -> ["", "''", "bar'", "<nowiki/>", 
"", "''"]
-                                       || (quotesOnStack===1
-                                               && j+2 < n
-                                               && p[j+1]===""
-                                               && p[j+2][0]==="'"
-                                               && 
p[j+2]===stack[stack.length-1])
+                                       || (quotesOnStack ===1
+                                               && j +2 < n
+                                               && p[j +1] ===""
+                                               && p[j +2][0] ==="'"
+                                               && p[j +2] 
===stack[stack.length -1])
                                        )) {
                                        nowiki_index = j;
                                }
@@ -1342,12 +1342,12 @@
                                //   mediawiki.wikitext.constants.js, <br> is 
the most common
                                //   culprit. )
                                continue;
-                       } else if (tag[0]==="'" && stack[stack.length-1]===tag) 
{
+                       } else if (tag[0] ==="'" && stack[stack.length -1] 
===tag) {
                                stack.pop();
                                quotesOnStack--;
                        } else {
                                stack.push(tag);
-                               if (tag[0]==="'") { quotesOnStack++; }
+                               if (tag[0] ==="'") { quotesOnStack++; }
                        }
                }
 
@@ -1399,7 +1399,7 @@
                        var accum = function(chunk) { out += chunk; };
                        state.emitSepAndOutput(chunk, node, accum, "OUT:");
                        state.atStartOfOutput = false;
-                       if (atEOF==='EOF') {
+                       if (atEOF ==='EOF') {
                                state.flushLine(accum);
                        }
                };
diff --git a/lib/mediawiki.parser.defines.js b/lib/mediawiki.parser.defines.js
index a6eefb7..7fb017e 100644
--- a/lib/mediawiki.parser.defines.js
+++ b/lib/mediawiki.parser.defines.js
@@ -129,7 +129,7 @@
        setAttribute: function ( name, value ) {
                requireUtil();
                // First look for the attribute and change the last match if 
found.
-               for ( var i = this.attribs.length-1; i >= 0; i-- ) {
+               for ( var i = this.attribs.length -1; i >= 0; i-- ) {
                        var kv = this.attribs[i],
                                k = kv.k;
                        if ( k.constructor === String && k.toLowerCase() === 
name ) {
diff --git a/lib/mediawiki.parser.environment.js 
b/lib/mediawiki.parser.environment.js
index 90d174c..26592b7 100644
--- a/lib/mediawiki.parser.environment.js
+++ b/lib/mediawiki.parser.environment.js
@@ -148,7 +148,7 @@
  * @param {String or Object} page source or metadata
  */
 MWParserEnvironment.prototype.setPageSrcInfo = function( src_or_metadata ) {
-       if (typeof (src_or_metadata)==='string' || src_or_metadata===null) {
+       if (typeof (src_or_metadata) ==='string' || src_or_metadata ===null) {
                this.page.meta = { revision: {} };
                this.page.src = src_or_metadata || '';
                return;
diff --git a/lib/mediawiki.parser.js b/lib/mediawiki.parser.js
index 372b5c7..87648b8 100644
--- a/lib/mediawiki.parser.js
+++ b/lib/mediawiki.parser.js
@@ -258,7 +258,7 @@
 
                // connect with previous stage
                if ( i ) {
-                       stage.addListenersOn( stages[i-1] );
+                       stage.addListenersOn( stages[i -1] );
                }
                stages.push( stage );
        }
@@ -291,9 +291,9 @@
                cacheKey += '::attrExpansion';
        }
        if ( options.extTag ) {
-               cacheKey += '::'+options.extTag;
+               cacheKey += '::' +options.extTag;
                if ( options.extTagId ) {
-                       cacheKey += '::'+options.extTagId;
+                       cacheKey += '::' +options.extTagId;
                }
        }
        return cacheKey;
diff --git a/lib/mediawiki.tokenizer.utils.js b/lib/mediawiki.tokenizer.utils.js
index 82a42f5..313d98f 100644
--- a/lib/mediawiki.tokenizer.utils.js
+++ b/lib/mediawiki.tokenizer.utils.js
@@ -197,7 +197,7 @@
                                                stops.onStack('table') && (
                                                        counters.tableCellArg 
|| (
                                                                pos < 
input.length - 1
-                                                               && 
/[}|]/.test(input[pos+1])
+                                                               && 
/[}|]/.test(input[pos +1])
                                                        )
                                                )
                                        );
@@ -246,7 +246,7 @@
                                // So, the /^\n/ part of the regexp is already 
satisfied.
                                // Look for /\s*[!|]/ below.
                                var i, n = input.length;
-                               for (i = pos+1; i < n; i++) {
+                               for (i = pos +1; i < n; i++) {
                                        var d = input[i];
                                        if (/[!|]/.test(d)) {
                                                return true;
diff --git a/lib/pegTokenizer.pegjs.txt b/lib/pegTokenizer.pegjs.txt
index 030b0d9..7d04994 100644
--- a/lib/pegTokenizer.pegjs.txt
+++ b/lib/pegTokenizer.pegjs.txt
@@ -41,7 +41,7 @@
 
             while (i < l) {
                 //console.warn('emitting partial chunk', i);
-                options.cb(tokens.slice(i, i+chunkLimit));
+                options.cb(tokens.slice(i, i + chunkLimit));
                 i += chunkLimit;
             }
         } else {
@@ -356,13 +356,13 @@
             var extras2 = e.substr(0, e.length - level),
                 lastElem = c[c.length - 1];
             if (lastElem.constructor === String) {
-                c[c.length-1] += extras2;
+                c[c.length - 1] += extras2;
             } else {
                 c.push( extras2 );
             }
         }
 
-        return [new TagTk( 'h' + level, [], { tsr: [peg$reportedPos, 
peg$reportedPos+level] } )]
+        return [new TagTk( 'h' + level, [], { tsr: [peg$reportedPos, 
peg$reportedPos + level] } )]
                 .concat(c, [
                         new EndTagTk( 'h' + level, [],
                             { tsr: [endTPos - level, endTPos]} ),
@@ -416,7 +416,7 @@
 autolink
   = ! { return stops.onStack('extlink'); }
     // this must be a word boundary, so previous character must be non-word
-    ! { return /\w/.test(input[peg$currPos-1]||''); }
+    ! { return /\w/.test(input[peg$currPos - 1] || ''); }
   r:(
       // urllink, inlined
       target:autourl {
@@ -458,7 +458,7 @@
                 ], {
                     targetOff: targetOff,
                     tsr: [peg$reportedPos, peg$currPos],
-                    contentOffsets: [targetOff, peg$currPos-1]
+                    contentOffsets: [targetOff, peg$currPos - 1]
                 })
             ];
         }
@@ -609,7 +609,7 @@
     proto += addr || '';
     var url = tu.flatten_stringlist( [proto].concat( path ) );
     // only need to look at last element; HTML entities are strip-proof.
-    var last = url[url.length-1], trim = 0;
+    var last = url[url.length - 1], trim = 0;
     if (last && last.constructor === String) {
       var strip = ',;\\.:!?';
       if (!stops.onStack( 'autourl' ).sawLParen) {
@@ -617,7 +617,7 @@
       }
       strip = new RegExp( '[' + Util.escapeRegExp(strip) + ']*$' );
       trim = strip.exec( last )[0].length;
-      url[url.length-1] = last.slice(0, last.length - trim);
+      url[url.length - 1] = last.slice(0, last.length - trim);
       peg$currPos -= trim;
     }
     stops.pop( 'autourl' );
@@ -856,7 +856,7 @@
       var obj = new SelfclosingTagTk( 'wikilink' ),
           textTokens = [],
           hrefKV = new KV('href', target);
-      hrefKV.vsrc = input.substring(peg$reportedPos+2, tpos);
+      hrefKV.vsrc = input.substring(peg$reportedPos + 2, tpos);
       // XXX: Point to object with path, revision and input information
       //obj.source = input;
       obj.attribs.push(hrefKV);
@@ -1119,7 +1119,7 @@
                     //
                     // Expand extSrc as long as there is a <ref> tag found in 
the
                     // extension source body.
-                    var s = extSrc.substring(peg$currPos-tsr0);
+                    var s = extSrc.substring(peg$currPos - tsr0);
                     while (s && s.match(new RegExp("<" + tagName + 
"[^<>]*>"))) {
                         tagContent = 
restOfInput.substring(extSrc.length).match(endTagRE);
                         if (tagContent) {
@@ -1134,7 +1134,7 @@
 
                 // Extension content source
                 dp.src = extSrc;
-                dp.tagWidths = [peg$currPos-tsr0, endTagWidth];
+                dp.tagWidths = [peg$currPos - tsr0, endTagWidth];
 
                 if ( !isIncludeTag && !isInstalledExt ) {
                     return t;
@@ -1553,7 +1553,7 @@
         li1.bullets = bullets.slice();
         li1.bullets.push(";");
         // TSR: -1 for the intermediate ":"
-        var li2 = new TagTk( 'listItem', [], { tsr: [cpos-1, cpos], stx: 'row' 
} );
+        var li2 = new TagTk( 'listItem', [], { tsr: [cpos - 1, cpos], stx: 
'row' } );
         li2.bullets = bullets.slice();
         li2.bullets.push(":");
 
@@ -1829,7 +1829,7 @@
       if (p !== "|") {
           // p+"<brace-char>" is triggering some bug in pegJS
           // I cannot even use that expression in the comment!
-          tblEnd.dataAttribs.endTagSrc = p+b;
+          tblEnd.dataAttribs.endTagSrc = p + b;
       }
       return sc.concat([tblEnd]);
   }
diff --git a/lib/wts.ConstrainedText.js b/lib/wts.ConstrainedText.js
index 7593090..9cdefb0 100644
--- a/lib/wts.ConstrainedText.js
+++ b/lib/wts.ConstrainedText.js
@@ -138,7 +138,7 @@
                if (!ct) { continue; }
                if (!Array.isArray(ct)) { ct = [ct]; }
                // tag these chunks as coming from selser
-               ct.forEach(function(t) { t.selser=true; });
+               ct.forEach(function(t) { t.selser =true; });
                return ct;
        }
        // ConstrainedText._fromSelSer should handle everything which reaches it
@@ -233,8 +233,8 @@
  */
 var RegExpConstrainedText = function RegExpConstrainedText( args ) {
        RegExpConstrainedText.super_.call(this, args);
-       this.prefix = args.prefix!==undefined ? args.prefix : '<nowiki/>';
-       this.suffix = args.suffix!==undefined ? args.suffix : '<nowiki/>';
+       this.prefix = args.prefix !==undefined ? args.prefix : '<nowiki/>';
+       this.suffix = args.suffix !==undefined ? args.suffix : '<nowiki/>';
        // functions which return true if escape prefix/suffix need to be added
        this.prefixMatcher = args.goodPrefix ? matcher(args.goodPrefix, true) :
                args.badPrefix ? matcher(args.badPrefix, false) : false;
@@ -313,10 +313,10 @@
 var TRAILING_PUNCT = /[,;\\.:!?]/.source.slice(1,-1);
 var NOT_LTGT = /(?!&(lt|gt);)/.source;
 
-var AUTOURL_BAD_PAREN = new RegExp("^"+NOT_LTGT+"[" + TRAILING_PUNCT + "]*[" + 
EXT_LINK_URL_CLASS + TRAILING_PUNCT + "]");
+var AUTOURL_BAD_PAREN = new RegExp("^" +NOT_LTGT +"[" + TRAILING_PUNCT + "]*[" 
+ EXT_LINK_URL_CLASS + TRAILING_PUNCT + "]");
 // if the URL has an doesn't have an open paren in it, TRAILING PUNCT will
 // include ')' as well.
-var AUTOURL_BAD_NOPAREN = new RegExp("^"+NOT_LTGT+"[" + TRAILING_PUNCT + 
"\\)]*[" + EXT_LINK_URL_CLASS + TRAILING_PUNCT + "\\)]");
+var AUTOURL_BAD_NOPAREN = new RegExp("^" +NOT_LTGT +"[" + TRAILING_PUNCT + 
"\\)]*[" + EXT_LINK_URL_CLASS + TRAILING_PUNCT + "\\)]");
 
 var AutoURLLinkText = function AutoURLLinkText(url, node) {
        AutoURLLinkText.super_.call(this, {
@@ -329,8 +329,8 @@
 };
 inherits(AutoURLLinkText, RegExpConstrainedText);
 AutoURLLinkText._fromSelSer = function(text, node, dataParsoid, env) {
-       if ((node.tagName==='A' && dataParsoid.stx === 'url') ||
-               (node.tagName==='IMG' && dataParsoid.type==='extlink')) {
+       if ((node.tagName ==='A' && dataParsoid.stx === 'url') ||
+               (node.tagName ==='IMG' && dataParsoid.type ==='extlink')) {
                return new AutoURLLinkText(text, node);
        }
 };
diff --git a/lib/wts.LinkHandler.js b/lib/wts.LinkHandler.js
index 5e8b09e..f3b887c 100644
--- a/lib/wts.LinkHandler.js
+++ b/lib/wts.LinkHandler.js
@@ -55,7 +55,7 @@
                                bases.push(interwikiInfo.url);
                        }
                });
-               for (i=0; i<bases.length; i++) {
+               for (i =0; i <bases.length; i++) {
                        // evaluate the url relative to this base
                        nhref = url.resolve(bases[i], href);
                        // can this match the pattern?
@@ -199,7 +199,7 @@
                                        
(wiki.interwikiMap.get(normalizeIWP(interWikiMatch[0])) || {}).url
                                        )) {
                                // Reuse old prefix capitalization
-                               if 
(Util.decodeEntities(target.value.substr(oldPrefix[1].length+1)) !== 
interWikiMatch[1]) {
+                               if 
(Util.decodeEntities(target.value.substr(oldPrefix[1].length +1)) !== 
interWikiMatch[1]) {
                                        // Modified, update target.value.
                                        target.value = localPrefix + 
oldPrefix[1] + ':' + interWikiMatch[1];
                                }
@@ -646,7 +646,7 @@
        } else {
                var safeAttr = new Set(["href", "rel", "class", "title"]);
                var isComplexLink = function ( attributes ) {
-                       for ( var i=0; i < attributes.length; i++ ) {
+                       for ( var i =0; i < attributes.length; i++ ) {
                                var attr = attributes.item(i);
                                // XXX: Don't drop rel and class in every case 
once a tags are
                                // actually supported in the MW default config?
@@ -922,7 +922,7 @@
                },
                getLastOpt = function(key) {
                        var o = outerDP.optList || [], i;
-                       for (i=o.length-1; i>=0; i--) {
+                       for (i =o.length -1; i >=0; i--) {
                                if (o[i].ck === key) {
                                        return o[i];
                                }
@@ -961,16 +961,16 @@
                } else {
                        var bbox = null;
                        // Serialize to a square bounding box
-                       if (ww.value!==null && ww.value!=='' && 
ww.value!==undefined) {
+                       if (ww.value !==null && ww.value !=='' && ww.value 
!==undefined) {
                                bbox = +ww.value;
                        }
-                       if (wh.value!==null && wh.value!=='' && 
wh.value!==undefined) {
+                       if (wh.value !==null && wh.value !=='' && wh.value 
!==undefined) {
                                var height = +wh.value;
                                if (bbox === null || height > bbox) {
                                        bbox = height;
                                }
                        }
-                       if (bbox!==null) {
+                       if (bbox !==null) {
                                nopts.push( {
                                        ck: 'width',
                                        // MediaWiki interprets 100px as a 
width restriction only, so
@@ -1059,7 +1059,7 @@
                nopts = nopts.filter(function(no) { return no.ck !== 'bogus'; 
});
                // empty captions should get filtered out in this case, too 
(bug 62264)
                nopts = nopts.filter(function(no) {
-                       return !(no.ck === 'caption' && no.ak==='');
+                       return !(no.ck === 'caption' && no.ak ==='');
                });
        }
 
diff --git a/lib/wts.SerializerState.js b/lib/wts.SerializerState.js
index 930edf6..d246439 100644
--- a/lib/wts.SerializerState.js
+++ b/lib/wts.SerializerState.js
@@ -346,7 +346,7 @@
                                                (/^[\|!]/.test(match[2]) && 
this.wikiTableNesting > 0) ||
                                                // indent-pres are suppressed 
inside <blockquote>
                                                (/^ [^\s]/.test(match[2]) && 
!DU.hasAncestorOfName(node, "BLOCKQUOTE"))) {
-                                               res = 
ConstrainedText.cast((match[1]||"") + "<nowiki>" + match[2][0] + "</nowiki>" + 
match[2].substring(1), node);
+                                               res = 
ConstrainedText.cast((match[1] ||"") + "<nowiki>" + match[2][0] + "</nowiki>" + 
match[2].substring(1), node);
                                        }
                                }
                        }
diff --git a/lib/wts.TagHandlers.js b/lib/wts.TagHandlers.js
index 00dd3c2..dc5ed2c 100644
--- a/lib/wts.TagHandlers.js
+++ b/lib/wts.TagHandlers.js
@@ -488,7 +488,7 @@
 function serializeTableTag( symbol, endSymbol, state, node, wrapperUnmodified 
) {
        if (wrapperUnmodified) {
                var dsr = DU.getDataParsoid( node ).dsr;
-               return state.getOrigSrc(dsr[0], dsr[0]+dsr[2]);
+               return state.getOrigSrc(dsr[0], dsr[0] +dsr[2]);
        } else {
                return serializeTableElement(symbol, endSymbol, state, node);
        }
diff --git a/lib/wts.escapeWikitext.js b/lib/wts.escapeWikitext.js
index ecdf1d0..1167017 100644
--- a/lib/wts.escapeWikitext.js
+++ b/lib/wts.escapeWikitext.js
@@ -42,7 +42,7 @@
                        line = text;
                }
                return line[0] === '=' &&
-                       text && text.length > 0 && text[text.length-1] === '=';
+                       text && text.length > 0 && text[text.length -1] === '=';
        } else {
                return false;
        }
@@ -55,7 +55,7 @@
 
        // For <dt> nodes, ":" trigger nowiki outside of elements
        // For first nodes of <li>'s, bullets in sol posn trigger escaping
-       if (liNode.nodeName === 'DT'&& /:/.test(text)) {
+       if (liNode.nodeName === 'DT' && /:/.test(text)) {
                return true;
        } else if (state.currLine.text === '' && 
this.isFirstContentNode(opts.node)) {
                return text.match(/^[#\*:;]/);
@@ -200,7 +200,7 @@
                        text.match(/^[\-+]/) &&
                        opts.node && DU.pathToAncestor(opts.node, 
tdNode).every(function(n) {
                                return this.isFirstContentNode(n) &&
-                                       (n===opts.node || 
DU.isZeroWidthWikitextElt(n));
+                                       (n ===opts.node || 
DU.isZeroWidthWikitextElt(n));
                        }, this)
                ));
 };
@@ -410,8 +410,8 @@
                                buf += str;
 
                                if (close) {
-                                       if ((i < numToks-1 && 
tokens[i+1].constructor === String && tokens[i+1].length >= 
maxExcessWrapLength) ||
-                                               (i === numToks-2 && 
tokens[i+1].constructor === String)) {
+                                       if ((i < numToks -1 && tokens[i 
+1].constructor === String && tokens[i +1].length >= maxExcessWrapLength) ||
+                                               (i === numToks -2 && tokens[i 
+1].constructor === String)) {
                                                buf += "</nowiki>";
                                                inNowiki = false;
                                        }
diff --git a/tests/client/client.js b/tests/client/client.js
index 25c9cb5..25aedd7 100755
--- a/tests/client/client.js
+++ b/tests/client/client.js
@@ -214,7 +214,7 @@
                        break;
 
                default:
-                       console.assert(false, 'Bad callback argument: '+which);
+                       console.assert(false, 'Bad callback argument: ' +which);
        }
 };
 
diff --git a/tests/fetch-parserTests.txt.js b/tests/fetch-parserTests.txt.js
index e73b36b..d6320b6 100755
--- a/tests/fetch-parserTests.txt.js
+++ b/tests/fetch-parserTests.txt.js
@@ -29,7 +29,7 @@
        host: downloadUrl.host,
        path: 
'/history/mediawiki%2Fcore.git/HEAD/tests%2Fparser%2FparserTests.txt'
 };
-var target_name = __dirname+"/parserTests.txt";
+var target_name = __dirname +"/parserTests.txt";
 
 var computeSHA1 = function(target_name) {
        var existsSync = fs.existsSync || path.existsSync; // node 0.6 compat
@@ -119,9 +119,9 @@
                var contents = fs.
                        readFileSync(__filename, 'utf8').
                        replace(/^var expectedSHA1 = "[0-9a-f]*";/m,
-                                       "var expectedSHA1 = \""+fileHash+"\";").
+                                       "var expectedSHA1 = \"" +fileHash 
+"\";").
                        replace(/^var latestCommit = "[0-9a-f]*";/m,
-                                       "var latestCommit = 
\""+gitCommit+"\";");
+                                       "var latestCommit = \"" +gitCommit 
+"\";");
                fs.writeFileSync(__filename, contents, 'utf8');
                console.log('Updated fetch-parserTests.txt.js');
        };
diff --git a/tests/mocha/parse.js b/tests/mocha/parse.js
index d9e2e4d..2651681 100644
--- a/tests/mocha/parse.js
+++ b/tests/mocha/parse.js
@@ -85,7 +85,7 @@
                });
 
                ['no subpages', 'subpages'].forEach(function(desc, subpages) {
-                       describe('should handle page titles with embedded ? 
('+desc+')', function() {
+                       describe('should handle page titles with embedded ? (' 
+desc +')', function() {
                                var linktests = [{
                                        wikitext: '[[Foo?/Bar]]',
                                        href: 
'//en.wikipedia.org/wiki/Foo%3F/Bar',
@@ -236,7 +236,7 @@
                                // now check the <meta> elements
                                els = doc.querySelectorAll('META[property]');
                                var o = {}, prop;
-                               for (var i=0; i<els.length; i++) {
+                               for (var i =0; i <els.length; i++) {
                                        prop = els[i].getAttribute('property');
                                        o.should.not.have.property(prop);
                                        o[prop] = 
els[i].getAttribute('content');
diff --git a/tests/parserTests.js b/tests/parserTests.js
index bfb8fc6..a6cf0f4 100755
--- a/tests/parserTests.js
+++ b/tests/parserTests.js
@@ -128,8 +128,8 @@
                return JSON.stringify(v);
        };
        return Object.keys(iopts).map(function(k) {
-               if (iopts[k]==='') { return k; }
-               return k+'='+ppValue(iopts[k]);
+               if (iopts[k] ==='') { return k; }
+               return k +'=' +ppValue(iopts[k]);
        }).join(' ');
 };
 
@@ -302,7 +302,7 @@
  */
 ParserTests.prototype.getTests = function ( argv ) {
        // double check that test file is up-to-date with upstream
-       var fetcher = require(__dirname+"/fetch-parserTests.txt.js");
+       var fetcher = require(__dirname +"/fetch-parserTests.txt.js");
        if (!fetcher.isUpToDate()) {
                parserTestsUpToDate = false;
                console.warn("warning", "ParserTests.txt not up-to-date with 
upstream.");
@@ -332,7 +332,7 @@
 
        var sha1 = require('crypto').createHash('sha1')
                .update( mtimes ).digest( 'hex' ),
-               cache_file_name= __dirname + '/' + this.cache_file,
+               cache_file_name = __dirname + '/' + this.cache_file,
                // Look for a cache_file
                cache_content,
                cache_file_digest;
@@ -734,7 +734,7 @@
                                if ( nodeIsUneditable(child) || random() < 0.5 
) {
                                        changeType = genChangesInternal(
                                                // ensure the subtree has a seed
-                                               { seed: ''+random.uint32() },
+                                               { seed: '' +random.uint32() },
                                                child );
                                } else {
                                        if ( !child.setAttribute ) {
@@ -832,7 +832,7 @@
        changes.forEach(function(change) {
                if (err) { return; }
                if (change.length < 2) {
-                       err = new Error('bad change: '+change);
+                       err = new Error('bad change: ' +change);
                        return;
                }
                // use document.querySelectorAll as a poor man's $(...)
@@ -850,7 +850,7 @@
                }
                var fun = jquery[change[1]];
                if (!fun) {
-                       err = new Error('bad mutator function: '+change[1]);
+                       err = new Error('bad mutator function: ' +change[1]);
                        return;
                }
                Array.prototype.forEach.call(els, function(el) {
@@ -1500,7 +1500,7 @@
                console.log( colorizeCount( stats.passedTests + 
stats.passedTestsWhitelisted, 'green' ) +
                             ' total passed tests (expected ' +
                             (stats.passedTests + stats.passedTestsWhitelisted 
- stats.passedTestsUnexpected + stats.failedTestsUnexpected) +
-                            '), '+
+                            '), ' +
                             colorizeCount( failTotalTests , 'red'   ) + ' 
total failures (expected ' +
                             (stats.failedTests - stats.failedTestsUnexpected + 
stats.passedTestsUnexpected) +
                             ')' );
@@ -2049,18 +2049,18 @@
 
                // update the blacklist, if requested
                if (booleanOption( options['rewrite-blacklist'] )) {
-                       var filename = __dirname+'/parserTests-blacklist.js';
+                       var filename = __dirname +'/parserTests-blacklist.js';
                        var shell = fs.readFileSync(filename, 'utf8').
                                split(/^.*DO NOT REMOVE THIS LINE.*$/m);
                        var contents = shell[0];
                        contents += '// ### DO NOT REMOVE THIS LINE ### ';
                        contents += '(start of automatically-generated 
section)\n';
                        modes.forEach(function(mode) {
-                               contents += '\n// Blacklist for '+mode+'\n';
+                               contents += '\n// Blacklist for ' +mode +'\n';
                                
this.stats.modes[mode].failList.forEach(function(fail) {
-                                       contents += 
'add('+JSON.stringify(mode)+', '+
+                                       contents += 'add(' 
+JSON.stringify(mode) +', ' +
                                                JSON.stringify(fail.title);
-                                       contents += ', 
'+JSON.stringify(fail.raw);
+                                       contents += ', ' 
+JSON.stringify(fail.raw);
                                        contents += ');\n';
                                });
                                contents += '\n';
diff --git a/tests/server/diff.js b/tests/server/diff.js
index 0cac9d3..eaf81e1 100644
--- a/tests/server/diff.js
+++ b/tests/server/diff.js
@@ -86,7 +86,7 @@
 
                var results = [];
                for (var i = 0, l = testcases.length - 1; i < l; i++) {
-                       if (i%2 === 0 && statusArray[i/2]) {
+                       if (i %2 === 0 && statusArray[i /2]) {
                                testcases[i] = 
testcases[i].replace('<testcase', '<testcase status="' + status + '"');
                        }
                        results.push(testcases[i]);
diff --git a/tests/server/server.js b/tests/server/server.js
index 24f1fe4..e4507d2 100755
--- a/tests/server/server.js
+++ b/tests/server/server.js
@@ -236,9 +236,9 @@
                'pages.latest_stat = stats.id) as avgscore, ' +
        'count(*) AS total, ' +
        'count(CASE WHEN stats.errors=0 THEN 1 ELSE NULL END) AS no_errors, ' +
-       'count(CASE WHEN stats.errors=0 AND stats.fails=0 '+
+       'count(CASE WHEN stats.errors=0 AND stats.fails=0 ' +
                'then 1 else null end) AS no_fails, ' +
-       'count(CASE WHEN stats.errors=0 AND stats.fails=0 AND stats.skips=0 '+
+       'count(CASE WHEN stats.errors=0 AND stats.fails=0 AND stats.skips=0 ' +
                'then 1 else null end) AS no_skips, ' +
        // get regression count between last two commits
        '(SELECT count(*) ' +
@@ -291,9 +291,9 @@
                'pages.latest_stat = stats.id where pages.prefix = ?) as 
avgscore, ' +
        'count(*) AS total, ' +
        'count(CASE WHEN stats.errors=0 THEN 1 ELSE NULL END) AS no_errors, ' +
-       'count(CASE WHEN stats.errors=0 AND stats.fails=0 '+
+       'count(CASE WHEN stats.errors=0 AND stats.fails=0 ' +
                'then 1 else null end) AS no_fails, ' +
-       'count(CASE WHEN stats.errors=0 AND stats.fails=0 AND stats.skips=0 '+
+       'count(CASE WHEN stats.errors=0 AND stats.fails=0 AND stats.skips=0 ' +
                'then 1 else null end) AS no_skips, ' +
        // get regression count between last two commits
        '(SELECT count(*) ' +
@@ -599,7 +599,7 @@
 var statsScore = function(skipCount, failCount, errorCount) {
        // treat <errors,fails,skips> as digits in a base 1000 system
        // and use the number as a score which can help sort in topfails.
-       return errorCount*1000000+failCount*1000+skipCount;
+       return errorCount *1000000 +failCount *1000 +skipCount;
 };
 
 var transUpdateCB = function( title, prefix, hash, type, res, trans, 
success_cb, err, result ) {
@@ -793,7 +793,7 @@
                numRegressions = row[0].numregressions,
                numFixes = row[0].numfixes,
                noErrors = Math.round( 100 * 100 * errorLess / ( tests || 1 ) ) 
/ 100,
-               perfects = Math.round( 100* 100 * skipLess / ( tests || 1 ) ) / 
100,
+               perfects = Math.round( 100 * 100 * skipLess / ( tests || 1 ) ) 
/ 100,
                syntacticDiffs = Math.round( 100 * 100 *
                        ( row[0].no_fails / ( tests || 1 ) ) ) / 100;
 
@@ -1114,14 +1114,14 @@
                                var row = rows[i];
                                var tableRow = {hash: row.hash, timestamp: 
row.timestamp};
                                if ( i + 1 < n ) {
-                                       tableRow.regUrl = 
'regressions/between/' + rows[i+1].hash + '/' + row.hash;
-                                       tableRow.fixUrl = 'topfixes/between/' + 
rows[i+1].hash + '/' + row.hash;
+                                       tableRow.regUrl = 
'regressions/between/' + rows[i +1].hash + '/' + row.hash;
+                                       tableRow.fixUrl = 'topfixes/between/' + 
rows[i +1].hash + '/' + row.hash;
                                }
                                tableRows.push(tableRow);
                        }
                        var data = {
                                numCommits: n,
-                               latest: 
rows[n-1].timestamp.toString().slice(4,15),
+                               latest: rows[n 
-1].timestamp.toString().slice(4,15),
                                header: ['Commit hash', 'Timestamp', 'Tests', 
'-', '+'],
                                row: tableRows
                        };
diff --git a/tests/server/static/js/commitList.js 
b/tests/server/static/js/commitList.js
index 97b0b8f..77f7d55 100644
--- a/tests/server/static/js/commitList.js
+++ b/tests/server/static/js/commitList.js
@@ -10,7 +10,7 @@
        };
 
        var button = function(name, index) {
-               return $('.revisions tr:eq(' + index + ') .buttons 
input[name="'+ name + '"]');
+               return $('.revisions tr:eq(' + index + ') .buttons 
input[name="' + name + '"]');
        };
 
        var buttonDisplay = function(name, index, visibility) {
@@ -26,7 +26,7 @@
                button('new', 0).attr('checked', 'checked');
                button('old', 1).attr('checked', 'checked');
                buttonDisplay('old', 0, 'hidden');
-               for (var i=1; i < numRows; i++) {
+               for (var i =1; i < numRows; i++) {
                        buttonDisplay('new', i, 'hidden');
                }
        };
@@ -40,7 +40,7 @@
                }
                setCompareLinks(oldHash, newHash);
                var index = $(this).closest('tr').index();
-               for (var i=0; i < numRows; i++) {
+               for (var i =0; i < numRows; i++) {
                        if (name === 'old' && i < index) {
                                buttonDisplay('new', i, 'visible');
                        } else if (name === 'old') {
diff --git a/tests/sync-parserTests.js b/tests/sync-parserTests.js
index 6436017..f5f5cc2 100755
--- a/tests/sync-parserTests.js
+++ b/tests/sync-parserTests.js
@@ -126,7 +126,7 @@
 // Make a new mediawiki/core commit with an appropriate message.
 q.push(function(callback) {
        var commitmsg = 'Sync up with Parsoid parserTests.';
-       commitmsg += '\n\nThis now aligns with Parsoid commit '+phash;
+       commitmsg += '\n\nThis now aligns with Parsoid commit ' +phash;
        mwexec(['git','commit','-m', commitmsg, mwPARSERTESTS])(callback);
 });
 

-- 
To view, visit https://gerrit.wikimedia.org/r/202241
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I13df3896e8130743eb31581e80d4c7909e48768d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/parsoid
Gerrit-Branch: master
Gerrit-Owner: Arlolra <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to