Hygiene: use object shorthand where obvious

Approximately:

  find \
    -not \( \( -name node_modules -o -name .git -o -name vendor -o -name doc -o -name resources \) -prune \) \
    -iname \*.js|
  xargs -rd\\n sed -ri 's%(\b\S+\b)\s*:\s*\b\1\b%\1%g'

Bug: T165036
Change-Id: I48869dc93b66f908e070288eb2f035bb064993e3
This commit is contained in:
Stephen Niedzielski 2018-03-14 14:44:22 -05:00
parent 5872c8376d
commit a2a743d775
24 changed files with 112 additions and 112 deletions

Binary file not shown.

View file

@ -78,20 +78,20 @@ export function boot(
return {
type: types.BOOT,
isEnabled: isEnabled,
isEnabled,
isNavPopupsEnabled: config.get( 'wgPopupsConflictsWithNavPopupGadget' ),
sessionToken: user.sessionId(),
pageToken: generateToken(),
page: {
url: url,
url,
title: config.get( 'wgTitle' ),
namespaceId: config.get( 'wgNamespaceNumber' ),
id: config.get( 'wgArticleId' )
},
user: {
isAnon: user.isAnon(),
editCount: editCount,
previewCount: previewCount
editCount,
previewCount
}
};
}
@ -115,16 +115,16 @@ export function fetch( gateway, title, el, token ) {
dispatch( timedAction( {
type: types.FETCH_START,
el: el,
el,
title: titleText,
namespaceId: namespaceId
namespaceId
} ) );
request = gateway.getPageSummary( titleText )
.then( function ( result ) {
dispatch( timedAction( {
type: types.FETCH_END,
el: el
el
} ) );
return result;
@ -132,7 +132,7 @@ export function fetch( gateway, title, el, token ) {
.catch( function ( err ) {
dispatch( {
type: types.FETCH_FAILED,
el: el
el
} );
// Keep the request promise in a rejected status since it failed.
throw err;
@ -145,9 +145,9 @@ export function fetch( gateway, title, el, token ) {
.then( function ( result ) {
dispatch( {
type: types.FETCH_COMPLETE,
el: el,
result: result,
token: token
el,
result,
token
} );
} )
.catch( function ( data, result ) {
@ -170,9 +170,9 @@ export function fetch( gateway, title, el, token ) {
dispatch( {
// Both FETCH_FAILED and FETCH_END conclude with FETCH_COMPLETE.
type: types.FETCH_COMPLETE,
el: el,
el,
result: createNullModel( titleText, title.getUrl() ),
token: token
token
} );
}
} );
@ -198,11 +198,11 @@ export function linkDwell( title, el, event, gateway, generateToken ) {
return function ( dispatch, getState ) {
var action = timedAction( {
type: types.LINK_DWELL,
el: el,
event: event,
token: token,
el,
event,
token,
title: titleText,
namespaceId: namespaceId
namespaceId
} );
// Has the new generated token been accepted?
@ -245,14 +245,14 @@ export function abandon() {
dispatch( timedAction( {
type: types.ABANDON_START,
token: token
token
} ) );
return wait( ABANDON_END_DELAY )
.then( function () {
dispatch( {
type: types.ABANDON_END,
token: token
token
} );
} );
};
@ -268,7 +268,7 @@ export function abandon() {
export function linkClick( el ) {
return timedAction( {
type: types.LINK_CLICK,
el: el
el
} );
}
@ -297,7 +297,7 @@ export function previewShow( token ) {
dispatch(
timedAction( {
type: types.PREVIEW_SHOW,
token: token
token
} )
);
@ -388,7 +388,7 @@ export function saveSettings( enabled ) {
dispatch( {
type: types.SETTINGS_CHANGE,
wasEnabled: getState().preview.enabled,
enabled: enabled
enabled
} );
};
}
@ -403,7 +403,7 @@ export function saveSettings( enabled ) {
export function eventLogged( event ) {
return {
type: types.EVENT_LOGGED,
event: event
event
};
}

View file

@ -8,12 +8,12 @@ import statsv from './statsv';
import syncUserSettings from './syncUserSettings';
export default {
footerLink: footerLink,
eventLogging: eventLogging,
linkTitle: linkTitle,
pageviews: pageviews,
render: render,
settings: settings,
statsv: statsv,
syncUserSettings: syncUserSettings
footerLink,
eventLogging,
linkTitle,
pageviews,
render,
settings,
statsv,
syncUserSettings
};

View file

@ -45,7 +45,7 @@ export default function createExperiments( mwExperiments ) {
return mwExperiments.getBucket( {
enabled: true,
name: name,
name,
buckets: {
'true': trueWeight,
'false': 1 - trueWeight

View file

@ -77,11 +77,11 @@ export default function createMediaWikiApiGateway( api, config ) {
}
return {
fetch: fetch,
extractPageFromResponse: extractPageFromResponse,
convertPageToModel: convertPageToModel,
getPageSummary: getPageSummary,
formatPlainTextExtract: formatPlainTextExtract
fetch,
extractPageFromResponse,
convertPageToModel,
getPageSummary,
formatPlainTextExtract
};
}

View file

@ -60,7 +60,7 @@ export default function createRESTBaseGateway( ajax, config, extractParser ) {
function ( page ) {
// Endpoint response may be empty or simply missing a title.
if ( !page || !page.title ) {
page = $.extend( true, page || {}, { title: title } );
page = $.extend( true, page || {}, { title } );
}
// And extract may be omitted if empty string
if ( page.extract === undefined ) {
@ -82,7 +82,7 @@ export default function createRESTBaseGateway( ajax, config, extractParser ) {
// matches Fetch failures.
result.reject( 'http', {
xhr: jqXHR,
textStatus: textStatus,
textStatus,
exception: errorThrown
} );
}
@ -93,9 +93,9 @@ export default function createRESTBaseGateway( ajax, config, extractParser ) {
}
return {
fetch: fetch,
convertPageToModel: convertPageToModel,
getPageSummary: getPageSummary
fetch,
convertPageToModel,
getPageSummary
};
}
@ -164,8 +164,8 @@ function generateThumbnailData( thumbnail, original, thumbSize ) {
return {
source: parts.join( '/' ),
width: width,
height: height
width,
height
};
}

View file

@ -21,7 +21,7 @@ function getUserBucket( experiments, experimentGroupSize, sessionId ) {
enabled: true,
buckets: {
off: 1 - experimentGroupSize,
control: control,
control,
on: control
}
}, sessionId );

View file

@ -63,14 +63,14 @@ export function createModel(
previewType = getPreviewType( type, processedExtract );
return {
title: title,
url: url,
languageCode: languageCode,
languageDirection: languageDirection,
title,
url,
languageCode,
languageDirection,
extract: processedExtract,
type: previewType,
thumbnail: thumbnail,
pageId: pageId
thumbnail,
pageId
};
}

View file

@ -55,8 +55,8 @@ export default function createPreviewBehavior( config, user, actions ) {
}
return {
settingsUrl: settingsUrl,
showSettings: showSettings,
settingsUrl,
showSettings,
previewDwell: actions.previewDwell,
previewAbandon: actions.abandon,
previewShow: actions.previewShow,

View file

@ -5,9 +5,9 @@ import settings from './settings';
import statsv from './statsv';
export default {
eventLogging: eventLogging,
pageviews: pageviews,
preview: preview,
settings: settings,
statsv: statsv
eventLogging,
pageviews,
preview,
settings,
statsv
};

View file

@ -162,8 +162,8 @@ export function createPagePreview( model ) {
return {
el: $el,
hasThumbnail: hasThumbnail,
thumbnail: thumbnail,
hasThumbnail,
thumbnail,
isTall: hasThumbnail && thumbnail.isTall
};
}
@ -426,8 +426,8 @@ export function createLayout(
top: offsetTop,
left: offsetLeft
},
flippedX: flippedX,
flippedY: flippedY
flippedX,
flippedY
};
}

View file

@ -49,7 +49,7 @@ export function createSettingsDialog( navPopupsEnabled ) {
helpText: mw.msg( 'popups-settings-help' ),
okLabel: mw.msg( 'popups-settings-help-ok' ),
descriptionText: mw.msg( 'popups-settings-description' ),
choices: choices
choices
} ) ) );
return $el;

View file

@ -130,8 +130,8 @@ export function createThumbnailElement(
$thumbnailSVGImage
.addClass( className )
.attr( {
x: x,
y: y,
x,
y,
width: thumbnailWidth,
height: thumbnailHeight,
'clip-path': 'url(#' + clipPath + ')'
@ -140,8 +140,8 @@ export function createThumbnailElement(
$thumbnail = $( document.createElementNS( nsSvg, 'svg' ) )
.attr( {
xmlns: nsSvg,
width: width,
height: height
width,
height
} )
.append( $thumbnailSVGImage );

View file

@ -127,7 +127,7 @@ QUnit.test( '#linkDwell', function ( assert ) {
assert.deepEqual( dispatch.getCall( 0 ).args[ 0 ], {
type: 'LINK_DWELL',
el: this.el,
event: event,
event,
token: '9876543210',
timestamp: mw.now(),
title: 'Foo',
@ -330,7 +330,7 @@ QUnit.test( 'it should delay dispatching the FETCH_COMPLETE action', function (
{
type: 'FETCH_COMPLETE',
el: this.el,
result: result,
result,
token: this.token
}
);
@ -412,7 +412,7 @@ QUnit.test( 'it should dispatch start and end actions', function ( assert ) {
assert.ok( dispatch.calledWith( {
type: 'ABANDON_START',
timestamp: mw.now(),
token: token
token
} ) );
// ---
@ -426,7 +426,7 @@ QUnit.test( 'it should dispatch start and end actions', function ( assert ) {
assert.ok(
dispatch.calledWith( {
type: 'ABANDON_END',
token: token
token
} ),
'ABANDON_* share the same token.'
);
@ -503,7 +503,7 @@ QUnit.test( 'it should dispatch the PREVIEW_SHOW action and log a pageview', fun
assert.ok(
dispatch.calledWith( {
type: 'PREVIEW_SHOW',
token: token,
token,
timestamp: mw.now()
} ),
'dispatches the preview show event'

View file

@ -22,8 +22,8 @@ QUnit.module( 'ext.popups/eventLogging', {
function createState( baseData, event ) {
return {
eventLogging: {
baseData: baseData,
event: event
baseData,
event
}
};
}

View file

@ -28,14 +28,14 @@ QUnit.module( 'ext.popups/pageviews', {
function createState( title ) {
return title ? {
pageviews: {
page: page,
page,
pageview: {
page_title: title // eslint-disable-line camelcase
}
}
} : {
pageviews: {
page: page,
page,
pageview: undefined
}
};

View file

@ -7,7 +7,7 @@ QUnit.module( 'ext.popups.preview.settingsBehavior', {
return { getUrl: function () { return 'url/' + title; } };
}
mediaWiki.Title = { newFromText: newFromText };
mediaWiki.Title = { newFromText };
/* global Map */ this.config = new Map();
},
afterEach: function () {

View file

@ -147,13 +147,13 @@ QUnit.test( 'PREVIEW_SHOW', function ( assert ) {
// state.interaction.started is used in this part of the reducer.
interaction: {
token: token
token
}
};
state = eventLogging( state, {
type: 'PREVIEW_SHOW',
token: token
token
} );
assert.equal(
@ -262,7 +262,7 @@ QUnit.test( 'LINK_DWELL should enqueue a "dismissed" or "dwelledButAbandoned" ev
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
@ -298,7 +298,7 @@ QUnit.test( 'LINK_DWELL should enqueue a "dismissed" or "dwelledButAbandoned" ev
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
@ -338,7 +338,7 @@ QUnit.test( 'LINK_CLICK should enqueue an "opened" event', function ( assert ) {
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
@ -383,13 +383,13 @@ QUnit.test( 'PREVIEW_SHOW should update the perceived wait time of the interacti
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
state = eventLogging( state, {
type: 'PREVIEW_SHOW',
token: token,
token,
timestamp: now + 500
} );
@ -397,7 +397,7 @@ QUnit.test( 'PREVIEW_SHOW should update the perceived wait time of the interacti
link: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
started: now,
isUserDwelling: true,
@ -420,13 +420,13 @@ QUnit.test( 'LINK_CLICK should include perceivedWait if the preview has been sho
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
state = eventLogging( state, {
type: 'PREVIEW_SHOW',
token: token,
token,
timestamp: now + 750
} );
@ -458,7 +458,7 @@ QUnit.test( 'FETCH_COMPLETE', function ( assert ) {
token = '1234567890',
initialState = {
interaction: {
token: token
token
}
},
state;
@ -475,7 +475,7 @@ QUnit.test( 'FETCH_COMPLETE', function ( assert ) {
state = eventLogging( initialState, {
type: 'FETCH_COMPLETE',
result: model,
token: token
token
} );
assert.strictEqual(
@ -612,7 +612,7 @@ QUnit.test( 'SETTINGS_SHOW should enqueue a "tapped settings cog" event', functi
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: Date.now()
} );
@ -685,19 +685,19 @@ QUnit.test( 'ABANDON_END should enqueue an event', function ( assert ) {
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
state = eventLogging( dwelledState, {
type: 'ABANDON_START',
token: token,
token,
timestamp: now + 500
} );
state = eventLogging( state, {
type: 'ABANDON_END',
token: token
token
} );
assert.deepEqual(
@ -722,19 +722,19 @@ QUnit.test( 'ABANDON_END should enqueue an event', function ( assert ) {
state = eventLogging( dwelledState, {
type: 'PREVIEW_SHOW',
token: token,
token,
timestamp: now + 700
} );
state = eventLogging( state, {
type: 'ABANDON_START',
token: token,
token,
timestamp: now + 850
} );
state = eventLogging( state, {
type: 'ABANDON_END',
token: token
token
} );
assert.deepEqual(
@ -766,7 +766,7 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
el: this.link,
title: 'Foo',
namespaceId: 1,
token: token,
token,
timestamp: now
} );
@ -785,7 +785,7 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
state = eventLogging( dwelledState, {
type: 'ABANDON_END',
token: token
token
} );
assert.strictEqual(
@ -808,13 +808,13 @@ QUnit.test( 'ABANDON_END doesn\'t enqueue an event under certain conditions', fu
state = eventLogging( state, {
type: 'ABANDON_START',
token: token,
token,
timestamp: now + 700
} );
state = eventLogging( state, {
type: 'ABANDON_END',
token: token,
token,
timestamp: now + 1000 // ABANDON_END_DELAY is 300 ms.
} );

View file

@ -161,7 +161,7 @@ QUnit.test( 'FETCH_COMPLETE', function ( assert ) {
},
action = {
type: 'FETCH_COMPLETE',
token: token,
token,
result: {}
};
@ -184,7 +184,7 @@ QUnit.test( 'FETCH_COMPLETE', function ( assert ) {
state = preview( state, {
type: 'ABANDON_START',
token: token
token
} );
assert.deepEqual(
@ -223,7 +223,7 @@ QUnit.test( actionTypes.FETCH_FAILED, function ( assert ) {
},
action = {
type: actionTypes.FETCH_FAILED,
token: token
token
};
assert.expect( 2 );
@ -241,7 +241,7 @@ QUnit.test( actionTypes.FETCH_FAILED, function ( assert ) {
action = {
type: actionTypes.FETCH_COMPLETE,
token: token,
token,
result: { title: createNullModel( 'Title', '/wiki/Title' ) }
};

View file

@ -75,8 +75,8 @@ QUnit.test( 'SETTINGS_CHANGE', function ( assert ) {
var action = function ( wasEnabled, enabled ) {
return {
type: 'SETTINGS_CHANGE',
wasEnabled: wasEnabled,
enabled: enabled
wasEnabled,
enabled
};
};

View file

@ -83,7 +83,7 @@ QUnit.test( 'LINK_DWELL', function ( assert ) {
timestamp = 100;
action = {
type: 'LINK_DWELL',
timestamp: timestamp
timestamp
};
state = statsv( {}, action );

View file

@ -58,7 +58,7 @@ export function createStubExperiments( bucket ) {
*/
export function createStubTitle( namespace, prefixedDb ) {
return {
namespace: namespace,
namespace,
getPrefixedDb: function () {
return prefixedDb;
},

View file

@ -22,9 +22,9 @@ function createPagePreview( isTall, hasThumbnail, thumbnail ) {
.append( hasThumbnail ? $( '<image>' ) : '' )
.append( $( '<a>', { 'class': 'mwe-popups-extract', text: 'extract' } ) )
.append( $( '<a>', { 'class': 'mwe-popups-settings-icon' } ) ),
isTall: isTall,
hasThumbnail: hasThumbnail,
thumbnail: thumbnail
isTall,
hasThumbnail,
thumbnail
};
}

View file

@ -3,7 +3,7 @@ import createSettingsDialogRenderer from '../../../src/ui/settingsDialogRenderer
QUnit.module( 'ext.popups/settingsDialogRenderer', {
beforeEach: function () {
function render() { return $( '<div>' ); }
function getTemplate() { return { render: render }; }
function getTemplate() { return { render }; }
mediaWiki.html = { escape: str => str };
mediaWiki.template = { get: getTemplate };