Avoid shadowed variables in javascript

The rule no-shadow gets enabled in the version eslint-config-wikimedia
0.17.0.
In prepration for the automatic update with libup this needs to be done
in a separate patch set due to T262450

Change-Id: I66d405aef6d2b777e9a7f63734f2b5a5649d2080
This commit is contained in:
Umherirrender 2020-09-18 20:15:57 +02:00 committed by Jdlrobson
parent 8b6e85dd7c
commit 23b6332a5b
10 changed files with 35 additions and 35 deletions

View file

@ -67,7 +67,7 @@
"bundlesize": [
{
"path": "resources/dist/index.js",
"maxSize": "13.64kB"
"maxSize": "13.7kB"
}
]
}

Binary file not shown.

Binary file not shown.

View file

@ -149,12 +149,12 @@ export function fetch( gateway, title, el, token, type ) {
} )
.catch( ( err, data ) => {
const exception = new Error( err );
const type = data && data.textStatus && data.textStatus === 'abort' ?
const fetchType = data && data.textStatus && data.textStatus === 'abort' ?
types.FETCH_ABORTED : types.FETCH_FAILED;
exception.data = data;
dispatch( {
type,
type: fetchType,
el,
token
} );

View file

@ -19,8 +19,8 @@ export default function eventLogging(
boundActions, eventLoggingTracker, getCurrentTimestamp
) {
return ( _, state ) => {
const eventLogging = state.eventLogging;
let event = eventLogging.event;
const eventLoggingObj = state.eventLogging;
let event = eventLoggingObj.event;
if ( !event ) {
return;
@ -33,7 +33,7 @@ export default function eventLogging(
// Rightly or wrongly, it's left as an exercise for the analyst to
// calculate the time at which the interaction started as part of their
// analyses, e.g. https://phabricator.wikimedia.org/T186016#4002923.
event = $.extend( true, {}, eventLogging.baseData, event, {
event = $.extend( true, {}, eventLoggingObj.baseData, event, {
timestamp: getCurrentTimestamp()
} );

View file

@ -6,7 +6,7 @@
* @return {ext.popups.ChangeListener}
*/
export default function settings( boundActions, render ) {
let settings;
let settingsObj;
return ( prevState, state ) => {
if ( !prevState ) {
@ -20,25 +20,25 @@ export default function settings( boundActions, render ) {
state.settings.shouldShow === true
) {
// Lazily instantiate the settings UI
if ( !settings ) {
settings = render( boundActions );
settings.appendTo( document.body );
if ( !settingsObj ) {
settingsObj = render( boundActions );
settingsObj.appendTo( document.body );
}
// Update the UI settings with the current settings
settings.setEnabled( state.preview.enabled );
settingsObj.setEnabled( state.preview.enabled );
settings.show();
settingsObj.show();
} else if (
prevState.settings.shouldShow === true &&
state.settings.shouldShow === false
) {
settings.hide();
settingsObj.hide();
}
// Update help visibility
if ( prevState.settings.showHelp !== state.settings.showHelp ) {
settings.toggleHelp( state.settings.showHelp );
settingsObj.toggleHelp( state.settings.showHelp );
}
};
}

View file

@ -12,10 +12,10 @@
*/
export default function statsv( boundActions, track ) {
return ( _, state ) => {
const statsv = state.statsv;
const statsvObj = state.statsv;
if ( statsv.action ) {
track( statsv.action, statsv.data );
if ( statsvObj.action ) {
track( statsvObj.action, statsvObj.data );
boundActions.statsvLogged();
}

View file

@ -115,36 +115,36 @@ function getCurrentTimestamp() {
* [store](http://redux.js.org/docs/api/Store.html#store).
*
* @param {Redux.Store} store
* @param {Object} actions
* @param {Object} registerActions
* @param {UserSettings} userSettings
* @param {Function} settingsDialog
* @param {PreviewBehavior} previewBehavior
* @param {EventTracker} statsvTracker
* @param {EventTracker} eventLoggingTracker
* @param {EventTracker} pageviewTracker
* @param {Function} getCurrentTimestamp
* @param {Function} callbackCurrentTimestamp
* @return {void}
*/
function registerChangeListeners(
store, actions, userSettings, settingsDialog, previewBehavior,
statsvTracker, eventLoggingTracker, pageviewTracker, getCurrentTimestamp
store, registerActions, userSettings, settingsDialog, previewBehavior,
statsvTracker, eventLoggingTracker, pageviewTracker, callbackCurrentTimestamp
) {
registerChangeListener( store, changeListeners.footerLink( actions ) );
registerChangeListener( store, changeListeners.linkTitle() );
registerChangeListener( store, changeListeners.render( previewBehavior ) );
registerChangeListener(
store, changeListeners.statsv( actions, statsvTracker ) );
store, changeListeners.statsv( registerActions, statsvTracker ) );
registerChangeListener(
store, changeListeners.syncUserSettings( userSettings ) );
registerChangeListener(
store, changeListeners.settings( actions, settingsDialog ) );
store, changeListeners.settings( registerActions, settingsDialog ) );
registerChangeListener(
store,
changeListeners.eventLogging(
actions, eventLoggingTracker, getCurrentTimestamp
registerActions, eventLoggingTracker, callbackCurrentTimestamp
) );
registerChangeListener( store,
changeListeners.pageviews( actions, pageviewTracker )
changeListeners.pageviews( registerActions, pageviewTracker )
);
}

View file

@ -360,12 +360,12 @@ export function hide( preview ) {
* @param {number} windowData.scrollTop
* @param {number} windowData.width
* @param {number} windowData.height
* @param {number} pointerSize Space reserved for the pointer
* @param {number} pointerSpaceSize Space reserved for the pointer
* @param {string} dir 'ltr' if left-to-right, 'rtl' if right-to-left.
* @return {ext.popups.PreviewLayout}
*/
export function createLayout(
isPreviewTall, eventData, linkData, windowData, pointerSize, dir
isPreviewTall, eventData, linkData, windowData, pointerSpaceSize, dir
) {
let flippedX = false,
flippedY = false,
@ -377,7 +377,7 @@ export function createLayout(
eventData.pageY - windowData.scrollTop,
linkData.clientRects,
false
) + windowData.scrollTop + pointerSize :
) + windowData.scrollTop + pointerSpaceSize :
// Position according to link position or size
linkData.offset.top + linkData.height + pointerSize,
offsetLeft;
@ -430,7 +430,7 @@ export function createLayout(
) + windowData.scrollTop;
}
offsetTop -= pointerSize;
offsetTop -= pointerSpaceSize;
}
return {
@ -498,11 +498,11 @@ export function getClasses( preview, layout ) {
* @param {ext.popups.PreviewLayout} layout
* @param {string[]} classes class names used for layout out the preview
* @param {number} predefinedLandscapeImageHeight landscape image height
* @param {number} pointerSize
* @param {number} pointerSpaceSize
* @return {void}
*/
export function layoutPreview(
preview, layout, classes, predefinedLandscapeImageHeight, pointerSize
preview, layout, classes, predefinedLandscapeImageHeight, pointerSpaceSize
) {
const popup = preview.el,
isTall = preview.isTall,
@ -517,7 +517,7 @@ export function layoutPreview(
) {
popup.find( '.mwe-popups-extract' ).css(
'margin-top',
thumbnail.height - pointerSize
thumbnail.height - pointerSpaceSize
);
}

View file

@ -1,13 +1,13 @@
import * as stubs from './stubs';
import isEnabled from '../../src/isEnabled';
function createStubUserSettings( isEnabled ) {
function createStubUserSettings( expectEnabled ) {
return {
hasIsEnabled() {
return isEnabled !== undefined;
return expectEnabled !== undefined;
},
getIsEnabled() {
return Boolean( isEnabled );
return Boolean( expectEnabled );
}
};
}