From 2bb2e4ed78b5bcc1ca4ab9f2b8b12b8b6ebc78a8 Mon Sep 17 00:00:00 2001 From: Maximilian <787658+mfranzke@users.noreply.github.com> Date: Tue, 23 Nov 2021 23:15:53 +0100 Subject: [PATCH] chore: code optimizations that are mentioned by the github pipeline as well --- packages/core/src/lib/compose.js | 5 ++--- packages/core/src/lib/expandPartials.js | 9 +++++---- packages/core/src/lib/loadPattern.js | 6 ++++-- packages/core/src/lib/object_factory.js | 10 ++++------ packages/core/src/lib/pattern_engines.js | 3 ++- packages/core/src/lib/ui_builder.js | 10 ++++------ 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/packages/core/src/lib/compose.js b/packages/core/src/lib/compose.js index cc981f8e2..3b8909b0a 100644 --- a/packages/core/src/lib/compose.js +++ b/packages/core/src/lib/compose.js @@ -205,9 +205,8 @@ module.exports = async function (pattern, patternlab) { ); // Allows serializing the compile state - patternlab.graph.node( - pattern - ).compileState = pattern.compileState = CompileState.CLEAN; + patternlab.graph.node(pattern).compileState = + pattern.compileState = CompileState.CLEAN; logger.info('Built pattern: ' + pattern.patternPartial); } ); diff --git a/packages/core/src/lib/expandPartials.js b/packages/core/src/lib/expandPartials.js index 908b6377a..f153ff467 100644 --- a/packages/core/src/lib/expandPartials.js +++ b/packages/core/src/lib/expandPartials.js @@ -64,10 +64,11 @@ module.exports = function (currentPattern, patternlab) { `within ${currentPattern.patternPartial}, replacing extendedTemplate partial ${foundPartial} with ${cleanPartialPattern.patternPartial}'s extendedTemplate` ); - currentPattern.extendedTemplate = currentPattern.extendedTemplate.replace( - foundPartial, - cleanPartialPattern.extendedTemplate - ); + currentPattern.extendedTemplate = + currentPattern.extendedTemplate.replace( + foundPartial, + cleanPartialPattern.extendedTemplate + ); // update the extendedTemplate in the partials object in case this // pattern is consumed later diff --git a/packages/core/src/lib/loadPattern.js b/packages/core/src/lib/loadPattern.js index 8c8d276f3..9d6b22519 100644 --- a/packages/core/src/lib/loadPattern.js +++ b/packages/core/src/lib/loadPattern.js @@ -133,10 +133,12 @@ module.exports = function (relPath, patternlab) { currentPattern.template = fs.readFileSync(templatePath, 'utf8'); //find any stylemodifiers that may be in the current pattern - currentPattern.stylePartials = currentPattern.findPartialsWithStyleModifiers(); + currentPattern.stylePartials = + currentPattern.findPartialsWithStyleModifiers(); //find any pattern parameters that may be in the current pattern - currentPattern.parameteredPartials = currentPattern.findPartialsWithPatternParameters(); + currentPattern.parameteredPartials = + currentPattern.findPartialsWithPatternParameters(); [ templatePath, diff --git a/packages/core/src/lib/object_factory.js b/packages/core/src/lib/object_factory.js index bce935228..704474881 100644 --- a/packages/core/src/lib/object_factory.js +++ b/packages/core/src/lib/object_factory.js @@ -381,16 +381,14 @@ Pattern.prototype = { .map((o, i) => { if (i === 0) { // TODO: Remove when prefix gets deprecated - info.patternGroupOrder = Pattern.prototype.setPatternOrderDataForInfo( - o - ); + info.patternGroupOrder = + Pattern.prototype.setPatternOrderDataForInfo(o); } if (i === 1) { // TODO: Remove when prefix gets deprecated - info.patternSubgroupOrder = Pattern.prototype.setPatternOrderDataForInfo( - o - ); + info.patternSubgroupOrder = + Pattern.prototype.setPatternOrderDataForInfo(o); } return o.replace(prefixMatcher, ''); diff --git a/packages/core/src/lib/pattern_engines.js b/packages/core/src/lib/pattern_engines.js index 20bc82a47..a744f4d7d 100644 --- a/packages/core/src/lib/pattern_engines.js +++ b/packages/core/src/lib/pattern_engines.js @@ -248,7 +248,8 @@ const PatternEngines = Object.create({ } // not a hidden pattern, let's dig deeper - const supportedPatternFileExtensions = PatternEngines.getSupportedFileExtensions(); + const supportedPatternFileExtensions = + PatternEngines.getSupportedFileExtensions(); return ( supportedPatternFileExtensions.lastIndexOf(extension) !== -1 || PatternEngines.isPseudoPatternJSON(filename) diff --git a/packages/core/src/lib/ui_builder.js b/packages/core/src/lib/ui_builder.js index d6e282059..8b3d7de3a 100644 --- a/packages/core/src/lib/ui_builder.js +++ b/packages/core/src/lib/ui_builder.js @@ -402,9 +402,8 @@ const ui_builder = function () { ] = {}; groupedPatterns.patternGroups[pattern.patternGroup][ pattern.patternSubgroup - ][ - 'viewall-' + pattern.patternGroup + '-' + pattern.patternSubgroup - ] = injectDocumentationBlock(pattern, patternlab, true); + ]['viewall-' + pattern.patternGroup + '-' + pattern.patternSubgroup] = + injectDocumentationBlock(pattern, patternlab, true); addToViewAllPaths(patternlab, pattern); addPatternSubgroupItem(patternlab, pattern, true); @@ -588,9 +587,8 @@ const ui_builder = function () { `Omitting ${patternGroupName}/${patternName} from building a viewall page because its patternSubgroup is specified in styleguideExcludes.` ); } else { - styleguideGroupedPatterns = styleguideGroupedPatterns.concat( - subgroupPatterns - ); + styleguideGroupedPatterns = + styleguideGroupedPatterns.concat(subgroupPatterns); } groupedPatterns = groupedPatterns.concat(subgroupPatterns);