jenkins-bot has submitted this change and it was merged. Change subject: [jscs] Enforce disallowSpaceAfterPrefixUnaryOperators ......................................................................
[jscs] Enforce disallowSpaceAfterPrefixUnaryOperators * This was auto-corrected with jscs -x . Change-Id: I14f086c819b4baa6b76ecf7becce7df30d277b93 --- M .jscsrc M lib/ext.core.LinkHandler.js M lib/ext.core.NoIncludeOnly.js M lib/ext.core.ParserFunctions.js M lib/ext.core.QuoteTransformer.js M lib/ext.core.Sanitizer.js M lib/ext.core.TemplateHandler.js M lib/jsutils.js M lib/mediawiki.DOMDiff.js M lib/mediawiki.DOMUtils.js M lib/mediawiki.TokenTransformManager.js M lib/mediawiki.Util.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/wts.separators.js M tests/parserTests.js 19 files changed, 48 insertions(+), 49 deletions(-) Approvals: Subramanya Sastry: Looks good to me, approved jenkins-bot: Verified diff --git a/.jscsrc b/.jscsrc index 0360ed2..88d6185 100644 --- a/.jscsrc +++ b/.jscsrc @@ -5,7 +5,6 @@ "disallowMultipleVarDecl": null, "disallowQuotedKeysInObjects": null, "disallowSpaceAfterObjectKeys": null, - "disallowSpaceAfterPrefixUnaryOperators": null, "disallowSpacesInFunction": null, "disallowSpacesInsideParentheses": null, "maximumLineLength": null, diff --git a/lib/ext.core.LinkHandler.js b/lib/ext.core.LinkHandler.js index 7846486..88dbd97 100644 --- a/lib/ext.core.LinkHandler.js +++ b/lib/ext.core.LinkHandler.js @@ -618,7 +618,7 @@ */ function getWrapperInfo( opts ) { var format = getFormat( opts ), - isInline = ! (format === 'thumbnail' + isInline = !(format === 'thumbnail' || format === 'framed'), wrapperStyles = [], wrapperClasses = [], diff --git a/lib/ext.core.NoIncludeOnly.js b/lib/ext.core.NoIncludeOnly.js index 515f1ff..9fd6dc5 100644 --- a/lib/ext.core.NoIncludeOnly.js +++ b/lib/ext.core.NoIncludeOnly.js @@ -85,7 +85,7 @@ if ( token.constructor === EOFTk ) { this.inOnlyInclude = false; - if ( this.accum.length && ! this.foundOnlyInclude ) { + if ( this.accum.length && !this.foundOnlyInclude ) { var res = this.accum; res.push( token ); this.accum = []; @@ -117,7 +117,7 @@ curriedBuildMetaToken = buildMetaToken.bind( null, manager, tagName ); if ( isTag && token.name === 'onlyinclude' ) { - if ( ! this.inOnlyInclude ) { + if ( !this.inOnlyInclude ) { this.foundOnlyInclude = true; this.inOnlyInclude = true; // wrap collected tokens into meta tag for round-tripping diff --git a/lib/ext.core.ParserFunctions.js b/lib/ext.core.ParserFunctions.js index 75b6366..172c39f 100644 --- a/lib/ext.core.ParserFunctions.js +++ b/lib/ext.core.ParserFunctions.js @@ -153,7 +153,7 @@ // skip entries with keys or empty values continue; } else { - if ( ! kv.v.get ) { + if ( !kv.v.get ) { this.env.ap( kv.v ); console.trace(); } @@ -208,7 +208,7 @@ return; } else if ( kvs.length ) { var lastKV = kvs[kvs.length - 1]; - if ( lastKV && ! lastKV.k.length ) { + if ( lastKV && !lastKV.k.length ) { lastKV.v.get( { cb: _cbNoTrim, asyncCB: cb } ); @@ -355,7 +355,7 @@ ParserFunctions.prototype.pf_padleft = function ( token, frame, cb, params ) { var target = params[0].k, env = this.env; - if ( ! params[1] ) { + if ( !params[1] ) { return cb( {} ); } // expand parameters 1 and 2 @@ -388,7 +388,7 @@ ParserFunctions.prototype.pf_padright = function ( token, frame, cb, params ) { var target = params[0].k, env = this.env; - if ( ! params[1] ) { + if ( !params[1] ) { return cb( {} ); } // expand parameters 1 and 2 diff --git a/lib/ext.core.QuoteTransformer.js b/lib/ext.core.QuoteTransformer.js index e9645e2..9cebb54 100644 --- a/lib/ext.core.QuoteTransformer.js +++ b/lib/ext.core.QuoteTransformer.js @@ -56,7 +56,7 @@ QuoteTransformer.prototype.onQuote = function ( token, frame, prevToken ) { var qlen = token.value.length; - if ( ! this.isActive ) { + if ( !this.isActive ) { this.dispatcher.addTransform( this.onNewLine.bind(this), "QuoteTransformer:onNewLine", this.quoteAndNewlineRank, 'newline' ); // Treat 'th' just the same as a newline @@ -97,7 +97,7 @@ QuoteTransformer.prototype.onNewLine = function ( token, frame, prevToken ) { var res, qlen, i; - if ( ! this.isActive ) { + if ( !this.isActive ) { // Nothing to do, quick abort. return { token: token }; } diff --git a/lib/ext.core.Sanitizer.js b/lib/ext.core.Sanitizer.js index 603a420..87379e7 100644 --- a/lib/ext.core.Sanitizer.js +++ b/lib/ext.core.Sanitizer.js @@ -642,7 +642,7 @@ proto = bits[1]; host = bits[2]; path = bits[3]; - if ( ! proto.match(this.manager.env.conf.wiki.protocolRegex)) { + if ( !proto.match(this.manager.env.conf.wiki.protocolRegex)) { // invalid proto, disallow URL return null; } diff --git a/lib/ext.core.TemplateHandler.js b/lib/ext.core.TemplateHandler.js index 270d1b9..5701376 100644 --- a/lib/ext.core.TemplateHandler.js +++ b/lib/ext.core.TemplateHandler.js @@ -510,7 +510,7 @@ target = attribs[0].k, self = this; - if ( ! target ) { + if ( !target ) { env.ap( 'No target! ', attribs ); console.trace(); } @@ -1082,7 +1082,7 @@ if ( title in env.pageCache ) { // XXX: store type too (and cache tokens/x-mediawiki) cb(null, env.pageCache[title] /* , type */ ); - } else if ( ! env.conf.parsoid.fetchTemplates ) { + } else if ( !env.conf.parsoid.fetchTemplates ) { // TODO: Set mw:Error and provide error info in data-mw // see https://bugzilla.wikimedia.org/show_bug.cgi?id=48900 var spanStart = new TagTk( 'span', [ @@ -1127,7 +1127,7 @@ if ( text in env.pageCache ) { // XXX: store type too (and cache tokens/x-mediawiki) cb(null, env.pageCache[text] /* , type */ ); - } else if ( ! env.conf.parsoid.fetchTemplates ) { + } else if ( !env.conf.parsoid.fetchTemplates ) { parentCB( { tokens: [ 'Warning: Page/template fetching disabled, and no cache for ' + text] }); } else { diff --git a/lib/jsutils.js b/lib/jsutils.js index d40de90..892b5b8 100644 --- a/lib/jsutils.js +++ b/lib/jsutils.js @@ -20,7 +20,7 @@ deepFreeze: function (o) { if ( o === undefined ) { return; - } else if ( ! (o instanceof Object) ) { + } else if ( !(o instanceof Object) ) { //console.log( o ); //console.trace(); return; diff --git a/lib/mediawiki.DOMDiff.js b/lib/mediawiki.DOMDiff.js index 9a05e5b..97ac597 100644 --- a/lib/mediawiki.DOMDiff.js +++ b/lib/mediawiki.DOMDiff.js @@ -43,7 +43,7 @@ // The root nodes are equal, call recursive differ this.debug('ORIG:\n', this.env.page.dom.outerHTML, '\nNEW :\n', workNode.outerHTML ); var foundChange = this.doDOMDiff(this.env.page.dom, workNode); - return { isEmpty: ! foundChange, dom: workNode }; + return { isEmpty: !foundChange, dom: workNode }; }; // These attributes are ignored for equality purposes if they are added to a node. @@ -203,7 +203,7 @@ dontAdvanceNewNode = false; debugOut(baseNode, newNode); // shallow check first - if ( ! this.treeEquals(baseNode, newNode, false) ) { + if ( !this.treeEquals(baseNode, newNode, false) ) { this.debug("-- not equal --"); var savedNewNode = newNode, foundDiff = false; diff --git a/lib/mediawiki.DOMUtils.js b/lib/mediawiki.DOMUtils.js index d3c7670..a0d8e74 100644 --- a/lib/mediawiki.DOMUtils.js +++ b/lib/mediawiki.DOMUtils.js @@ -2393,7 +2393,7 @@ * @returns {Node} */ DOMUtils.parseHTML = function ( html ) { - if (! html.match(/^<(?:!doctype|html|body)/i)) { + if (!html.match(/^<(?:!doctype|html|body)/i)) { // Make sure that we parse fragments in the body. Otherwise comments, // link and meta tags end up outside the html element or in the head // element. diff --git a/lib/mediawiki.TokenTransformManager.js b/lib/mediawiki.TokenTransformManager.js index 1c08048..b91488c 100644 --- a/lib/mediawiki.TokenTransformManager.js +++ b/lib/mediawiki.TokenTransformManager.js @@ -379,7 +379,7 @@ } // Emit or append the returned tokens - if ( ! this.tailAccumulator ) { + if ( !this.tailAccumulator ) { this.env.dp( 'emitting' ); this.emit( 'chunk', res.tokens ); } else { @@ -560,7 +560,7 @@ // Token type special cases -- FIXME: why do we have this? if ( Array.isArray(token) ) { - if ( ! token.length ) { + if ( !token.length ) { // skip it /* jshint noempty: false */ } else if ( token.rank >= this.phaseEndRank ) { @@ -578,7 +578,7 @@ //this.env.dp( 'async token:', accumChain.state.c, token, minRank, ts ); - if ( ! ts.length ) { + if ( !ts.length ) { // nothing to do for this token accumChain.push( token ); } else { @@ -614,13 +614,13 @@ break; } - if ( token === soleToken && ! resTokens.rank ) { + if ( token === soleToken && !resTokens.rank ) { // token not modified, continue with transforms. continue; } else if ( resTokens.rank === this.phaseEndRank || ( soleToken.constructor === String && - ! this.tokenTransformers.text ) ) { + !this.tokenTransformers.text ) ) { // Fast path for text token, and nothing to do for it // Abort processing, but treat token as done. token = soleToken; @@ -634,7 +634,7 @@ // Could be fixed. // // token(s) were potentially modified - if ( ! resTokens.rank || resTokens.rank < this.phaseEndRank ) { + if ( !resTokens.rank || resTokens.rank < this.phaseEndRank ) { // There might still be something to do for these // tokens. Prepare them for the workStack. resTokens = resTokens.slice(); @@ -753,8 +753,8 @@ tokens = ret.tokens; if ( tokens ) { if ( tokens.length && - ( ! tokens.rank || tokens.rank < this.phaseEndRank ) && - ! ( tokens.length === 1 && tokens[0].constructor === String ) ) { + ( !tokens.rank || tokens.rank < this.phaseEndRank ) && + !( tokens.length === 1 && tokens[0].constructor === String ) ) { // Re-process incomplete tokens this.env.dp( 'maybeSyncReturn: recursive transformTokens', this.frame.title, ret.tokens ); @@ -772,7 +772,7 @@ // in this chain, and the new chain will pass its results to // the former parent accumulator. - if ( ! ret.async ) { + if ( !ret.async ) { // There will be no more input to the child pipeline res.asyncAccum.siblingDone(); @@ -1364,7 +1364,7 @@ // We are now dealing with an Array of tokens. See if the chunk is // a source chunk with a cache attached. - if ( ! chunk.length ) { + if ( !chunk.length ) { // nothing to do return cb( chunk ); } diff --git a/lib/mediawiki.Util.js b/lib/mediawiki.Util.js index 9e64534..a004dbd 100644 --- a/lib/mediawiki.Util.js +++ b/lib/mediawiki.Util.js @@ -789,7 +789,7 @@ }, lookupKV: function ( kvs, key ) { - if ( ! kvs ) { + if ( !kvs ) { return null; } var kv; @@ -810,7 +810,7 @@ }, lookupValue: function ( kvs, key ) { - if ( ! kvs ) { + if ( !kvs ) { return null; } var kv; @@ -830,7 +830,7 @@ * duplicate keys, the last entry wins. */ KVtoHash: function ( kvs, convertValuesToString ) { - if ( ! kvs ) { + if ( !kvs ) { console.warn( "Invalid kvs!: " + JSON.stringify( kvs, null, 2 ) ); return Object.create(null); } @@ -918,7 +918,7 @@ if ( !Array.isArray(tokens) ) { tokens = [ tokens ]; } - if ( ! tokens.length ) { + if ( !tokens.length ) { return tokens; } // Strip 'end' token diff --git a/lib/mediawiki.WikitextSerializer.js b/lib/mediawiki.WikitextSerializer.js index 086898b..e5b6c17 100644 --- a/lib/mediawiki.WikitextSerializer.js +++ b/lib/mediawiki.WikitextSerializer.js @@ -723,7 +723,7 @@ && /(?:^|\s)mw:Extension\/references(?:\s|$)/ .test(node.getAttribute('typeof')) // Only apply to plain references tags - && ! /(?:^|\s)mw:Transclusion(?:\s|$)/ + && !/(?:^|\s)mw:Transclusion(?:\s|$)/ .test(node.getAttribute('typeof'))) { // Serialize new references tags on a new line return {min: 1, max: 2}; diff --git a/lib/mediawiki.parser.defines.js b/lib/mediawiki.parser.defines.js index b9d22f9..a6eefb7 100644 --- a/lib/mediawiki.parser.defines.js +++ b/lib/mediawiki.parser.defines.js @@ -57,11 +57,11 @@ var setShadowInfo = function ( name, value, origValue ) { // Don't shadow if value is the same or the orig is null if ( value !== origValue && origValue !== null ) { - if ( ! this.dataAttribs.a ) { + if ( !this.dataAttribs.a ) { this.dataAttribs.a = {}; } this.dataAttribs.a[name] = value; - if ( ! this.dataAttribs.sa ) { + if ( !this.dataAttribs.sa ) { this.dataAttribs.sa = {}; } if ( origValue !== undefined ) { @@ -217,8 +217,8 @@ var kv = this.attribs[i]; if ( kv.k.toLowerCase() !== name ) { out.push( kv ); - } else if ( ! found ) { - if ( ! this.dataAttribs.a || + } else if ( !found ) { + if ( !this.dataAttribs.a || this.dataAttribs.a[name] === undefined ) { this.setShadowInfo( name, value, kv.v ); } @@ -229,7 +229,7 @@ // else strip it.. } out.reverse(); - if ( ! found ) { + if ( !found ) { out.push( new KV( name, value ) ); } this.attribs = out; diff --git a/lib/mediawiki.parser.environment.js b/lib/mediawiki.parser.environment.js index 3d44140..90d174c 100644 --- a/lib/mediawiki.parser.environment.js +++ b/lib/mediawiki.parser.environment.js @@ -345,7 +345,7 @@ name = name.trim(); - if ( ! noUnderScores ) { + if ( !noUnderScores ) { name = name.replace(/[\s_]+/g, '_'); } diff --git a/lib/mediawiki.parser.js b/lib/mediawiki.parser.js index cbb449a..372b5c7 100644 --- a/lib/mediawiki.parser.js +++ b/lib/mediawiki.parser.js @@ -210,7 +210,7 @@ options = this.defaultOptions(options); var recipe = this.recipes[type]; - if ( ! recipe ) { + if ( !recipe ) { console.trace(); throw( 'Error while trying to construct pipeline for ' + type ); } @@ -272,10 +272,10 @@ function getCacheKey(cacheKey, options) { cacheKey = cacheKey || ''; - if ( ! options.isInclude ) { + if ( !options.isInclude ) { cacheKey += '::noInclude'; } - if ( ! options.wrapTemplates ) { + if ( !options.wrapTemplates ) { cacheKey += '::noWrap'; } if ( options.noPre ) { @@ -345,7 +345,7 @@ options = this.defaultOptions(options); var cacheKey = getCacheKey(type, options); - if ( ! this.pipelineCache[cacheKey] ) { + if ( !this.pipelineCache[cacheKey] ) { this.pipelineCache[cacheKey] = []; } var pipe; diff --git a/lib/mediawiki.tokenizer.utils.js b/lib/mediawiki.tokenizer.utils.js index 363e176..82a42f5 100644 --- a/lib/mediawiki.tokenizer.utils.js +++ b/lib/mediawiki.tokenizer.utils.js @@ -205,7 +205,7 @@ // {{!}} pipe templates.. return ( ( stops.onStack( 'pipe' ) && - ! counters.template && + !counters.template && input.substr(pos, 5) === '{{!}}' ) || ( stops.onStack( 'table' ) && ( @@ -220,9 +220,9 @@ return counters.template && input[pos + 1] === "}"; case ":": return counters.colon && - ! stops.onStack( 'extlink' ) && - ! stops.onCount( 'templatedepth' ) && - ! counters.linkdesc; + !stops.onStack( 'extlink' ) && + !stops.onCount( 'templatedepth' ) && + !counters.linkdesc; case "\r": return stops.onStack( 'table' ) && /\r\n?\s*[!|]/.test(input.substr(pos)); diff --git a/lib/wts.separators.js b/lib/wts.separators.js index 8bb25ce..05626b6 100644 --- a/lib/wts.separators.js +++ b/lib/wts.separators.js @@ -205,7 +205,7 @@ sepNlCount = sepMatch && sepMatch.length || 0, minNls = nlConstraints.min || 0; - if (state.atStartOfOutput && ! nlConstraints.a.min && minNls > 0) { + if (state.atStartOfOutput && !nlConstraints.a.min && minNls > 0) { // Skip first newline as we are in start-of-line context minNls--; } diff --git a/tests/parserTests.js b/tests/parserTests.js index 5c74799..bfb8fc6 100755 --- a/tests/parserTests.js +++ b/tests/parserTests.js @@ -929,7 +929,7 @@ this.env.conf.wiki.allowExternalImages = [ '' ]; // all allowed if ( item.options.wgallowexternalimages !== undefined && - ! /^(1|true|)$/.test(item.options.wgallowexternalimages) ) { + !/^(1|true|)$/.test(item.options.wgallowexternalimages) ) { this.env.conf.wiki.allowExternalImages = undefined; } } -- To view, visit https://gerrit.wikimedia.org/r/202072 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I14f086c819b4baa6b76ecf7becce7df30d277b93 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/services/parsoid Gerrit-Branch: master Gerrit-Owner: Arlolra <abrea...@wikimedia.org> Gerrit-Reviewer: Cscott <canan...@wikimedia.org> Gerrit-Reviewer: Subramanya Sastry <ssas...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits