Fixed no-shadow lint warnings (#15520)

We're planning to change this from a warning to an error and need to
clean the codebase up before we do so.

In all of these cases the shadowing was known about and was not
causing unexpected behaviour, so the refactor consists entirely of
renaming, rather than refactoring/bug fixes.
This commit is contained in:
Fabien 'egg' O'Carroll 2022-10-03 15:50:28 +01:00 committed by GitHub
parent 353cad7ed2
commit 35bc5fa08a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 32 deletions

View File

@ -91,7 +91,7 @@ module.exports = function MembersAPI({
productRepository,
Member,
MemberCancelEvent,
MemberSubscribeEvent,
MemberSubscribeEventModel: MemberSubscribeEvent,
MemberPaidSubscriptionEvent,
MemberEmailChangeEvent,
MemberStatusEvent,

View File

@ -29,7 +29,7 @@ module.exports = class MemberRepository {
* @param {object} deps
* @param {any} deps.Member
* @param {any} deps.MemberCancelEvent
* @param {any} deps.MemberSubscribeEvent
* @param {any} deps.MemberSubscribeEventModel
* @param {any} deps.MemberEmailChangeEvent
* @param {any} deps.MemberPaidSubscriptionEvent
* @param {any} deps.MemberStatusEvent
@ -47,7 +47,7 @@ module.exports = class MemberRepository {
constructor({
Member,
MemberCancelEvent,
MemberSubscribeEvent,
MemberSubscribeEventModel,
MemberEmailChangeEvent,
MemberPaidSubscriptionEvent,
MemberStatusEvent,
@ -64,7 +64,7 @@ module.exports = class MemberRepository {
}) {
this._Member = Member;
this._MemberCancelEvent = MemberCancelEvent;
this._MemberSubscribeEvent = MemberSubscribeEvent;
this._MemberSubscribeEvent = MemberSubscribeEventModel;
this._MemberEmailChangeEvent = MemberEmailChangeEvent;
this._MemberPaidSubscriptionEvent = MemberPaidSubscriptionEvent;
this._MemberStatusEvent = MemberStatusEvent;
@ -931,9 +931,9 @@ module.exports = class MemberRepository {
const originalMrrDelta = model.get('mrr');
const updatedMrrDelta = updated.get('mrr');
const getStatus = (model) => {
const status = model.get('status');
const canceled = model.get('cancel_at_period_end');
const getStatus = (modelToCheck) => {
const status = modelToCheck.get('status');
const canceled = modelToCheck.get('cancel_at_period_end');
if (status === 'canceled') {
return 'expired';
@ -979,16 +979,16 @@ module.exports = class MemberRepository {
}
} else {
eventData.created_at = new Date(subscription.start_date * 1000);
const model = await this._StripeCustomerSubscription.add(subscriptionData, options);
const subscriptionModel = await this._StripeCustomerSubscription.add(subscriptionData, options);
await this._MemberPaidSubscriptionEvent.add({
member_id: member.id,
subscription_id: model.id,
subscription_id: subscriptionModel.id,
type: 'created',
source: 'stripe',
from_plan: null,
to_plan: subscriptionPriceData.id,
currency: subscriptionPriceData.currency,
mrr_delta: model.get('mrr'),
mrr_delta: subscriptionModel.get('mrr'),
...eventData
}, options);
@ -999,7 +999,7 @@ module.exports = class MemberRepository {
source,
tierId: ghostProduct?.get('id'),
memberId: member.id,
subscriptionId: model.get('id'),
subscriptionId: subscriptionModel.get('id'),
offerId: data.offerId,
attribution: data.attribution
});
@ -1045,10 +1045,10 @@ module.exports = class MemberRepository {
let activeSubscriptionForChangedProduct = false;
for (const subscription of subscriptions.models) {
if (this.isActiveSubscriptionStatus(subscription.get('status'))) {
for (const subscriptionModel of subscriptions.models) {
if (this.isActiveSubscriptionStatus(subscriptionModel.get('status'))) {
try {
const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscription.get('stripe_price_id')}, options);
const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscriptionModel.get('stripe_price_id')}, options);
if (subscriptionProduct && changedProduct && subscriptionProduct.id === changedProduct.id) {
activeSubscriptionForChangedProduct = true;
}
@ -1070,11 +1070,11 @@ module.exports = class MemberRepository {
} else {
const subscriptions = await member.related('stripeSubscriptions').fetch(options);
let activeSubscriptionForGhostProduct = false;
for (const subscription of subscriptions.models) {
if (this.isActiveSubscriptionStatus(subscription.get('status'))) {
for (const subscriptionModel of subscriptions.models) {
if (this.isActiveSubscriptionStatus(subscriptionModel.get('status'))) {
status = 'paid';
try {
const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscription.get('stripe_price_id')}, options);
const subscriptionProduct = await this._productRepository.get({stripe_price_id: subscriptionModel.get('stripe_price_id')}, options);
if (subscriptionProduct && ghostProduct && subscriptionProduct.id === ghostProduct.id) {
activeSubscriptionForGhostProduct = true;
}

View File

@ -276,16 +276,16 @@ function createServer(hostname, server, pretest) {
let index = 0;
function next(err) {
const vhost = vhosts[index];
const foundVhost = vhosts[index];
index = index + 1;
if (!vhost || err) {
if (!foundVhost || err) {
res.statusCode = err ? (err.status || 500) : 404;
res.end(err ? err.message : `no vhost for "${req.headers.host}"`);
return;
}
vhost(req, res, next);
foundVhost(req, res, next);
}
next();

View File

@ -321,8 +321,8 @@ describe('SubscriptionStatsService', function () {
*
* @returns {(result: import('../../lib/subscriptions').SubscriptionHistoryEntry) => boolean}
**/
const finder = (tier, cadence, date) => (result) => {
return result.tier === tier && result.cadence === cadence && result.date === date;
const finder = (tier, cadence, date) => (resultItem) => {
return resultItem.tier === tier && resultItem.cadence === cadence && resultItem.date === date;
};
const days = [{

View File

@ -174,9 +174,9 @@ module.exports = class StripeMigrations {
}
for (const plan of plans) {
const price = await this.findPriceByPlan(plan, options);
const existingPrice = await this.findPriceByPlan(plan, options);
if (!price) {
if (!existingPrice) {
logging.info(`Could not find Stripe Price ${JSON.stringify(plan)}`);
try {
@ -240,8 +240,8 @@ module.exports = class StripeMigrations {
const newPortalPlans = await portalPlans.reduce(async (newPortalPlansPromise, plan) => {
let newPlan = plan;
if (plan === 'monthly') {
const monthlyPlan = plans.find((plan) => {
return plan.name === 'Monthly';
const monthlyPlan = plans.find((planItem) => {
return planItem.name === 'Monthly';
});
if (!monthlyPlan) {
return newPortalPlansPromise;
@ -250,8 +250,8 @@ module.exports = class StripeMigrations {
newPlan = price.id;
}
if (plan === 'yearly') {
const yearlyPlan = plans.find((plan) => {
return plan.name === 'Yearly';
const yearlyPlan = plans.find((planItem) => {
return planItem.name === 'Yearly';
});
if (!yearlyPlan) {
return newPortalPlansPromise;
@ -259,8 +259,8 @@ module.exports = class StripeMigrations {
const price = await this.findPriceByPlan(yearlyPlan, options);
newPlan = price.id;
}
const newPortalPlans = await newPortalPlansPromise;
return newPortalPlans.concat(newPlan);
const newPortalPlansMemo = await newPortalPlansPromise;
return newPortalPlansMemo.concat(newPlan);
}, []);
logging.info(`Updating portal_plans setting to ${JSON.stringify(newPortalPlans)}`);
@ -515,8 +515,8 @@ module.exports = class StripeMigrations {
return newPortalPlansPromise;
}
const newPortalPlans = await newPortalPlansPromise;
const updatedPortalPlans = newPortalPlans.filter(d => d !== plan).concat(plan);
const newPortalPlansMemo = await newPortalPlansPromise;
const updatedPortalPlans = newPortalPlansMemo.filter(d => d !== plan).concat(plan);
return updatedPortalPlans;
}, defaultPortalPlans);