From 008c9dcbcd385b018d1c7c8db0dc1f66745da9ae Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Thu, 4 Feb 2021 10:25:04 +0000 Subject: [PATCH] Linting and updating helper manifest. --- packages/string-templates/manifest.json | 11 ++++++++++- .../string-templates/scripts/gen-collection-info.js | 7 ++++--- packages/string-templates/src/helpers/date.js | 8 ++++---- packages/string-templates/src/helpers/external.js | 4 ++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/string-templates/manifest.json b/packages/string-templates/manifest.json index af1f4e3d54..5a96885383 100644 --- a/packages/string-templates/manifest.json +++ b/packages/string-templates/manifest.json @@ -1097,8 +1097,17 @@ "format" ], "numArgs": 2, - "example": "{{date now \"DD-MM-YYYY\"}}", + "example": "{{date now \"DD-MM-YYYY\"}} -> 21-01-2021", "description": "

Format a date using moment.js date formatting.

\n" + }, + "duration": { + "args": [ + "time", + "durationType" + ], + "numArgs": 2, + "example": "{{duration timeLeft \"seconds\"}} -> a few seconds", + "description": "

Produce a humanized duration left/until given an amount of time and the type of time measurement.

\n" } } } \ No newline at end of file diff --git a/packages/string-templates/scripts/gen-collection-info.js b/packages/string-templates/scripts/gen-collection-info.js index 863322fb29..a33d967a62 100644 --- a/packages/string-templates/scripts/gen-collection-info.js +++ b/packages/string-templates/scripts/gen-collection-info.js @@ -26,9 +26,10 @@ const ADDED_HELPERS = { args: ["time", "durationType"], numArgs: 2, example: '{{duration timeLeft "seconds"}} -> a few seconds', - description: "Produce a humanized duration left/until given an amount of time and the type of time measurement." - } - } + description: + "Produce a humanized duration left/until given an amount of time and the type of time measurement.", + }, + }, } function fixSpecialCases(name, obj) { diff --git a/packages/string-templates/src/helpers/date.js b/packages/string-templates/src/helpers/date.js index cc254195d9..514efcd19f 100644 --- a/packages/string-templates/src/helpers/date.js +++ b/packages/string-templates/src/helpers/date.js @@ -64,12 +64,12 @@ function initialSteps(str, pattern, options) { pattern = null str = null } - return {str, pattern, options} + return { str, pattern, options } } function setLocale(str, pattern, options) { // if options is null then it'll get updated here - ({str, pattern, options} = initialSteps(str, pattern, options)) + ;({ str, pattern, options } = initialSteps(str, pattern, options)) const defaults = { lang: "en", date: new Date(str) } const opts = getContext(this, defaults, options) @@ -78,7 +78,7 @@ function setLocale(str, pattern, options) { } module.exports.date = (str, pattern, options) => { - ({str, pattern, options} = initialSteps(str, pattern, options)) + ;({ str, pattern, options } = initialSteps(str, pattern, options)) // if no args are passed, return a formatted date if (str == null && pattern == null) { @@ -92,7 +92,7 @@ module.exports.date = (str, pattern, options) => { } module.exports.duration = (str, pattern, format) => { - ({str, pattern} = initialSteps(str, pattern)) + ;({ str, pattern } = initialSteps(str, pattern)) setLocale(str, pattern) diff --git a/packages/string-templates/src/helpers/external.js b/packages/string-templates/src/helpers/external.js index df2880f96c..0fa7f734d0 100644 --- a/packages/string-templates/src/helpers/external.js +++ b/packages/string-templates/src/helpers/external.js @@ -19,8 +19,8 @@ const EXTERNAL_FUNCTION_COLLECTIONS = [ ] const ADDED_HELPERS = { - "date": date, - "duration": duration, + date: date, + duration: duration, } exports.registerAll = handlebars => {