From ee43133dd960f8fcbb45ad99cefdcd584437117a Mon Sep 17 00:00:00 2001 From: Naz Date: Wed, 22 Sep 2021 11:51:37 +0200 Subject: [PATCH] Fixed error initialization syntax refs https://linear.app/tryghost/issue/CORE-9/remove-eslint-warnings - Used an incorrect string parameter constructor for ghost errors previously. The errors should be initialized with an object containing a "message" property --- ghost/limit-service/lib/date-utils.js | 4 +++- ghost/limit-service/lib/limit-service.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ghost/limit-service/lib/date-utils.js b/ghost/limit-service/lib/date-utils.js index bae0847ffc..6798c4ec21 100644 --- a/ghost/limit-service/lib/date-utils.js +++ b/ghost/limit-service/lib/date-utils.js @@ -22,7 +22,9 @@ const lastPeriodStart = (startDate, interval) => { return lastPeriodStartDate.toISO(); } - throw new IncorrectUsageError('Invalid interval specified. Only "month" value is accepted.'); + throw new IncorrectUsageError({ + message: 'Invalid interval specified. Only "month" value is accepted.' + }); }; module.exports = { diff --git a/ghost/limit-service/lib/limit-service.js b/ghost/limit-service/lib/limit-service.js index 3df5357af0..5996d68591 100644 --- a/ghost/limit-service/lib/limit-service.js +++ b/ghost/limit-service/lib/limit-service.js @@ -20,7 +20,9 @@ class LimitService { */ loadLimits({limits = {}, subscription, helpLink, db, errors}) { if (!errors) { - throw new IncorrectUsageError(`Config Missing: 'errors' is required.`); + throw new IncorrectUsageError({ + message: `Config Missing: 'errors' is required.` + }); } this.errors = errors; @@ -42,7 +44,9 @@ class LimitService { this.limits[name] = new MaxLimit({name: name, config: limitConfig, helpLink, db, errors}); } else if (_.has(limitConfig, 'maxPeriodic')) { if (subscription === undefined) { - throw new errors.IncorrectUsageError({message: 'Attempted to setup a periodic max limit without a subscription'}); + throw new errors.IncorrectUsageError({ + message: 'Attempted to setup a periodic max limit without a subscription' + }); } const maxPeriodicLimitConfig = Object.assign({}, limitConfig, subscription);