From 4f7f0b2fdc3a8e304978767b17e894b88b89b7e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 8 Dec 2022 23:01:12 +0100 Subject: [PATCH 01/10] Revert "fix unicorn/prefer-default-parameters manually" --- .eslintrc.js | 1 + src/definitions/behaviors/form.js | 5 +---- src/definitions/modules/calendar.js | 5 +---- src/definitions/modules/progress.js | 13 +++++-------- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 3cab27478e..c99bcdc9fd 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -104,6 +104,7 @@ module.exports = { 'unicorn/no-array-for-each': 'off', 'unicorn/no-for-loop': 'off', // autofixes to "for of" 'unicorn/prefer-code-point': 'off', + 'unicorn/prefer-default-parameters': 'off', 'unicorn/prefer-includes': 'off', 'unicorn/prefer-node-protocol': 'off', // needs Node 14+ 'unicorn/prefer-number-properties': 'off', diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 868eb4beec..a0ea6fe1e8 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -136,10 +136,7 @@ }, attachEvents: function (selector, action) { - if (!action) { - action = 'submit'; - } - + action = action || 'submit'; $(selector).on('click' + eventNamespace, function (event) { module[action](); event.preventDefault(); diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index bbd981e08f..f801227f5e 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -1342,10 +1342,7 @@ return date; }, dateDiff: function (date1, date2, mode) { - if (!mode) { - mode = 'day'; - } - + mode = mode || 'day'; var isTimeOnly = settings.type === 'time'; var isYear = mode === 'year'; var isYearOrMonth = isYear || mode === 'month'; diff --git a/src/definitions/modules/progress.js b/src/definitions/modules/progress.js index 11d44c17d0..17c698c8af 100644 --- a/src/definitions/modules/progress.js +++ b/src/definitions/modules/progress.js @@ -260,16 +260,13 @@ get: { text: function (templateText, index) { - if (!index) { - index = 0; - } - var - value = module.get.value(index), + index_ = index || 0, + value = module.get.value(index_), total = module.get.total(), percent = animating - ? module.get.displayPercent(index) - : module.get.percent(index), + ? module.get.displayPercent(index_) + : module.get.percent(index_), left = total !== false ? Math.max(0, total - value) : 100 - percent @@ -280,7 +277,7 @@ .replace('{total}', total || 0) .replace('{left}', left) .replace('{percent}', percent) - .replace('{bar}', settings.text.bars[index] || '') + .replace('{bar}', settings.text.bars[index_] || '') ; module.verbose('Adding variables to progress bar text', templateText); From ee25413db7075d3bbec43b49f9871a3cac80356b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 01:05:31 +0100 Subject: [PATCH 02/10] fix remaining no-extra-parens with autofix and manual review --- src/definitions/behaviors/api.js | 22 ++++++++++----------- src/definitions/behaviors/form.js | 16 +++++++-------- src/definitions/modules/accordion.js | 6 +++--- src/definitions/modules/calendar.js | 10 +++++----- src/definitions/modules/dimmer.js | 2 +- src/definitions/modules/dropdown.js | 28 +++++++++++++-------------- src/definitions/modules/flyout.js | 4 ++-- src/definitions/modules/modal.js | 4 ++-- src/definitions/modules/popup.js | 2 +- src/definitions/modules/progress.js | 8 ++++---- src/definitions/modules/search.js | 4 ++-- src/definitions/modules/shape.js | 8 ++++---- src/definitions/modules/sidebar.js | 10 +++++----- src/definitions/modules/transition.js | 4 ++-- tasks/config/tasks.js | 2 +- 15 files changed, 64 insertions(+), 66 deletions(-) diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index c4bf5b5af9..d80a2ec3ff 100644 --- a/src/definitions/behaviors/api.js +++ b/src/definitions/behaviors/api.js @@ -362,11 +362,11 @@ variable = templatedString.indexOf('$') !== -1 ? templatedString.slice(2, -1) : templatedString.slice(1, -1), - value = ($.isPlainObject(urlData) && urlData[variable] !== undefined) + value = $.isPlainObject(urlData) && urlData[variable] !== undefined ? urlData[variable] - : (($module.data(variable) !== undefined) + : ($module.data(variable) !== undefined ? $module.data(variable) - : (($context.data(variable) !== undefined) // eslint-disable-line unicorn/no-nested-ternary + : ($context.data(variable) !== undefined // eslint-disable-line unicorn/no-nested-ternary ? $context.data(variable) : urlData[variable])) ; @@ -393,11 +393,11 @@ variable = templatedString.indexOf('$') !== -1 ? templatedString.slice(3, -1) : templatedString.slice(2, -1), - value = ($.isPlainObject(urlData) && urlData[variable] !== undefined) + value = $.isPlainObject(urlData) && urlData[variable] !== undefined ? urlData[variable] - : (($module.data(variable) !== undefined) + : ($module.data(variable) !== undefined ? $module.data(variable) - : (($context.data(variable) !== undefined) // eslint-disable-line unicorn/no-nested-ternary + : ($context.data(variable) !== undefined // eslint-disable-line unicorn/no-nested-ternary ? $context.data(variable) : urlData[variable])) ; @@ -748,15 +748,15 @@ }, responseFromXHR: function (xhr) { return $.isPlainObject(xhr) - ? ((module.is.expectingJSON()) + ? (module.is.expectingJSON() ? module.decode.json(xhr.responseText) : xhr.responseText) : false; }, errorFromRequest: function (response, status, httpMessage) { - return ($.isPlainObject(response) && response.error !== undefined) + return $.isPlainObject(response) && response.error !== undefined ? response.error // use json error message - : ((settings.error[status] !== undefined) // use server error message + : (settings.error[status] !== undefined // use server error message ? settings.error[status] : httpMessage); }, @@ -836,9 +836,9 @@ } if (settings.on == 'auto') { if ($module.is('input')) { - return (element.oninput !== undefined) + return element.oninput !== undefined ? 'input' - : ((element.onpropertychange !== undefined) + : (element.onpropertychange !== undefined ? 'propertychange' : 'keyup'); } diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index a0ea6fe1e8..36f2085f78 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -492,9 +492,9 @@ return module.get.inputEvent(); }, inputEvent: function () { - return (document.createElement('input').oninput !== undefined) + return document.createElement('input').oninput !== undefined ? 'input' - : ((document.createElement('input').onpropertychange !== undefined) + : (document.createElement('input').onpropertychange !== undefined ? 'propertychange' : 'keyup'); }, @@ -539,13 +539,11 @@ if (ancillary && ['integer', 'decimal', 'number'].indexOf(ruleName) >= 0 && ancillary.indexOf('..') >= 0) { parts = ancillary.split('..', 2); if (!rule.prompt) { - suffixPrompt = ( - parts[0] === '' - ? settings.prompt.maxValue.replace(/{ruleValue}/g, '{max}') - : (parts[1] === '' - ? settings.prompt.minValue.replace(/{ruleValue}/g, '{min}') - : settings.prompt.range) - ); + suffixPrompt = parts[0] === '' + ? settings.prompt.maxValue.replace(/{ruleValue}/g, '{max}') + : (parts[1] === '' + ? settings.prompt.minValue.replace(/{ruleValue}/g, '{min}') + : settings.prompt.range); prompt += suffixPrompt.replace(/{name}/g, ' ' + settings.text.and); } prompt = prompt.replace(/{min}/g, parts[0]); diff --git a/src/definitions/modules/accordion.js b/src/definitions/modules/accordion.js index 15f3a526a4..4b9ed7a99e 100644 --- a/src/definitions/modules/accordion.js +++ b/src/definitions/modules/accordion.js @@ -122,7 +122,7 @@ toggle: function (query) { var $activeTitle = query !== undefined - ? ((typeof query === 'number') + ? (typeof query === 'number' ? $title.eq(query) : $(query).closest(selector.title)) : $(this).closest(selector.title), @@ -147,7 +147,7 @@ open: function (query) { var $activeTitle = query !== undefined - ? ((typeof query === 'number') + ? (typeof query === 'number' ? $title.eq(query) : $(query).closest(selector.title)) : $(this).closest(selector.title), @@ -217,7 +217,7 @@ close: function (query) { var $activeTitle = query !== undefined - ? ((typeof query === 'number') + ? (typeof query === 'number' ? $title.eq(query) : $(query).closest(selector.title)) : $(this).closest(selector.title), diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index f801227f5e..a00297e2d1 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -531,8 +531,8 @@ var focused = module.helper.dateEqual(cellDate, focusDate, mode); var inRange = !rangeDate ? false - : ((!!startDate && module.helper.isDateInRange(cellDate, mode, startDate, rangeDate)) - || (!!endDate && module.helper.isDateInRange(cellDate, mode, rangeDate, endDate))); + : (!!startDate && module.helper.isDateInRange(cellDate, mode, startDate, rangeDate)) + || (!!endDate && module.helper.isDateInRange(cellDate, mode, rangeDate, endDate)); $cell.toggleClass(className.focusCell, focused && (!isTouch || isTouchDown) && (!adjacent || (settings.selectAdjacentDays && adjacent)) && !disabled); if (module.helper.isTodayButton($cell)) { @@ -1112,7 +1112,7 @@ ss: ('0' + s).slice(-2), a: a, A: a.toUpperCase(), - S: ['th', 'st', 'nd', 'rd'][(D % 10) > 3 ? 0 : (((D % 100) - (D % 10) === 10) ? 0 : D % 10)], + S: ['th', 'st', 'nd', 'rd'][(D % 10) > 3 ? 0 : ((D % 100) - (D % 10) === 10 ? 0 : D % 10)], w: w, ww: ('0' + w).slice(-2), } @@ -1392,9 +1392,9 @@ return !date ? date - : ((minDate && module.helper.dateDiff(date, minDate, 'minute') > 0) + : (minDate && module.helper.dateDiff(date, minDate, 'minute') > 0 ? (isTimeOnly ? module.helper.mergeDateTime(date, minDate) : minDate) // eslint-disable-line unicorn/no-nested-ternary - : ((maxDate && module.helper.dateDiff(maxDate, date, 'minute') > 0) // eslint-disable-line unicorn/no-nested-ternary + : (maxDate && module.helper.dateDiff(maxDate, date, 'minute') > 0 // eslint-disable-line unicorn/no-nested-ternary ? (isTimeOnly ? module.helper.mergeDateTime(date, maxDate) : maxDate) : date)); }, diff --git a/src/definitions/modules/dimmer.js b/src/definitions/modules/dimmer.js index d0c2c1753e..9577b32645 100755 --- a/src/definitions/modules/dimmer.js +++ b/src/definitions/modules/dimmer.js @@ -48,7 +48,7 @@ moduleNamespace = 'module-' + namespace, moduleSelector = $allModules.selector || '', - clickEvent = ('ontouchstart' in document.documentElement) + clickEvent = 'ontouchstart' in document.documentElement ? 'touchstart' : 'click', diff --git a/src/definitions/modules/dropdown.js b/src/definitions/modules/dropdown.js index 294527c980..79c201158e 100644 --- a/src/definitions/modules/dropdown.js +++ b/src/definitions/modules/dropdown.js @@ -1920,8 +1920,8 @@ return ''; } - return (!module.has.selectInput() && module.is.multiple()) - ? ((typeof value === 'string') // delimited string + return !module.has.selectInput() && module.is.multiple() + ? (typeof value === 'string' // delimited string ? (raw ? value : module.escape.htmlEntities(value)).split(settings.delimiter) @@ -1965,9 +1965,9 @@ $choice.find(selector.menuIcon).remove(); } - return ($choice.data(metadata.text) !== undefined) + return $choice.data(metadata.text) !== undefined ? $choice.data(metadata.text) - : ((preserveHTML) + : (preserveHTML ? $choice.html() && $choice.html().trim() : $choice.text() && $choice.text().trim()); } @@ -1978,9 +1978,9 @@ return false; } - return ($choice.data(metadata.value) !== undefined) + return $choice.data(metadata.value) !== undefined ? String($choice.data(metadata.value)) - : ((typeof choiceText === 'string') + : (typeof choiceText === 'string' ? String( settings.ignoreSearchCase ? choiceText.toLowerCase() @@ -1993,9 +1993,9 @@ input = $search[0] ; if (input) { - return (input.oninput !== undefined) + return input.oninput !== undefined ? 'input' - : ((input.onpropertychange !== undefined) + : (input.onpropertychange !== undefined ? 'propertychange' : 'keyup'); } @@ -2102,14 +2102,14 @@ ; value = value !== undefined ? value - : ((module.get.values() !== undefined) + : (module.get.values() !== undefined ? module.get.values() : module.get.text()); - isMultiple = (module.is.multiple() && Array.isArray(value)); - shouldSearch = (isMultiple) + isMultiple = module.is.multiple() && Array.isArray(value); + shouldSearch = isMultiple ? value.length > 0 - : (value !== undefined && value !== null); - strict = (value === '' || value === false || value === true) + : value !== undefined && value !== null; + strict = value === '' || value === false || value === true ? true : strict || false; if (shouldSearch) { @@ -2384,7 +2384,7 @@ : elementIndex < $selectableItem.length; $nextSelectedItem = isWithinRange ? $selectableItem.eq(elementIndex) - : ((direction == 'up') + : (direction == 'up' ? $selectableItem.first() : $selectableItem.last()); if ($nextSelectedItem.length > 0) { diff --git a/src/definitions/modules/flyout.js b/src/definitions/modules/flyout.js index d32eded4c7..1ba1d66afc 100644 --- a/src/definitions/modules/flyout.js +++ b/src/definitions/modules/flyout.js @@ -1015,8 +1015,8 @@ ie: function () { if (module.cache.isIE === undefined) { var - isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window), - isIE = ('ActiveXObject' in window) + isIE11 = !window.ActiveXObject && 'ActiveXObject' in window, + isIE = 'ActiveXObject' in window ; module.cache.isIE = isIE11 || isIE; } diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index 77d686267e..eee70cbce6 100755 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -941,8 +941,8 @@ ie: function () { if (module.cache.isIE === undefined) { var - isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window), - isIE = ('ActiveXObject' in window) + isIE11 = !window.ActiveXObject && 'ActiveXObject' in window, + isIE = 'ActiveXObject' in window ; module.cache.isIE = isIE11 || isIE; } diff --git a/src/definitions/modules/popup.js b/src/definitions/modules/popup.js index b5bef7b0ee..a1c808190d 100644 --- a/src/definitions/modules/popup.js +++ b/src/definitions/modules/popup.js @@ -28,7 +28,7 @@ moduleSelector = $allModules.selector || '', - clickEvent = ('ontouchstart' in document.documentElement) + clickEvent = 'ontouchstart' in document.documentElement ? 'touchstart' : 'click', diff --git a/src/definitions/modules/progress.js b/src/definitions/modules/progress.js index 17c698c8af..c588989430 100644 --- a/src/definitions/modules/progress.js +++ b/src/definitions/modules/progress.js @@ -320,9 +320,9 @@ }, numericValue: function (value) { - return (typeof value === 'string') - ? ((value.replace(/[^\d.]/g, '') !== '') - ? +(value.replace(/[^\d.]/g, '')) + return typeof value === 'string' + ? (value.replace(/[^\d.]/g, '') !== '' + ? +value.replace(/[^\d.]/g, '') : false) : value; }, @@ -497,7 +497,7 @@ percent: function (percents) { percents = module.helper.forceArray(percents).map(function (percent) { percent = typeof percent === 'string' - ? +(percent.replace('%', '')) + ? +percent.replace('%', '') : percent; return settings.limitValues diff --git a/src/definitions/modules/search.js b/src/definitions/modules/search.js index cbba6280d2..d417351f06 100644 --- a/src/definitions/modules/search.js +++ b/src/definitions/modules/search.js @@ -458,9 +458,9 @@ inputEvent: function () { var prompt = $prompt[0], - inputEvent = (prompt !== undefined && prompt.oninput !== undefined) + inputEvent = prompt !== undefined && prompt.oninput !== undefined ? 'input' - : ((prompt !== undefined && prompt.onpropertychange !== undefined) + : (prompt !== undefined && prompt.onpropertychange !== undefined ? 'propertychange' : 'keyup') ; diff --git a/src/definitions/modules/shape.js b/src/definitions/modules/shape.js index 54df511339..8c306a9e2e 100644 --- a/src/definitions/modules/shape.js +++ b/src/definitions/modules/shape.js @@ -245,19 +245,19 @@ $clone = $module.clone().addClass(className.loading), $side = $clone.find('>' + selector.sides + '>' + selector.side), $activeSide = $side.filter('.' + settings.className.active), - $nextSide = (nextIndex) + $nextSide = nextIndex ? $side.eq(nextIndex) - : (($activeSide.next(selector.side).length > 0) + : ($activeSide.next(selector.side).length > 0 ? $activeSide.next(selector.side) : $side.first()), newWidth = settings.width === 'next' ? $nextSide.outerWidth(true) - : ((settings.width === 'initial') + : (settings.width === 'initial' ? $module.width() : settings.width), newHeight = settings.height === 'next' ? $nextSide.outerHeight(true) - : ((settings.height === 'initial') + : (settings.height === 'initial' ? $module.height() : settings.height) ; diff --git a/src/definitions/modules/sidebar.js b/src/definitions/modules/sidebar.js index 96ca5e543f..0ddb2ef16f 100644 --- a/src/definitions/modules/sidebar.js +++ b/src/definitions/modules/sidebar.js @@ -724,11 +724,11 @@ direction = module.get.direction(), transition ; - transition = (module.is.mobile()) - ? ((settings.mobileTransition == 'auto') + transition = module.is.mobile() + ? (settings.mobileTransition == 'auto' ? settings.defaultTransition.mobile[direction] : settings.mobileTransition) - : ((settings.transition == 'auto') + : (settings.transition == 'auto' ? settings.defaultTransition.computer[direction] : settings.transition); module.verbose('Determined transition', transition); @@ -786,8 +786,8 @@ ie: function () { if (module.cache.isIE === undefined) { var - isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window), - isIE = ('ActiveXObject' in window) + isIE11 = !window.ActiveXObject && 'ActiveXObject' in window, + isIE = 'ActiveXObject' in window ; module.cache.isIE = isIE11 || isIE; } diff --git a/src/definitions/modules/transition.js b/src/definitions/modules/transition.js index 361e06da0d..4e97c514b1 100644 --- a/src/definitions/modules/transition.js +++ b/src/definitions/modules/transition.js @@ -579,8 +579,8 @@ duration = $module.css('animation-duration') || 0; } - return (typeof duration === 'string') - ? ((duration.indexOf('ms') > -1) + return typeof duration === 'string' + ? (duration.indexOf('ms') > -1 ? parseFloat(duration) : parseFloat(duration) * 1000) : duration; diff --git a/tasks/config/tasks.js b/tasks/config/tasks.js index 291df99c73..5dfbbd58b3 100644 --- a/tasks/config/tasks.js +++ b/tasks/config/tasks.js @@ -95,7 +95,7 @@ module.exports = { /* Comment Banners */ header: { - year: nullish(config.header.year, (new Date()).getFullYear()), + year: nullish(config.header.year, new Date().getFullYear()), title: nullish(config.header.title, release.title), version: nullish(config.header.version, release.version), repository: nullish(config.header.repository, release.repository), From 9baf68b47e15a73a1279bda533087632949c5f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 15:54:03 +0100 Subject: [PATCH 03/10] assert no-extra-parens with customized rule --- .eslint/index.js | 23 +++++++++++++++++++++++ .eslint/no-extra-parens-rule.js | 17 +++++++++++++++++ .eslint/package.json | 11 +++++++++++ .eslintrc.js | 11 ++++------- package.json | 1 + yarn.lock | 10 ++++++++++ 6 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 .eslint/index.js create mode 100644 .eslint/no-extra-parens-rule.js create mode 100644 .eslint/package.json diff --git a/.eslint/index.js b/.eslint/index.js new file mode 100644 index 0000000000..b29ca41234 --- /dev/null +++ b/.eslint/index.js @@ -0,0 +1,23 @@ +module.exports = { + rules: { + 'no-extra-parens': require('./no-extra-parens-rule'), + }, + configs: { + recommended: { + plugins: [ + '@internal/eslint-plugin', + ], + rules: { + // https://github.com/eslint/eslint/issues/16626 + // https://github.com/airbnb/javascript/blob/eslint-config-airbnb-v19.0.4/packages/eslint-config-airbnb-base/rules/errors.js#L66 + '@internal/no-extra-parens': ['error', 'all', { + conditionalAssign: true, + enforceForArrowConditionals: false, + ignoreJSX: 'all', + nestedBinaryExpressions: false, + returnAssign: false, + }], + }, + }, + }, +}; diff --git a/.eslint/no-extra-parens-rule.js b/.eslint/no-extra-parens-rule.js new file mode 100644 index 0000000000..ca92017190 --- /dev/null +++ b/.eslint/no-extra-parens-rule.js @@ -0,0 +1,17 @@ +const eslint = require('eslint'); +const ruleComposer = require('eslint-rule-composer'); + +const rule = new eslint.Linter().getRules().get('no-extra-parens'); + +module.exports = ruleComposer.filterReports( + rule, + (problem) => { + if (problem.node.type === 'ConditionalExpression' + && (problem.node.parent.type === 'ConditionalExpression' || problem.node.parent.type === 'SpreadElement') + ) { + return false; + } + + return problem; + } +); diff --git a/.eslint/package.json b/.eslint/package.json new file mode 100644 index 0000000000..2a840dca60 --- /dev/null +++ b/.eslint/package.json @@ -0,0 +1,11 @@ +{ + "name": "@internal/eslint-plugin", + "version": "1.0.0", + "private": true, + "dependencies": { + "eslint-rule-composer": "^0.3.0" + }, + "peerDependencies": { + "eslint": "*" + } +} diff --git a/.eslintrc.js b/.eslintrc.js index c99bcdc9fd..c7e439c417 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -6,6 +6,7 @@ module.exports = { extends: [ 'airbnb-base', 'plugin:unicorn/recommended', + 'plugin:@internal/eslint-plugin/recommended', ], parserOptions: { ecmaVersion: '2020', @@ -22,10 +23,10 @@ module.exports = { 'class-methods-use-this': 'off', 'comma-dangle': ['error', { arrays: 'always-multiline', - objects: 'always-multiline', + exports: 'always-multiline', functions: 'never', imports: 'always-multiline', - exports: 'always-multiline', + objects: 'always-multiline', }], 'consistent-return': 'off', curly: ['error', 'all'], @@ -47,10 +48,6 @@ module.exports = { VariableDeclarator: true, }, }], - 'no-extra-parens': 'off', /* TODO https://github.com/eslint/eslint/issues/16626#issuecomment-1341016901 ['error', 'all', { - nestedBinaryExpressions: false, - enforceForNewInMemberExpressions: false, - }], */ 'no-nested-ternary': 'off', 'no-param-reassign': 'off', 'no-plusplus': 'off', @@ -60,8 +57,8 @@ module.exports = { 'object-shorthand': ['error', 'never'], 'padding-line-between-statements': ['error', { blankLine: 'always', - prev: '*', next: ['continue', 'break', 'export', 'return', 'throw'], + prev: '*', }], 'prefer-destructuring': 'off', 'prefer-template': 'off', diff --git a/package.json b/package.json index 19a3ac6b81..83abadd8a2 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "yamljs": "^0.3.0" }, "devDependencies": { + "@internal/eslint-plugin": "file:.eslint", "all-contributors-cli": "^6.7.0", "auto-changelog": "^2.4.0", "eslint": "^8.29.0", diff --git a/yarn.lock b/yarn.lock index 8155ea901f..eafcba9124 100644 --- a/yarn.lock +++ b/yarn.lock @@ -84,6 +84,11 @@ resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== +"@internal/eslint-plugin@file:.eslint": + version "1.0.0" + dependencies: + eslint-rule-composer "^0.3.0" + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" @@ -1591,6 +1596,11 @@ eslint-plugin-import@^2.26.0: resolve "^1.22.0" tsconfig-paths "^3.14.1" +eslint-rule-composer@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz#79320c927b0c5c0d3d3d2b76c8b4a488f25bbaf9" + integrity sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg== + eslint-scope@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.1.1.tgz#fff34894c2f65e5226d3041ac480b4513a163642" From 77adc1b5bbd204808e190d75bb4e61a8c7b2b64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 01:31:20 +0100 Subject: [PATCH 04/10] fix no-return-assign manually --- .eslintrc.js | 1 - src/definitions/modules/toast.js | 11 ++++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index c7e439c417..212f0ef9af 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -120,7 +120,6 @@ module.exports = { 'prefer-rest-params': 'off', // about 180 errors to be fixed manually // TODO - 'no-return-assign': 'off', 'no-shadow-restricted-names': 'off', 'no-use-before-define': 'off', 'unicorn/prefer-negative-index': 'off', diff --git a/src/definitions/modules/toast.js b/src/definitions/modules/toast.js index 994524f5d4..89fc59fafe 100644 --- a/src/definitions/modules/toast.js +++ b/src/definitions/modules/toast.js @@ -932,13 +932,18 @@ return n1 * x * x; } if (x < 2 / d1) { - return n1 * (x -= 1.5 / d1) * x + 0.75; + x -= 1.5 / d1; + + return n1 * x * x + 0.75; } if (x < 2.5 / d1) { - return n1 * (x -= 2.25 / d1) * x + 0.9375; + x -= 2.25 / d1; + + return n1 * x * x + 0.9375; } + x -= 2.625 / d1; - return n1 * (x -= 2.625 / d1) * x + 0.984375; + return n1 * x * x + 0.984375; }, easeOutCubic: function (t) { return --t * t * t + 1; From 00ea0d9dad478b3ca4d52a15fce67c7434039644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 01:32:31 +0100 Subject: [PATCH 05/10] fix no-use-before-define --- .eslintrc.js | 1 - 1 file changed, 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 212f0ef9af..6d023d4e8e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -121,7 +121,6 @@ module.exports = { // TODO 'no-shadow-restricted-names': 'off', - 'no-use-before-define': 'off', 'unicorn/prefer-negative-index': 'off', }, reportUnusedDisableDirectives: true, From 9bdedac78d0258bf8a8a28424126a6ebeb2c8e95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 01:35:18 +0100 Subject: [PATCH 06/10] fix unicorn/prefer-negative-index manually --- .eslintrc.js | 1 - src/definitions/modules/calendar.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 6d023d4e8e..54fa090259 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -121,7 +121,6 @@ module.exports = { // TODO 'no-shadow-restricted-names': 'off', - 'unicorn/prefer-negative-index': 'off', }, reportUnusedDisableDirectives: true, globals: { diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index a00297e2d1..fc3a12c0b9 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -1123,7 +1123,7 @@ return tokens[match]; } - return match.slice(1, match.length - 1); + return match.slice(1, -1); }); }, isDisabled: function (date, mode) { From ef6d678afb4d81f91a988e21b54364ba20d48ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Fri, 9 Dec 2022 01:38:29 +0100 Subject: [PATCH 07/10] move prefer-rest-params --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 54fa090259..64c2684cce 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -96,6 +96,7 @@ module.exports = { 'one-var': 'off', 'prefer-const': 'off', 'prefer-exponentiation-operator': 'off', + 'prefer-rest-params': 'off', 'prefer-spread': 'off', 'semi-style': 'off', 'unicorn/no-array-for-each': 'off', @@ -117,7 +118,6 @@ module.exports = { 'global-require': 'off', // about 30 errors to be fixed manually 'no-shadow': 'off', // about 220 errors to be fixed manually 'prefer-arrow-callback': 'off', // about 350 errors (all autofixable) - 'prefer-rest-params': 'off', // about 180 errors to be fixed manually // TODO 'no-shadow-restricted-names': 'off', From d45aae906f2fc5f7c18f93ca1e747f55baadbff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 Dec 2022 09:38:10 +0100 Subject: [PATCH 08/10] require node modules using const --- gulpfile.js | 2 +- tasks/admin/components/create.js | 2 +- tasks/admin/components/init.js | 2 +- tasks/admin/components/update.js | 2 +- tasks/admin/distributions/create.js | 2 +- tasks/admin/distributions/init.js | 2 +- tasks/admin/distributions/update.js | 2 +- tasks/admin/publish.js | 4 +--- tasks/admin/register.js | 10 +++++----- tasks/admin/release.js | 4 +--- tasks/build.js | 2 +- tasks/build/assets.js | 2 +- tasks/check-install.js | 2 +- tasks/clean.js | 2 +- tasks/collections/admin.js | 2 +- tasks/collections/rtl.js | 2 +- tasks/config/admin/github.js | 7 +++---- tasks/config/npm/gulpfile.js | 2 +- tasks/config/project/config.js | 2 +- tasks/config/project/install.js | 2 +- tasks/config/project/release.js | 3 ++- tasks/config/tasks.js | 2 +- tasks/config/user.js | 6 ++++-- tasks/docs/build.js | 2 +- tasks/docs/metadata.js | 2 +- tasks/docs/serve.js | 3 ++- tasks/install.js | 2 +- tasks/rtl/build.js | 4 +--- tasks/rtl/watch.js | 4 +--- tasks/version.js | 4 +--- tasks/watch.js | 2 +- 31 files changed, 42 insertions(+), 49 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 78a1b95190..b15ec062e6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -2,7 +2,7 @@ * Set-up *******************************/ -let +const gulp = require('gulp'), // read user config to know what task to load diff --git a/tasks/admin/components/create.js b/tasks/admin/components/create.js index cc799aa963..1c355e6b4c 100644 --- a/tasks/admin/components/create.js +++ b/tasks/admin/components/create.js @@ -14,7 +14,7 @@ * create meteor.js file */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/admin/components/init.js b/tasks/admin/components/init.js index 67a661624e..a5597c8baa 100644 --- a/tasks/admin/components/init.js +++ b/tasks/admin/components/init.js @@ -12,7 +12,7 @@ */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/admin/components/update.js b/tasks/admin/components/update.js index 9a25ba9f0f..4c68951877 100644 --- a/tasks/admin/components/update.js +++ b/tasks/admin/components/update.js @@ -12,7 +12,7 @@ */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/admin/distributions/create.js b/tasks/admin/distributions/create.js index cff01add2f..00632a9f37 100644 --- a/tasks/admin/distributions/create.js +++ b/tasks/admin/distributions/create.js @@ -9,7 +9,7 @@ * update package.json file */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/admin/distributions/init.js b/tasks/admin/distributions/init.js index efa124df0f..cd206f24fa 100644 --- a/tasks/admin/distributions/init.js +++ b/tasks/admin/distributions/init.js @@ -12,7 +12,7 @@ */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/admin/distributions/update.js b/tasks/admin/distributions/update.js index 09bf364588..aaf01e2cd0 100644 --- a/tasks/admin/distributions/update.js +++ b/tasks/admin/distributions/update.js @@ -12,7 +12,7 @@ */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/admin/publish.js b/tasks/admin/publish.js index 6c24131771..245eef8b77 100644 --- a/tasks/admin/publish.js +++ b/tasks/admin/publish.js @@ -9,9 +9,7 @@ */ -let - gulp = require('gulp') -; +const gulp = require('gulp'); /* Release All */ module.exports = function (callback) { diff --git a/tasks/admin/register.js b/tasks/admin/register.js index ab72d0e6b8..23ff79d9af 100644 --- a/tasks/admin/register.js +++ b/tasks/admin/register.js @@ -8,13 +8,13 @@ * Registers component with NPM */ -let - // node dependencies - process = require('child_process'), +// node dependencies +const process = require('child_process'); - // config - release = require('../config/admin/release'), +// config +const release = require('../config/admin/release'); +let // register components and distributions repos = release.distributions.concat(release.components), total = repos.length, diff --git a/tasks/admin/release.js b/tasks/admin/release.js index cf18cd558c..f1dd47bd9a 100644 --- a/tasks/admin/release.js +++ b/tasks/admin/release.js @@ -10,9 +10,7 @@ */ -let - gulp = require('gulp') -; +const gulp = require('gulp'); /* Release All */ module.exports = function (callback) { diff --git a/tasks/build.js b/tasks/build.js index f4211a2b51..33d5512064 100644 --- a/tasks/build.js +++ b/tasks/build.js @@ -2,7 +2,7 @@ * Build Task *******************************/ -let +const // dependencies gulp = require('gulp'), diff --git a/tasks/build/assets.js b/tasks/build/assets.js index 93539ca786..f932c32321 100644 --- a/tasks/build/assets.js +++ b/tasks/build/assets.js @@ -2,7 +2,7 @@ Build Task *******************************/ -let +const gulp = require('gulp'), // gulp dependencies diff --git a/tasks/check-install.js b/tasks/check-install.js index ecda387473..7df43f819d 100644 --- a/tasks/check-install.js +++ b/tasks/check-install.js @@ -2,7 +2,7 @@ * Check Install *******************************/ -let +const // node dependencies gulp = require('gulp'), console = require('better-console'), diff --git a/tasks/clean.js b/tasks/clean.js index b92079a7fd..339defb67d 100644 --- a/tasks/clean.js +++ b/tasks/clean.js @@ -2,7 +2,7 @@ Clean Task *******************************/ -let +const del = require('del'), config = require('./config/user'), tasks = require('./config/tasks') diff --git a/tasks/collections/admin.js b/tasks/collections/admin.js index ed18ce6819..da32d57829 100644 --- a/tasks/collections/admin.js +++ b/tasks/collections/admin.js @@ -14,7 +14,7 @@ *******************************/ module.exports = function (gulp) { - let + const // less/css distributions initComponents = require('../admin/components/init'), createComponents = require('../admin/components/create'), diff --git a/tasks/collections/rtl.js b/tasks/collections/rtl.js index 4b6a870dd2..e30762db31 100644 --- a/tasks/collections/rtl.js +++ b/tasks/collections/rtl.js @@ -4,7 +4,7 @@ module.exports = function (gulp) { // rtl - let + const buildRTL = require('../rtl/build'), watchRTL = require('../rtl/watch') ; diff --git a/tasks/config/admin/github.js b/tasks/config/admin/github.js index aea82602b1..1f16bb2df0 100644 --- a/tasks/config/admin/github.js +++ b/tasks/config/admin/github.js @@ -5,7 +5,7 @@ Logs into GitHub using OAuth */ -let +const fs = require('fs'), path = require('path'), GithubAPI = require('@octokit/rest'), @@ -13,15 +13,14 @@ let // stores oauth info for GitHub API oAuth = fs.existsSync(path.join(__dirname, './oauth.js')) ? require('./oauth.js') // eslint-disable-line import/extensions - : false, - github + : false ; if (!oAuth) { console.error('Must add oauth token for GitHub in tasks/config/admin/oauth.js'); } -github = new GithubAPI({ +let github = new GithubAPI({ version: '3.0.0', debug: true, protocol: 'https', diff --git a/tasks/config/npm/gulpfile.js b/tasks/config/npm/gulpfile.js index 50d56c6a06..a33fd99f1c 100644 --- a/tasks/config/npm/gulpfile.js +++ b/tasks/config/npm/gulpfile.js @@ -2,7 +2,7 @@ * Set-up *******************************/ -let +const gulp = require('gulp'), // read user config to know what task to load diff --git a/tasks/config/project/config.js b/tasks/config/project/config.js index 4f27b8e4b1..a2814f7dfa 100644 --- a/tasks/config/project/config.js +++ b/tasks/config/project/config.js @@ -2,7 +2,7 @@ Set-up *******************************/ -let +const fs = require('fs'), path = require('path'), diff --git a/tasks/config/project/install.js b/tasks/config/project/install.js index d53e174df8..08eaeef336 100644 --- a/tasks/config/project/install.js +++ b/tasks/config/project/install.js @@ -2,7 +2,7 @@ Set-up *******************************/ -let +const fs = require('fs'), path = require('path'), requireDotFile = require('require-dot-file'), diff --git a/tasks/config/project/release.js b/tasks/config/project/release.js index ce0ff37556..0e4b9750b8 100644 --- a/tasks/config/project/release.js +++ b/tasks/config/project/release.js @@ -2,8 +2,9 @@ Release Config *******************************/ +const requireDotFile = require('require-dot-file'); + let - requireDotFile = require('require-dot-file'), config, npmPackage, version diff --git a/tasks/config/tasks.js b/tasks/config/tasks.js index 5dfbbd58b3..3103dc2f98 100644 --- a/tasks/config/tasks.js +++ b/tasks/config/tasks.js @@ -1,4 +1,4 @@ -let +const browserslist = require('browserslist'), console = require('better-console'), config = require('./user'), diff --git a/tasks/config/user.js b/tasks/config/user.js index 881b820da1..a611756a28 100644 --- a/tasks/config/user.js +++ b/tasks/config/user.js @@ -2,7 +2,7 @@ Set-up *******************************/ -let +const // npm dependencies extend = require('extend'), fs = require('fs'), @@ -11,8 +11,10 @@ let // semantic.json defaults defaults = require('./defaults'), - config = require('./project/config'), + config = require('./project/config') +; +let // Final config object gulpConfig = {}, diff --git a/tasks/docs/build.js b/tasks/docs/build.js index c313e3129a..195a6dacf4 100644 --- a/tasks/docs/build.js +++ b/tasks/docs/build.js @@ -2,7 +2,7 @@ Build Docs *******************************/ -let +const extend = require('extend'), gulp = require('gulp'), diff --git a/tasks/docs/metadata.js b/tasks/docs/metadata.js index f798a7b81c..076516b48c 100644 --- a/tasks/docs/metadata.js +++ b/tasks/docs/metadata.js @@ -2,7 +2,7 @@ Summarize Docs *******************************/ -let +const // node dependencies console = require('better-console'), fs = require('fs'), diff --git a/tasks/docs/serve.js b/tasks/docs/serve.js index 8fc085019e..51b5598b82 100644 --- a/tasks/docs/serve.js +++ b/tasks/docs/serve.js @@ -1,7 +1,8 @@ /******************************* Serve Docs *******************************/ -let + +const extend = require('extend'), gulp = require('gulp'), diff --git a/tasks/install.js b/tasks/install.js index dcfb8cc207..79ed3ded81 100644 --- a/tasks/install.js +++ b/tasks/install.js @@ -13,7 +13,7 @@ * Standard installer runs asking for paths to site files etc */ -let +const gulp = require('gulp'), // node dependencies diff --git a/tasks/rtl/build.js b/tasks/rtl/build.js index d42be80fc8..4d72aea2f5 100644 --- a/tasks/rtl/build.js +++ b/tasks/rtl/build.js @@ -2,9 +2,7 @@ * Build Task *******************************/ -let - gulp = require('gulp') -; +const gulp = require('gulp'); // RTL builds are now handled by the default build process module.exports = function (callback) { diff --git a/tasks/rtl/watch.js b/tasks/rtl/watch.js index 389ce9a660..1adfffdf99 100644 --- a/tasks/rtl/watch.js +++ b/tasks/rtl/watch.js @@ -2,9 +2,7 @@ * Watch Task *******************************/ -let - gulp = require('gulp') -; +const gulp = require('gulp'); // RTL watch are now handled by the default watch process module.exports = function (callback) { diff --git a/tasks/version.js b/tasks/version.js index 25f84a7c1c..e8ced4ce8b 100644 --- a/tasks/version.js +++ b/tasks/version.js @@ -2,9 +2,7 @@ Version Task *******************************/ -let - release = require('./config/project/release') -; +const release = require('./config/project/release'); module.exports = function (callback) { console.log(release.title + ' ' + release.version); diff --git a/tasks/watch.js b/tasks/watch.js index dd12932358..871a7c4771 100644 --- a/tasks/watch.js +++ b/tasks/watch.js @@ -2,7 +2,7 @@ * Watch Task *******************************/ -let +const gulp = require('gulp'), // node dependencies From 55250c8c14cb4a12c83350c640f89506f142900b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Tue, 13 Dec 2022 16:03:34 +0100 Subject: [PATCH 09/10] fix no-shadow-restricted-names --- .eslintrc.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 64c2684cce..f80017fc64 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -117,10 +117,8 @@ module.exports = { eqeqeq: 'off', // about 300 errors to be fixed manually 'global-require': 'off', // about 30 errors to be fixed manually 'no-shadow': 'off', // about 220 errors to be fixed manually + 'no-shadow-restricted-names': 'off', // TODO https://github.com/fomantic/Fomantic-UI/pull/2604 'prefer-arrow-callback': 'off', // about 350 errors (all autofixable) - - // TODO - 'no-shadow-restricted-names': 'off', }, reportUnusedDisableDirectives: true, globals: { From 05483bb0719546de7cb8c88d50e121d34919a974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Thu, 8 Dec 2022 23:01:12 +0100 Subject: [PATCH 10/10] Revert "Revert "fix unicorn/prefer-default-parameters manually"" This reverts commit 4f7f0b2fdc3a8e304978767b17e894b88b89b7e5. --- .eslintrc.js | 1 - src/definitions/behaviors/form.js | 5 ++++- src/definitions/modules/calendar.js | 5 ++++- src/definitions/modules/progress.js | 13 ++++++++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f80017fc64..97e9994ad0 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -102,7 +102,6 @@ module.exports = { 'unicorn/no-array-for-each': 'off', 'unicorn/no-for-loop': 'off', // autofixes to "for of" 'unicorn/prefer-code-point': 'off', - 'unicorn/prefer-default-parameters': 'off', 'unicorn/prefer-includes': 'off', 'unicorn/prefer-node-protocol': 'off', // needs Node 14+ 'unicorn/prefer-number-properties': 'off', diff --git a/src/definitions/behaviors/form.js b/src/definitions/behaviors/form.js index 36f2085f78..ddde0c904f 100644 --- a/src/definitions/behaviors/form.js +++ b/src/definitions/behaviors/form.js @@ -136,7 +136,10 @@ }, attachEvents: function (selector, action) { - action = action || 'submit'; + if (!action) { + action = 'submit'; + } + $(selector).on('click' + eventNamespace, function (event) { module[action](); event.preventDefault(); diff --git a/src/definitions/modules/calendar.js b/src/definitions/modules/calendar.js index fc3a12c0b9..f447814e91 100644 --- a/src/definitions/modules/calendar.js +++ b/src/definitions/modules/calendar.js @@ -1342,7 +1342,10 @@ return date; }, dateDiff: function (date1, date2, mode) { - mode = mode || 'day'; + if (!mode) { + mode = 'day'; + } + var isTimeOnly = settings.type === 'time'; var isYear = mode === 'year'; var isYearOrMonth = isYear || mode === 'month'; diff --git a/src/definitions/modules/progress.js b/src/definitions/modules/progress.js index c588989430..4aa775c0a6 100644 --- a/src/definitions/modules/progress.js +++ b/src/definitions/modules/progress.js @@ -260,13 +260,16 @@ get: { text: function (templateText, index) { + if (!index) { + index = 0; + } + var - index_ = index || 0, - value = module.get.value(index_), + value = module.get.value(index), total = module.get.total(), percent = animating - ? module.get.displayPercent(index_) - : module.get.percent(index_), + ? module.get.displayPercent(index) + : module.get.percent(index), left = total !== false ? Math.max(0, total - value) : 100 - percent @@ -277,7 +280,7 @@ .replace('{total}', total || 0) .replace('{left}', left) .replace('{percent}', percent) - .replace('{bar}', settings.text.bars[index_] || '') + .replace('{bar}', settings.text.bars[index] || '') ; module.verbose('Adding variables to progress bar text', templateText);