diff --git a/packages/cli/bin/inquiries/starterkit.js b/packages/cli/bin/inquiries/starterkit.js index 945649973..523eb64bc 100644 --- a/packages/cli/bin/inquiries/starterkit.js +++ b/packages/cli/bin/inquiries/starterkit.js @@ -10,7 +10,8 @@ const starterkitSetup = [ message: 'What initial patterns do you want included in your project?', choices: [ { - name: 'Handlebars base patterns (some basic patterns to get started with)', + name: + 'Handlebars base patterns (some basic patterns to get started with)', value: '@pattern-lab/starterkit-handlebars-vanilla', }, { diff --git a/packages/cli/bin/scaffold.js b/packages/cli/bin/scaffold.js index ac2b4378b..618301fc5 100644 --- a/packages/cli/bin/scaffold.js +++ b/packages/cli/bin/scaffold.js @@ -1,7 +1,7 @@ 'use strict'; const path = require('path'); const execa = require('execa'); -const fs = require('fs-extra'); +const fs = require('fs'); const wrapAsync = require('./utils').wrapAsync; const mkdirsAsync = require('./utils').mkdirsAsync; @@ -18,7 +18,6 @@ const scaffold = (projectDir, sourceDir, publicDir, exportDir) => wrapAsync(function* () { const projectPath = path.join(process.cwd(), projectDir); if (!fs.existsSync(path.join(projectPath, 'package.json'))) { - fs.ensureDirSync(projectPath); execa.sync('npm', ['init', '-y'], { cwd: projectPath, }); diff --git a/packages/cli/package.json b/packages/cli/package.json index c0ac5912d..0708fc754 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -49,7 +49,7 @@ ], "scripts": { "lint": "eslint ./{bin,test}", - "test:separate": "tap ./test/*.test.js --reporter spec --timeout=120" + "test:separate": "tap './test/*.test.js' --reporter spec --timeout=120" }, "repository": "https://github.com/pattern-lab/patternlab-node/tree/master/packages/cli", "bugs": "https://github.com/pattern-lab/patternlab-node/issues", diff --git a/packages/core/src/lib/addPattern.js b/packages/core/src/lib/addPattern.js index 0534c5dfd..12c0c9429 100644 --- a/packages/core/src/lib/addPattern.js +++ b/packages/core/src/lib/addPattern.js @@ -2,7 +2,7 @@ const logger = require('./log'); -module.exports = function (pattern, patternlab) { +module.exports = function(pattern, patternlab) { //add the link to the global object if (!patternlab.data.link) { patternlab.data.link = {}; diff --git a/packages/core/src/lib/annotation_exporter.js b/packages/core/src/lib/annotation_exporter.js index dffb01253..2ff23547b 100644 --- a/packages/core/src/lib/annotation_exporter.js +++ b/packages/core/src/lib/annotation_exporter.js @@ -6,7 +6,7 @@ const _ = require('lodash'); const mp = require('./markdown_parser'); const logger = require('./log'); -const annotations_exporter = function (pl) { +const annotations_exporter = function(pl) { const paths = pl.config.paths; let oldAnnotations; @@ -68,7 +68,7 @@ const annotations_exporter = function (pl) { //let annotations = annotations; const markdown_parser = parser; - return function (filePath) { + return function(filePath) { const annotationsMD = fs.readFileSync(path.resolve(filePath), 'utf8'); //take the annotation snippets and split them on our custom delimiter @@ -110,15 +110,15 @@ const annotations_exporter = function (pl) { } return { - gather: function () { + gather: function() { return gatherAnnotations(); }, - gatherJS: function () { + gatherJS: function() { return parseAnnotationsJS(); }, - gatherMD: function () { + gatherMD: function() { return parseAnnotationsMD(); - }, + } }; }; diff --git a/packages/core/src/lib/buildFooter.js b/packages/core/src/lib/buildFooter.js index c70cfe249..3054cdc44 100644 --- a/packages/core/src/lib/buildFooter.js +++ b/packages/core/src/lib/buildFooter.js @@ -13,15 +13,15 @@ let render = require('./render'); //eslint-disable-line prefer-const * @param patternPartial - the partial key to build this for, either viewall-patternPartial or a viewall-patternGroup-all * @returns A promise which resolves with the HTML */ -module.exports = function (patternlab, patternPartial, uikit) { +module.exports = function(patternlab, patternPartial, uikit) { //first render the general footer return render(Pattern.createEmpty({ extendedTemplate: uikit.footer }), { patternData: JSON.stringify({ - patternPartial: patternPartial, + patternPartial: patternPartial }), - cacheBuster: patternlab.cacheBuster, + cacheBuster: patternlab.cacheBuster }) - .then((footerPartial) => { + .then(footerPartial => { let allFooterData; try { allFooterData = jsonCopy( @@ -36,7 +36,7 @@ module.exports = function (patternlab, patternPartial, uikit) { return render(patternlab.userFoot, allFooterData); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error('Error building buildFooterHTML'); }); diff --git a/packages/core/src/lib/buildListItems.js b/packages/core/src/lib/buildListItems.js index 7eb214f12..b3ebe19aa 100644 --- a/packages/core/src/lib/buildListItems.js +++ b/packages/core/src/lib/buildListItems.js @@ -23,10 +23,10 @@ const items = [ 'seventeen', 'eighteen', 'nineteen', - 'twenty', + 'twenty' ]; -module.exports = function (container) { +module.exports = function(container) { //combine all list items into one structure const list = []; for (const item in container.listitems) { diff --git a/packages/core/src/lib/buildPatterns.js b/packages/core/src/lib/buildPatterns.js index 476a373c6..c1d9f8524 100644 --- a/packages/core/src/lib/buildPatterns.js +++ b/packages/core/src/lib/buildPatterns.js @@ -113,13 +113,13 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => { return render( Pattern.createEmpty({ // todo should this be uikit.header? - extendedTemplate: patternlab.header, + extendedTemplate: patternlab.header }), { - cacheBuster: patternlab.cacheBuster, + cacheBuster: patternlab.cacheBuster } ) - .then((results) => { + .then(results => { patternlab.data.patternLabHead = results; // If deletePatternDir == true or graph needs to be updated @@ -133,7 +133,7 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => { if (patternlab.incrementalBuildsEnabled) { // When the graph was loaded from file, some patterns might have been moved/deleted between runs // so the graph data become out of sync - patternlab.graph.sync().forEach((n) => { + patternlab.graph.sync().forEach(n => { logger.info('[Deleted/Moved] ' + n); }); @@ -150,18 +150,18 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => { } //render all patterns last, so lineageR works const allPatternsPromise = patternsToBuild.map( - async (pattern) => await compose(pattern, patternlab) + async pattern => await compose(pattern, patternlab) ); //copy non-pattern files like JavaScript - const allJS = patternsToBuild.map((pattern) => { + const allJS = patternsToBuild.map(pattern => { const { name, patternPartial, subdir } = pattern; const { source: { patterns: sourceDir }, - public: { patterns: publicDir }, + public: { patterns: publicDir } } = patternlab.config.paths; const src = path.join(sourceDir, subdir); const dest = path.join(publicDir, name); - return map(patternlab.uikits, (uikit) => { + return map(patternlab.uikits, uikit => { return copy( src, path.resolve(process.cwd(), uikit.outputDir, dest), @@ -170,7 +170,7 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => { filter: ['*.js'], rename: () => { return `${patternPartial}.js`; - }, + } } ).on(copy.events.COPY_FILE_COMPLETE, () => { logger.debug( @@ -199,27 +199,27 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => { //export patterns if necessary pattern_exporter.export_patterns(patternlab); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error('Error rendering patterns'); }); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error('Error rendering pattern lab header'); }); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error('Error processing meta patterns'); }); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error('Error processing patterns recursively'); }); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error('Error in buildPatterns()'); }); diff --git a/packages/core/src/lib/changes_hunter.js b/packages/core/src/lib/changes_hunter.js index ee4a4d52c..65c4456dd 100644 --- a/packages/core/src/lib/changes_hunter.js +++ b/packages/core/src/lib/changes_hunter.js @@ -12,7 +12,7 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const * For detecting changed patterns. * @constructor */ -const ChangesHunter = function () {}; +const ChangesHunter = function() {}; ChangesHunter.prototype = { /** @@ -25,7 +25,7 @@ ChangesHunter.prototype = { * * @see {@link CompileState} */ - checkBuildState: function (pattern, patternlab) { + checkBuildState: function(pattern, patternlab) { //write the compiled template to the public patterns directory const renderedTemplatePath = patternlab.config.paths.public.patterns + @@ -40,12 +40,12 @@ ChangesHunter.prototype = { pattern.compileState = CompileState.NEEDS_REBUILD; } - _.each(patternlab.uikits, (uikit) => { + _.each(patternlab.uikits, uikit => { try { // renderedTemplatePath required to display a single element // Markup only is required for "View All" pages. It will get loaded later on. // If any of these is missing, mark pattern for recompile - [renderedTemplatePath, markupOnlyPath].forEach((renderedFile) => { + [renderedTemplatePath, markupOnlyPath].forEach(renderedFile => { // Prevent error message if file does not exist fs.accessSync( path.join(process.cwd(), uikit.outputDir, renderedFile), @@ -94,7 +94,7 @@ ChangesHunter.prototype = { * @param {Pattern} currentPattern * @param {string} file */ - checkLastModified: function (currentPattern, file) { + checkLastModified: function(currentPattern, file) { if (file && fs.pathExistsSync(file)) { try { const stat = fs.statSync(file); @@ -110,12 +110,12 @@ ChangesHunter.prototype = { } }, - needsRebuild: function (lastModified, p) { + needsRebuild: function(lastModified, p) { if (p.compileState !== CompileState.CLEAN || !p.lastModified) { return true; } return p.lastModified >= lastModified; - }, + } }; module.exports = ChangesHunter; diff --git a/packages/core/src/lib/cleanBuildDirectory.js b/packages/core/src/lib/cleanBuildDirectory.js index 0cfc300e0..11d78c01e 100644 --- a/packages/core/src/lib/cleanBuildDirectory.js +++ b/packages/core/src/lib/cleanBuildDirectory.js @@ -15,12 +15,12 @@ module.exports = (incrementalBuildsEnabled, patternlab) => { return Promise.resolve(); } else { return Promise.all( - _.map(patternlab.uikits, (uikit) => { + _.map(patternlab.uikits, uikit => { return fs.emptyDir( path.join(process.cwd(), uikit.outputDir, paths.public.patterns) ); }) - ).catch((reason) => { + ).catch(reason => { logger.error(reason); }); } diff --git a/packages/core/src/lib/compose.js b/packages/core/src/lib/compose.js index 3b8909b0a..4a2ed124d 100644 --- a/packages/core/src/lib/compose.js +++ b/packages/core/src/lib/compose.js @@ -15,7 +15,7 @@ const pluginManager = new pm(); const Pattern = require('./object_factory').Pattern; const CompileState = require('./object_factory').CompileState; -module.exports = async function (pattern, patternlab) { +module.exports = async function(pattern, patternlab) { // Pattern does not need to be built and recompiled more than once if (!pattern.isPattern || pattern.compileState === CompileState.CLEAN) { return Promise.resolve(false); @@ -41,7 +41,7 @@ module.exports = async function (pattern, patternlab) { ); return Promise.all( - _.map(patternlab.uikits, (uikit) => { + _.map(patternlab.uikits, uikit => { // exclude pattern from uikit rendering if (uikitExcludePattern(pattern, uikit)) { return Promise.resolve(); @@ -125,18 +125,18 @@ module.exports = async function (pattern, patternlab) { patternBreadcrumb: pattern.patternGroup === pattern.patternSubgroup ? { - patternGroup: pattern.patternGroup, + patternGroup: pattern.patternGroup } : { patternGroup: pattern.patternGroup, - patternSubgroup: pattern.patternSubgroup, + patternSubgroup: pattern.patternSubgroup }, patternExtension: pattern.fileExtension.substr(1), //remove the dot because styleguide asset default adds it for us patternName: pattern.patternName, patternPartial: pattern.patternPartial, patternState: pattern.patternState, patternEngineName: pattern.engine.engineName, - extraOutput: extraOutput, + extraOutput: extraOutput }); //set the pattern-specific footer by compiling the general-footer with data, and then adding it to the meta footer @@ -145,16 +145,16 @@ module.exports = async function (pattern, patternlab) { { isPattern: pattern.isPattern, patternData: pattern.patternData, - cacheBuster: patternlab.cacheBuster, + cacheBuster: patternlab.cacheBuster } ); return Promise.all([ headPromise, patternPartialPromise, - footerPartialPromise, + footerPartialPromise ]) - .then((intermediateResults) => { + .then(intermediateResults => { // retrieve results of promises const headHTML = intermediateResults[0]; //headPromise pattern.patternPartialCode = intermediateResults[1]; //patternPartialPromise @@ -178,7 +178,7 @@ module.exports = async function (pattern, patternlab) { allFooterData.patternLabFoot = footerPartial; return render(patternlab.userFoot, allFooterData).then( - async (footerHTML) => { + async footerHTML => { /////////////// // WRITE FILES /////////////// @@ -211,7 +211,7 @@ module.exports = async function (pattern, patternlab) { } ); }) - .catch((reason) => { + .catch(reason => { console.log(reason); }); }) diff --git a/packages/core/src/lib/copier.js b/packages/core/src/lib/copier.js index ef7990ec5..0bb3e6efd 100644 --- a/packages/core/src/lib/copier.js +++ b/packages/core/src/lib/copier.js @@ -8,7 +8,7 @@ const watchAssets = require('./watchAssets'); const watchPatternLabFiles = require('./watchPatternLabFiles'); const copier = () => { - const transform_paths = (directories) => { + const transform_paths = directories => { //create array with all source keys minus our blacklist const dirs = {}; const blackList = [ @@ -18,7 +18,7 @@ const copier = () => { 'meta', 'annotations', 'patternlabFiles', - 'styleguide', + 'styleguide' ]; _.each(directories.source, (dir, key) => { if (blackList.includes(key)) { @@ -52,7 +52,7 @@ const copier = () => { const copyOptions = { overwrite: true, emitter: patternlab.events, - debug: patternlab.config.logLevel === 'debug', + debug: patternlab.config.logLevel === 'debug' }; //loop through each directory asset object (source / public pairing) @@ -66,7 +66,7 @@ const copier = () => { } else { //just copy copyPromises.push( - _.map(patternlab.uikits, (uikit) => { + _.map(patternlab.uikits, uikit => { copyFile( dir.source, path.join(basePath, uikit.outputDir, dir.public), @@ -79,7 +79,7 @@ const copier = () => { // copy the styleguide copyPromises.push( - _.map(patternlab.uikits, (uikit) => { + _.map(patternlab.uikits, uikit => { copyFile( path.join(uikit.modulePath, assetDirectories.source.styleguide), path.join(basePath, uikit.outputDir, assetDirectories.public.root), @@ -90,7 +90,7 @@ const copier = () => { // copy the favicon copyPromises.push( - _.map(patternlab.uikits, (uikit) => { + _.map(patternlab.uikits, uikit => { copyFile( `${assetDirectories.source.root}/favicon.ico`, path.join( @@ -116,9 +116,9 @@ const copier = () => { copyAndWatch: (assetDirectories, patternlab, options) => { return copyAndWatch(assetDirectories, patternlab, options); }, - transformConfigPaths: (paths) => { + transformConfigPaths: paths => { return transform_paths(paths); - }, + } }; }; diff --git a/packages/core/src/lib/copyFile.js b/packages/core/src/lib/copyFile.js index c8202afe1..c1fcc03fb 100644 --- a/packages/core/src/lib/copyFile.js +++ b/packages/core/src/lib/copyFile.js @@ -7,17 +7,17 @@ let copy = require('recursive-copy'); // eslint-disable-line prefer-const const copyFile = (p, dest, options) => { return copy(p, dest, options) - .on(copy.events.ERROR, function (error, copyOperation) { + .on(copy.events.ERROR, function(error, copyOperation) { logger.error('Unable to copy ' + copyOperation.dest); }) - .on(copy.events.COPY_FILE_ERROR, (error) => { + .on(copy.events.COPY_FILE_ERROR, error => { logger.error(error); }) .on(copy.events.COPY_FILE_COMPLETE, () => { logger.debug(`Moved ${p} to ${dest}`); options.emitter.emit(events.PATTERNLAB_PATTERN_ASSET_CHANGE, { file: p, - dest: dest, + dest: dest }); }); }; diff --git a/packages/core/src/lib/dataMerger.js b/packages/core/src/lib/dataMerger.js index 08544c320..5ebdd21bb 100644 --- a/packages/core/src/lib/dataMerger.js +++ b/packages/core/src/lib/dataMerger.js @@ -9,11 +9,7 @@ const _ = require('lodash'); * @param {*} dataToMergeWithObject the object that should be merged with the original data * @param {*} patternlabConfig the patternlab configuration object */ -module.exports = function ( - dataObject, - dataToMergeWithObject, - patternlabConfig -) { +module.exports = function(dataObject, dataToMergeWithObject, patternlabConfig) { return _.mergeWith( {}, dataObject, diff --git a/packages/core/src/lib/data_loader.js b/packages/core/src/lib/data_loader.js index 594f4b700..e52885155 100644 --- a/packages/core/src/lib/data_loader.js +++ b/packages/core/src/lib/data_loader.js @@ -53,7 +53,7 @@ function loadDataFromFolder(dataFilesPath, excludeFileNames, fsDep) { const dataFiles = glob.sync(dataFilesFullPath, globOptions); let mergeObject = {}; - dataFiles.forEach(function (filePath) { + dataFiles.forEach(function(filePath) { try { const jsonData = yaml.safeLoad( fsDep.readFileSync(path.resolve(filePath), 'utf8') @@ -70,6 +70,6 @@ function loadDataFromFolder(dataFilesPath, excludeFileNames, fsDep) { module.exports = function configFileLoader() { return { loadDataFromFile: loadFile, - loadDataFromFolder: loadDataFromFolder, + loadDataFromFolder: loadDataFromFolder }; }; diff --git a/packages/core/src/lib/decompose.js b/packages/core/src/lib/decompose.js index 4c35cd694..ff65a0bfc 100644 --- a/packages/core/src/lib/decompose.js +++ b/packages/core/src/lib/decompose.js @@ -16,7 +16,7 @@ const list_item_hunter = new lih(); * @param patternlab - global data store * @param ignoreLineage - whether or not to hunt for lineage for this pattern */ -module.exports = function (pattern, patternlab, ignoreLineage) { +module.exports = function(pattern, patternlab, ignoreLineage) { //set the extendedTemplate to operate on later if we find partials to replace if (!pattern.extendedTemplate) { pattern.extendedTemplate = pattern.template; @@ -50,8 +50,8 @@ module.exports = function (pattern, patternlab, ignoreLineage) { listItemPromise, expandPartialPromise, lineagePromise, - addPromise, - ]).catch((reason) => { + addPromise + ]).catch(reason => { logger.error(reason); }); }; diff --git a/packages/core/src/lib/expandPartials.js b/packages/core/src/lib/expandPartials.js index f153ff467..36fbba13e 100644 --- a/packages/core/src/lib/expandPartials.js +++ b/packages/core/src/lib/expandPartials.js @@ -9,7 +9,7 @@ const getPartial = require('./get'); const parameter_hunter = new ph(); const style_modifier_hunter = new smh(); -module.exports = function (currentPattern, patternlab) { +module.exports = function(currentPattern, patternlab) { const processRecursive = require('./processRecursive'); //find how many partials there may be for the given pattern @@ -31,7 +31,7 @@ module.exports = function (currentPattern, patternlab) { .find_parameters(currentPattern, patternlab) .then(() => { //do something with the regular old partials - foundPatternPartials.forEach((foundPartial) => { + foundPatternPartials.forEach(foundPartial => { const partial = currentPattern.findPartial(foundPartial); const partialPattern = getPartial(partial, patternlab); @@ -77,13 +77,13 @@ module.exports = function (currentPattern, patternlab) { return Promise.resolve(); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error(reason); }); }); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error(reason); }); diff --git a/packages/core/src/lib/exportData.js b/packages/core/src/lib/exportData.js index a229cc815..034f1f294 100644 --- a/packages/core/src/lib/exportData.js +++ b/packages/core/src/lib/exportData.js @@ -11,7 +11,7 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const * Write out our pattern information for use by the front end * @param patternlab - global data store */ -module.exports = function (patternlab, uikit) { +module.exports = function(patternlab, uikit) { const annotation_exporter = new ae(patternlab); const paths = patternlab.config.paths; diff --git a/packages/core/src/lib/findModules.js b/packages/core/src/lib/findModules.js index f54f80d4f..0d0ff0824 100644 --- a/packages/core/src/lib/findModules.js +++ b/packages/core/src/lib/findModules.js @@ -6,7 +6,7 @@ const isScopedPackage = require('./isScopedPackage'); let fs = require('fs-extra'); // eslint-disable-line -const isDir = (fPath) => { +const isDir = fPath => { const stats = fs.lstatSync(fPath); return stats.isDirectory() || stats.isSymbolicLink(); }; @@ -27,7 +27,7 @@ module.exports = (dir, filter) => { */ const dirList = fs .readdirSync(fPath) - .filter((p) => isDir(path.join(fPath, p))); + .filter(p => isDir(path.join(fPath, p))); /** * @name m @@ -35,10 +35,10 @@ module.exports = (dir, filter) => { * @type {Array} */ const m = foundModules.concat( - dirList.filter(filter).map((mod) => { + dirList.filter(filter).map(mod => { return { name: filter(mod), - modulePath: path.join(fPath, mod), + modulePath: path.join(fPath, mod) }; }) ); @@ -52,7 +52,7 @@ module.exports = (dir, filter) => { ...m, ...dirList .filter(isScopedPackage) // 2 - .map((scope) => findModules(path.join(fPath, scope), m)) // 3 + .map(scope => findModules(path.join(fPath, scope), m)) // 3 ); }; diff --git a/packages/core/src/lib/get.js b/packages/core/src/lib/get.js index 4852670eb..2feccc135 100644 --- a/packages/core/src/lib/get.js +++ b/packages/core/src/lib/get.js @@ -2,7 +2,7 @@ const logger = require('./log'); -module.exports = function (partialName, patternlab, reportWarning = true) { +module.exports = function(partialName, patternlab, reportWarning = true) { //look for exact partial matches for (let i = 0; i < patternlab.patterns.length; i++) { if (patternlab.patterns[i].patternPartial === partialName) { diff --git a/packages/core/src/lib/isScopedPackage.js b/packages/core/src/lib/isScopedPackage.js index 53b607ad7..cffd1d811 100644 --- a/packages/core/src/lib/isScopedPackage.js +++ b/packages/core/src/lib/isScopedPackage.js @@ -10,7 +10,7 @@ const scopeMatch = /^@(.*)$/; * @param {string} filePath - The pathname to check * @return {Boolean} - Returns a bool when found, false othersie */ -module.exports = (filePath) => { +module.exports = filePath => { const baseName = path.basename(filePath); return scopeMatch.test(baseName); }; diff --git a/packages/core/src/lib/lineage_hunter.js b/packages/core/src/lib/lineage_hunter.js index 3a90a0f65..08b320c12 100644 --- a/packages/core/src/lib/lineage_hunter.js +++ b/packages/core/src/lib/lineage_hunter.js @@ -2,7 +2,7 @@ const getPartial = require('./get'); const logger = require('./log'); -const lineage_hunter = function () { +const lineage_hunter = function() { function findlineage(pattern, patternlab) { // As we are adding edges from pattern to ancestor patterns, ensure it is known to the graph patternlab.graph.add(pattern); @@ -10,7 +10,7 @@ const lineage_hunter = function () { //find the {{> template-name }} within patterns const matches = pattern.findPartials(); if (matches !== null) { - matches.forEach(function (match) { + matches.forEach(function(match) { //get the ancestorPattern const ancestorPattern = getPartial( pattern.findPartial(match), @@ -27,7 +27,7 @@ const lineage_hunter = function () { //create the more complex patternLineage object too const l = { lineagePattern: ancestorPattern.patternPartial, - lineagePath: '../../patterns/' + ancestorPattern.patternLink, + lineagePath: '../../patterns/' + ancestorPattern.patternLink }; if (ancestorPattern.patternState) { l.lineageState = ancestorPattern.patternState; @@ -49,7 +49,7 @@ const lineage_hunter = function () { //create the more complex patternLineage object in reverse const lr = { lineagePattern: pattern.patternPartial, - lineagePath: '../../patterns/' + pattern.patternLink, + lineagePath: '../../patterns/' + pattern.patternLink }; if (pattern.patternState) { lr.lineageState = pattern.patternState; @@ -158,12 +158,12 @@ const lineage_hunter = function () { } return { - find_lineage: function (pattern, patternlab) { + find_lineage: function(pattern, patternlab) { findlineage(pattern, patternlab); }, - cascade_pattern_states: function (patternlab) { + cascade_pattern_states: function(patternlab) { cascadePatternStates(patternlab); - }, + } }; }; diff --git a/packages/core/src/lib/list_item_hunter.js b/packages/core/src/lib/list_item_hunter.js index 7d6346161..6bf4ca0f1 100644 --- a/packages/core/src/lib/list_item_hunter.js +++ b/packages/core/src/lib/list_item_hunter.js @@ -1,6 +1,6 @@ 'use strict'; -const list_item_hunter = function () { +const list_item_hunter = function() { const logger = require('./log'); function processListItemPartials(pattern) { @@ -39,9 +39,9 @@ const list_item_hunter = function () { } return { - process_list_item_partials: function (pattern) { + process_list_item_partials: function(pattern) { return processListItemPartials(pattern); - }, + } }; }; diff --git a/packages/core/src/lib/loadPattern.js b/packages/core/src/lib/loadPattern.js index 9d6b22519..49cd160cc 100644 --- a/packages/core/src/lib/loadPattern.js +++ b/packages/core/src/lib/loadPattern.js @@ -19,7 +19,7 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const // loads a pattern from disk, creates a Pattern object from it and // all its associated files, and records it in patternlab.patterns[] -module.exports = function (relPath, patternlab) { +module.exports = function(relPath, patternlab) { const fileObject = path.parse(relPath); //extract some information @@ -147,8 +147,8 @@ module.exports = function (relPath, patternlab) { `${jsonFilename}.yaml`, `${listJsonFileName}.json`, `${listJsonFileName}.yml`, - `${listJsonFileName}.yaml`, - ].forEach((file) => { + `${listJsonFileName}.yaml` + ].forEach(file => { changes_hunter.checkLastModified(currentPattern, file); }); diff --git a/packages/core/src/lib/loaduikits.js b/packages/core/src/lib/loaduikits.js index 79de4556f..2e1147ba9 100644 --- a/packages/core/src/lib/loaduikits.js +++ b/packages/core/src/lib/loaduikits.js @@ -24,11 +24,11 @@ const readModuleFile = (uikitLocation, subPath) => { * [4] Reads files from uikit that apply to every template * @param {object} patternlab */ -module.exports = (patternlab) => { +module.exports = patternlab => { const paths = patternlab.config.paths; const uikitConfigs = _.filter(patternlab.config.uikits, 'enabled'); // [1] - uikitConfigs.forEach((uikitConfig) => { + uikitConfigs.forEach(uikitConfig => { let uikitLocation = null; if ('package' in uikitConfig) { try { @@ -49,7 +49,7 @@ module.exports = (patternlab) => { uikitConfig.name, `uikit-${uikitConfig.name}`, `@pattern-lab/${uikitConfig.name}`, - `@pattern-lab/uikit-${uikitConfig.name}`, + `@pattern-lab/uikit-${uikitConfig.name}` ]) { try { uikitLocation = resolvePackageFolder(packageName); // [2] @@ -102,7 +102,7 @@ module.exports = (patternlab) => { viewAll: readModuleFile( uikitLocation, paths.source.patternlabFiles.viewall - ), + ) }; // [4] } catch (ex) { logger.error(ex); diff --git a/packages/core/src/lib/log.js b/packages/core/src/lib/log.js index f55ff4aa1..62a64c8d3 100644 --- a/packages/core/src/lib/log.js +++ b/packages/core/src/lib/log.js @@ -21,7 +21,7 @@ const log = Object.assign( }, error(msg) { this.emit('error', chalk.red(msg)); - }, + } }, EventEmitter.prototype ); @@ -63,8 +63,8 @@ const error = log.error.bind(log); * @param {string} - a message to report * @returns {function} - a callback to be passed to a Promise's .catch() */ -const reportError = function (message) { - return function (err) { +const reportError = function(message) { + return function(err) { console.log(message); console.log(err); }; @@ -76,5 +76,5 @@ module.exports = { warning, error, log, - reportError, + reportError }; diff --git a/packages/core/src/lib/markModifiedPatterns.js b/packages/core/src/lib/markModifiedPatterns.js index 6eede313e..aa80b25bb 100644 --- a/packages/core/src/lib/markModifiedPatterns.js +++ b/packages/core/src/lib/markModifiedPatterns.js @@ -17,7 +17,7 @@ let fs = require('fs-extra'); //eslint-disable-line prefer-const * @param lastModified * @param patternlab */ -module.exports = function (lastModified, patternlab) { +module.exports = function(lastModified, patternlab) { /** * If the given array exists, apply a function to each of its elements * @param {Array} array @@ -28,13 +28,13 @@ module.exports = function (lastModified, patternlab) { array.forEach(func); } }; - const modifiedOrNot = _.groupBy(patternlab.patterns, (p) => + const modifiedOrNot = _.groupBy(patternlab.patterns, p => changes_hunter.needsRebuild(lastModified, p) ? 'modified' : 'notModified' ); // For all unmodified patterns load their rendered template output - forEachExisting(modifiedOrNot.notModified, (cleanPattern) => { - _.each(patternlab.uikits, (uikit) => { + forEachExisting(modifiedOrNot.notModified, cleanPattern => { + _.each(patternlab.uikits, uikit => { const xp = path.join( process.cwd(), uikit.outputDir, @@ -50,7 +50,7 @@ module.exports = function (lastModified, patternlab) { // For all patterns that were modified, schedule them for rebuild forEachExisting( modifiedOrNot.modified, - (p) => (p.compileState = CompileState.NEEDS_REBUILD) + p => (p.compileState = CompileState.NEEDS_REBUILD) ); return modifiedOrNot; }; diff --git a/packages/core/src/lib/markdown_parser.js b/packages/core/src/lib/markdown_parser.js index ec962e89e..4eb359f36 100644 --- a/packages/core/src/lib/markdown_parser.js +++ b/packages/core/src/lib/markdown_parser.js @@ -3,7 +3,7 @@ const md = require('markdown-it')(); const yaml = require('js-yaml'); const logger = require('./log'); -const markdown_parser = function () { +const markdown_parser = function() { /** * Converts a markdown block with frontmatter (each is optional, technically) to a well-formed object. * @param block - the ".md" file, which can contain frontmatter or not, or only frontmatter. @@ -47,9 +47,9 @@ const markdown_parser = function () { } return { - parse: function (block) { + parse: function(block) { return parseMarkdownBlock(block); - }, + } }; }; diff --git a/packages/core/src/lib/object_factory.js b/packages/core/src/lib/object_factory.js index 704474881..8dc81d0e6 100644 --- a/packages/core/src/lib/object_factory.js +++ b/packages/core/src/lib/object_factory.js @@ -27,7 +27,7 @@ const prefixMatcherDeprecationCheckHidden = /^_.+/; * @param {Patternlab} patternlab The actual pattern lab instance * @param {boolean} isPromoteToFlatPatternRun specifies if the pattern needs to be removed from its deep nesting folder */ -const Pattern = function ( +const Pattern = function( relPath, jsonFileData, patternlab, @@ -201,7 +201,7 @@ const Pattern = function ( Pattern.prototype = { // render function - acts as a proxy for the PatternEngine's - render: function (data, partials) { + render: function(data, partials) { if (!this.extendedTemplate) { this.extendedTemplate = this.template; } @@ -213,17 +213,17 @@ Pattern.prototype = { partials ); return promise - .then((results) => { + .then(results => { return results; }) - .catch((reason) => { + .catch(reason => { return Promise.reject(reason); }); } return Promise.reject('where is the engine?'); }, - registerPartial: function () { + registerPartial: function() { if (this.engine && typeof this.engine.registerPartial === 'function') { this.engine.registerPartial(this); } @@ -239,7 +239,7 @@ Pattern.prototype = { * @param {string} suffixType File suffix * @param {string} customFileExtension Custom extension */ - getPatternLink: function (patternlab, suffixType, customFileExtension) { + getPatternLink: function(patternlab, suffixType, customFileExtension) { // if no suffixType is provided, we default to rendered const suffixConfig = patternlab.config.outputFileSuffixes; const suffix = suffixType @@ -261,23 +261,23 @@ Pattern.prototype = { * The finders all delegate to the PatternEngine, which also * encapsulates all appropriate regex's */ - findPartials: function () { + findPartials: function() { return this.engine.findPartials(this); }, - findPartialsWithStyleModifiers: function () { + findPartialsWithStyleModifiers: function() { return this.engine.findPartialsWithStyleModifiers(this); }, - findPartialsWithPatternParameters: function () { + findPartialsWithPatternParameters: function() { return this.engine.findPartialsWithPatternParameters(this); }, - findListItems: function () { + findListItems: function() { return this.engine.findListItems(this); }, - findPartial: function (partialString) { + findPartial: function(partialString) { return this.engine.findPartial(partialString); }, @@ -287,7 +287,7 @@ Pattern.prototype = { * @param {Number} level Level of folder to get * @param {Object} pInfo general information about the pattern */ - getDirLevel: function (level, pInfo) { + getDirLevel: function(level, pInfo) { const items = this.subdir.split(path.sep); pInfo && pInfo.patternHasOwnDir && items.pop(); @@ -309,7 +309,7 @@ Pattern.prototype = { * * @param {Patternlab} patternlab Current patternlab instance */ - promoteFromDirectoryToFlatPattern: function (patternlab) { + promoteFromDirectoryToFlatPattern: function(patternlab) { const p = new Pattern(this.relPath, this.jsonFileData, patternlab, true); // Only reset the specific fields, not everything Object.assign(this, { @@ -320,7 +320,7 @@ Pattern.prototype = { isFlatPattern: p.isFlatPattern, flatPatternPath: p.flatPatternPath, patternPartial: p.patternPartial, - verbosePartial: p.verbosePartial, + verbosePartial: p.verbosePartial }); }, @@ -330,7 +330,7 @@ Pattern.prototype = { * @param {*} pathStr the path that needs to be checked for number prefixes * @returns the order number or 0 when no prefix is available */ - setPatternOrderDataForInfo: (pathStr) => { + setPatternOrderDataForInfo: pathStr => { const match = pathStr.match(prefixMatcherDeprecationCheckOrder); return match && match.length >= 1 ? pathStr.match(prefixMatcherDeprecationCheckOrder)[1].replace('-', '') @@ -354,11 +354,11 @@ Pattern.prototype = { pathObj.name.replace(prefixMatcher, '') || path.basename(pathObj.dir).replace(prefixMatcher, '') === pathObj.name.split('~')[0].replace(prefixMatcher, '') - : false, + : false }; info.dir = info.patternHasOwnDir ? pathObj.dir.split(path.sep).pop() : ''; - info.dirLevel = pathObj.dir.split(path.sep).filter((s) => !!s).length; + info.dirLevel = pathObj.dir.split(path.sep).filter(s => !!s).length; // Only relevant for deprecation check and message if (path.parse(pathObj.dir).base === '_meta') { @@ -397,13 +397,13 @@ Pattern.prototype = { .replace(new RegExp(`-${info.dir}$`), ''); info.verbosePartial = pathObj.dir .split(/\/|\\/, 2) - .map((o) => o.replace(prefixMatcher, '')) + .map(o => o.replace(prefixMatcher, '')) .join('/') .replace(new RegExp(`-${info.dir}$`), ''); } return info; - }, + } }; // Pattern static methods @@ -415,7 +415,7 @@ Pattern.prototype = { * @param {Object} customProps Properties to apply to new pattern * @param {Patternlab} patternlab Current patternlab instance */ -Pattern.createEmpty = function (customProps, patternlab) { +Pattern.createEmpty = function(customProps, patternlab) { let relPath = ''; if (customProps) { if (customProps.relPath) { @@ -434,7 +434,7 @@ Pattern.createEmpty = function (customProps, patternlab) { * parameters that replace the positional parameters that the Pattern * constructor takes. */ -Pattern.create = function (relPath, data, customProps, patternlab) { +Pattern.create = function(relPath, data, customProps, patternlab) { const newPattern = new Pattern(relPath || '', data || null, patternlab); return Object.assign(newPattern, customProps); }; @@ -442,10 +442,10 @@ Pattern.create = function (relPath, data, customProps, patternlab) { const CompileState = { NEEDS_REBUILD: 'needs rebuild', BUILDING: 'building', - CLEAN: 'clean', + CLEAN: 'clean' }; module.exports = { Pattern: Pattern, - CompileState: CompileState, + CompileState: CompileState }; diff --git a/packages/core/src/lib/parameter_hunter.js b/packages/core/src/lib/parameter_hunter.js index 3a6d018e5..19845b344 100644 --- a/packages/core/src/lib/parameter_hunter.js +++ b/packages/core/src/lib/parameter_hunter.js @@ -9,7 +9,7 @@ const parseLink = require('./parseLink'); const jsonCopy = require('./json_copy'); const replaceParameter = require('./replaceParameter'); -const parameter_hunter = function () { +const parameter_hunter = function() { /** * This function is really to accommodate the lax JSON-like syntax allowed by * Pattern Lab PHP for parameter submissions to partials. Unfortunately, no @@ -331,7 +331,7 @@ const parameter_hunter = function () { //todo: this no longer needs to be a promise return Promise.resolve(); }) - .catch((reason) => { + .catch(reason => { console.log(reason); logger.error(reason); }); @@ -342,9 +342,9 @@ const parameter_hunter = function () { } return { - find_parameters: function (pattern, patternlab) { + find_parameters: function(pattern, patternlab) { return findparameters(pattern, patternlab); - }, + } }; }; diff --git a/packages/core/src/lib/parseAllLinks.js b/packages/core/src/lib/parseAllLinks.js index e69383bd7..894ad6f83 100644 --- a/packages/core/src/lib/parseAllLinks.js +++ b/packages/core/src/lib/parseAllLinks.js @@ -4,7 +4,7 @@ const parseLink = require('./parseLink'); //look for pattern links included in data files. //these will be in the form of link.* WITHOUT {{}}, which would still be there from direct pattern inclusion -module.exports = function (patternlab) { +module.exports = function(patternlab) { //look for link.* such as link.pages-blog as a value patternlab.data = parseLink(patternlab, patternlab.data, 'data.json'); diff --git a/packages/core/src/lib/parseLink.js b/packages/core/src/lib/parseLink.js index 0251ffada..f473c6c1c 100644 --- a/packages/core/src/lib/parseLink.js +++ b/packages/core/src/lib/parseLink.js @@ -5,7 +5,7 @@ const path = require('path'); const logger = require('./log'); const getPartial = require('./get'); -module.exports = function (patternlab, obj, key) { +module.exports = function(patternlab, obj, key) { //check for 'link.patternPartial' const linkRE = /(?:'|")(link\.[A-z0-9-_]+)(?:'|")/g; @@ -20,7 +20,7 @@ module.exports = function (patternlab, obj, key) { const linkMatches = dataObjAsString.match(linkRE); if (linkMatches) { - linkMatches.forEach((dataLink) => { + linkMatches.forEach(dataLink => { if (dataLink && dataLink.split('.').length >= 2) { //get the partial the link refers to const linkPatternPartial = dataLink.split('.')[1].replace(/'|"/g, ''); @@ -34,7 +34,7 @@ module.exports = function (patternlab, obj, key) { .replace('viewall-', '') .replace('-all', ''); const pattern = patternlab.patterns.find( - (p) => p.patternGroup === partial + p => p.patternGroup === partial ); if (pattern) { @@ -45,7 +45,7 @@ module.exports = function (patternlab, obj, key) { // group and subgroup there will be a view all page for that group) const partial = linkPatternPartial.replace('viewall-', ''); const pattern = patternlab.patterns.find( - (p) => `${p.patternGroup}-${p.patternSubgroup}` === partial + p => `${p.patternGroup}-${p.patternSubgroup}` === partial ); if (pattern) { diff --git a/packages/core/src/lib/pattern_exporter.js b/packages/core/src/lib/pattern_exporter.js index 221415bf8..12b556076 100644 --- a/packages/core/src/lib/pattern_exporter.js +++ b/packages/core/src/lib/pattern_exporter.js @@ -14,7 +14,10 @@ function exportSinglePattern(patternlab, pattern) { // Extract the first part of the pattern partial as the directory in which // it should go. patternDir = path.join(patternDir, pattern.patternPartial.split('-')[0]); - patternName = pattern.patternPartial.split('-').slice(1).join('-'); + patternName = pattern.patternPartial + .split('-') + .slice(1) + .join('-'); } if (patternlab.config.patternExportRaw) { @@ -28,7 +31,7 @@ function exportSinglePattern(patternlab, pattern) { ); } -const pattern_exporter = function () { +const pattern_exporter = function() { /** * Exports all pattern's final HTML as defined in patternlab-config.json to desired location. * Originally created to help facilitate easier consumption by jekyll. @@ -63,9 +66,9 @@ const pattern_exporter = function () { } return { - export_patterns: function (patternlab) { + export_patterns: function(patternlab) { exportPatterns(patternlab); - }, + } }; }; diff --git a/packages/core/src/lib/pattern_graph.js b/packages/core/src/lib/pattern_graph.js index a5320292d..848f6f8c4 100644 --- a/packages/core/src/lib/pattern_graph.js +++ b/packages/core/src/lib/pattern_graph.js @@ -35,11 +35,11 @@ const PATTERN_GRAPH_VERSION = 1; * @see PatternGraph#fromJson * @see #540 */ -const PatternGraph = function (graph, timestamp, version) { +const PatternGraph = function(graph, timestamp, version) { this.graph = graph || new Graph({ - directed: true, + directed: true }); this.graph.setDefaultEdgeLabel({}); @@ -51,7 +51,7 @@ const PatternGraph = function (graph, timestamp, version) { }; // shorthand. Use relPath as it is always unique, even with subPatternGroup -const nodeName = (p) => (p instanceof Pattern ? p.relPath : p); +const nodeName = p => (p instanceof Pattern ? p.relPath : p); PatternGraph.prototype = { /** @@ -61,11 +61,11 @@ PatternGraph.prototype = { * * @see {@link https://github.com/pattern-lab/patternlab-node/issues/580|Issue #580} */ - sync: function () { + sync: function() { // Remove any patterns that are in the graph data, but that haven't been discovered when // walking all patterns iteratively - const nodesToRemove = this.nodes().filter((n) => !this.patterns.has(n)); - nodesToRemove.forEach((n) => this.remove(n)); + const nodesToRemove = this.nodes().filter(n => !this.patterns.has(n)); + nodesToRemove.forEach(n => this.remove(n)); return nodesToRemove; }, @@ -73,7 +73,7 @@ PatternGraph.prototype = { * Creates an independent copy of the graph where nodes and edges can be modified without * affecting the source. */ - clone: function () { + clone: function() { const json = graphlib.json.write(this.graph); const graph = graphlib.json.read(json); return new PatternGraph(graph, this.timestamp, this.version); @@ -85,18 +85,18 @@ PatternGraph.prototype = { * * @param {Pattern} pattern */ - add: function (pattern) { + add: function(pattern) { const n = nodeName(pattern); if (!this.patterns.has(n)) { this.graph.setNode(n, { - compileState: pattern.compileState, + compileState: pattern.compileState }); this.patterns.put(pattern); } }, - remove: function (pattern) { + remove: function(pattern) { const n = nodeName(pattern); this.graph.removeNode(n); this.patterns.remove(n); @@ -106,8 +106,8 @@ PatternGraph.prototype = { * Removes nodes from this graph for which the given predicate function returns false. * @param {function} fn which takes a node name as argument */ - filter: function (fn) { - this.graph.nodes().forEach((n) => { + filter: function(fn) { + this.graph.nodes().forEach(n => { if (!fn(n)) { this.remove(n); } @@ -123,7 +123,7 @@ PatternGraph.prototype = { * * @throws {Error} If the pattern is unknown */ - link: function (patternFrom, patternTo) { + link: function(patternFrom, patternTo) { const nameFrom = nodeName(patternFrom); const nameTo = nodeName(patternTo); for (const name of [nameFrom, nameTo]) { @@ -141,7 +141,7 @@ PatternGraph.prototype = { * * @return {boolean} */ - hasLink: function (patternFrom, patternTo) { + hasLink: function(patternFrom, patternTo) { const nameFrom = nodeName(patternFrom); const nameTo = nodeName(patternTo); return this.graph.hasEdge(nameFrom, nameTo); @@ -157,8 +157,8 @@ PatternGraph.prototype = { * @return {Array} An Array of {@link Pattern}s in the order by which the changed patters must be * compiled. */ - compileOrder: function () { - const compileStateFilter = function (patterns, n) { + compileOrder: function() { + const compileStateFilter = function(patterns, n) { const node = patterns.get(n); return node.compileState !== CompileState.CLEAN; }; @@ -169,14 +169,14 @@ PatternGraph.prototype = { * where "->" means "included by"). */ const compileGraph = new Graph({ - directed: true, + directed: true }); const nodes = this.graph.nodes(); - const changedNodes = nodes.filter((n) => + const changedNodes = nodes.filter(n => compileStateFilter(this.patterns, n) ); - this.nodes2patterns(changedNodes).forEach((pattern) => { + this.nodes2patterns(changedNodes).forEach(pattern => { const patternNode = nodeName(pattern); if (!compileGraph.hasNode(patternNode)) { compileGraph.setNode(patternNode); @@ -211,7 +211,7 @@ PatternGraph.prototype = { * @param fn A function that takes the currently viewed pattern and node data. Allows synching data * between patterns and node metadata. */ - applyReverse: function (pattern, fn) { + applyReverse: function(pattern, fn) { for (const p of this.lineageR(pattern)) { fn(p, pattern); this.applyReverse(p, fn); @@ -225,7 +225,7 @@ PatternGraph.prototype = { * * @return [null|Pattern] */ - node: function (pattern) { + node: function(pattern) { return this.graph.node(nodeName(pattern)); }, @@ -234,8 +234,8 @@ PatternGraph.prototype = { * @param nodes {Array} * @return {Array} An Array of Patterns */ - nodes2patterns: function (nodes) { - return nodes.map((n) => this.patterns.get(n)); + nodes2patterns: function(nodes) { + return nodes.map(n => this.patterns.get(n)); }, // TODO cache result in a Map[String, Array]? @@ -246,7 +246,7 @@ PatternGraph.prototype = { * @param pattern * @return {*|Array} */ - lineage: function (pattern) { + lineage: function(pattern) { const nodes = this.graph.successors(nodeName(pattern)); return this.nodes2patterns(nodes); }, @@ -256,7 +256,7 @@ PatternGraph.prototype = { * @param {Pattern} pattern * @return {*|Array} */ - lineageR: function (pattern) { + lineageR: function(pattern) { const nodes = this.graph.predecessors(nodeName(pattern)); return this.nodes2patterns(nodes); }, @@ -267,9 +267,9 @@ PatternGraph.prototype = { * * @see {@link PatternGraph.lineage(pattern)} */ - lineageIndex: function (pattern) { + lineageIndex: function(pattern) { const lineage = this.lineage(pattern); - return lineage.map((p) => p.patternPartial); + return lineage.map(p => p.patternPartial); }, /** @@ -280,36 +280,36 @@ PatternGraph.prototype = { * * @see {@link PatternGraph.lineageRIndex(pattern)} */ - lineageRIndex: function (pattern) { + lineageRIndex: function(pattern) { const lineageR = this.lineageR(pattern); - return lineageR.map((p) => p.patternPartial); + return lineageR.map(p => p.patternPartial); }, /** * Creates an object representing the graph and meta data. * @returns {{timestamp: number, graph}} */ - toJson: function () { + toJson: function() { return { version: this.version, timestamp: this.timestamp, - graph: graphlib.json.write(this.graph), + graph: graphlib.json.write(this.graph) }; }, /** * @return {Array} An array of all node names. */ - nodes: function () { + nodes: function() { return this.graph.nodes(); }, /** * Updates the version to the most recent one */ - upgradeVersion: function () { + upgradeVersion: function() { this.version = PATTERN_GRAPH_VERSION; - }, + } }; /** @@ -317,7 +317,7 @@ PatternGraph.prototype = { * @param {int} [version=PATTERN_GRAPH_VERSION] * @return {PatternGraph} */ -PatternGraph.empty = function (version) { +PatternGraph.empty = function(version) { return new PatternGraph(null, 0, version || PATTERN_GRAPH_VERSION); }; @@ -326,7 +326,7 @@ PatternGraph.empty = function (version) { * @param {PatternGraph|Object} graphOrJson * @return {boolean} */ -PatternGraph.checkVersion = function (graphOrJson) { +PatternGraph.checkVersion = function(graphOrJson) { return graphOrJson.version === PATTERN_GRAPH_VERSION; }; @@ -346,7 +346,7 @@ function VersionMismatch(oldVersion) { * @param {object} o The JSON object to read from * @return {PatternGraph} */ -PatternGraph.fromJson = function (o) { +PatternGraph.fromJson = function(o) { if (!PatternGraph.checkVersion(o)) { throw new VersionMismatch(o.version); } @@ -360,7 +360,7 @@ PatternGraph.fromJson = function (o) { * @param {string} [fileName='dependencyGraph.json'] Name of the graph file * @return {string} */ -PatternGraph.resolveJsonGraphFile = function ( +PatternGraph.resolveJsonGraphFile = function( filePath = process.cwd(), fileName = 'dependencyGraph.json' ) { @@ -377,7 +377,7 @@ PatternGraph.resolveJsonGraphFile = function ( * @see {@link PatternGraph.fromJson} * @see {@link PatternGraph.resolveJsonGraphFile} */ -PatternGraph.loadFromFile = function (filePath, fileName) { +PatternGraph.loadFromFile = function(filePath, fileName) { const jsonGraphFile = this.resolveJsonGraphFile(filePath, fileName); // File is fresh, so simply construct an empty graph in memory @@ -399,7 +399,7 @@ PatternGraph.loadFromFile = function (filePath, fileName) { * * @see {@link PatternGraph.resolveJsonGraphFile} */ -PatternGraph.storeToFile = function (patternlab) { +PatternGraph.storeToFile = function(patternlab) { if (process.env.PATTERNLAB_ENV === 'CI') { return; } @@ -413,7 +413,7 @@ PatternGraph.storeToFile = function (patternlab) { * @param patternlab @ @param {string} fileName Output filename */ -PatternGraph.exportToDot = function (patternlab, fileName) { +PatternGraph.exportToDot = function(patternlab, fileName) { const dotFile = this.resolveJsonGraphFile(undefined, fileName); const g = PatternGraphDot.generate(patternlab.graph); fs.outputFileSync(dotFile, g); @@ -421,5 +421,5 @@ PatternGraph.exportToDot = function (patternlab, fileName) { module.exports = { PatternGraph: PatternGraph, - PATTERN_GRAPH_VERSION: PATTERN_GRAPH_VERSION, + PATTERN_GRAPH_VERSION: PATTERN_GRAPH_VERSION }; diff --git a/packages/core/src/lib/pattern_graph_dot.js b/packages/core/src/lib/pattern_graph_dot.js index f4da40e18..33c11fe7d 100644 --- a/packages/core/src/lib/pattern_graph_dot.js +++ b/packages/core/src/lib/pattern_graph_dot.js @@ -14,7 +14,7 @@ function header() { 'rankdir=LR;', 'ranksep="4 equally·";', 'node [style=filled,color=white];', - 'edge [style=dotted constraint=false]', + 'edge [style=dotted constraint=false]' ]; } @@ -23,7 +23,7 @@ function header() { * @param name * @return {string} */ -const niceKey = function (name) { +const niceKey = function(name) { return 'O' + name.replace('-', ''); }; @@ -69,7 +69,7 @@ function subGraph(group, patterns) { patterns.map(addNode).join(''), //patterns.map(p => "\"" + p.name + "\"").join(" -> ") + "[style=invis]", - '}', + '}' ]; } @@ -84,7 +84,7 @@ const PatternGraphDot = {}; * @param patternGraph * @return {string} */ -PatternGraphDot.generate = function (patternGraph) { +PatternGraphDot.generate = function(patternGraph) { const g = patternGraph.graph; const patterns = patternGraph.patterns; const buckets = new Map(); @@ -93,7 +93,7 @@ PatternGraphDot.generate = function (patternGraph) { 'firebrick', 'slateblue', 'darkgoldenrod', - 'black', + 'black' ]; const colorMap = new Map(); let colIdx = 0; diff --git a/packages/core/src/lib/pattern_registry.js b/packages/core/src/lib/pattern_registry.js index 041cb109e..047551af1 100644 --- a/packages/core/src/lib/pattern_registry.js +++ b/packages/core/src/lib/pattern_registry.js @@ -4,7 +4,7 @@ * Allows lookups for patterns via a central registry. * @constructor */ -const PatternRegistry = function () { +const PatternRegistry = function() { this.key2pattern = new Map(); /** For lookups by {@link Pattern#partialKey} */ @@ -12,15 +12,15 @@ const PatternRegistry = function () { }; PatternRegistry.prototype = { - allPatterns: function () { + allPatterns: function() { return Array.from(this.key2pattern.values()); }, - has: function (name) { + has: function(name) { return this.key2pattern.has(name); }, - get: function (name) { + get: function(name) { return this.key2pattern.get(name); }, @@ -28,18 +28,18 @@ PatternRegistry.prototype = { * Adds the given pattern to the registry. If a pattern with the same key exists, it is replaced. * @param pattern {Pattern|*} */ - put: function (pattern) { + put: function(pattern) { const name = PatternRegistry.partialName(pattern); this.partials.set(name, pattern); const key = PatternRegistry.patternKey(pattern); this.key2pattern.set(key, pattern); }, - remove: function (name) { + remove: function(name) { this.key2pattern.delete(name); }, - getPartial: function (partialName) { + getPartial: function(partialName) { /* Code in here has been moved from getPartial() to prepare for some refactoring. There are a few advantages to this method: @@ -80,10 +80,10 @@ PatternRegistry.prototype = { } } return undefined; - }, + } }; -PatternRegistry.patternKey = function (pattern) { +PatternRegistry.patternKey = function(pattern) { return pattern.relPath; }; @@ -93,7 +93,7 @@ PatternRegistry.patternKey = function (pattern) { * @param pattern {Pattern} * @return {string} */ -PatternRegistry.partialName = function (pattern) { +PatternRegistry.partialName = function(pattern) { return pattern.patternPartial; }; diff --git a/packages/core/src/lib/patternlab.js b/packages/core/src/lib/patternlab.js index 405da4fc9..15c9f3cf5 100644 --- a/packages/core/src/lib/patternlab.js +++ b/packages/core/src/lib/patternlab.js @@ -89,7 +89,7 @@ module.exports = class PatternLab { const outputFileSuffixes = { rendered: '.rendered', rawTemplate: '', - markupOnly: '.markup-only', + markupOnly: '.markup-only' }; if (!patternlab.config.outputFileSuffixes) { @@ -215,10 +215,10 @@ module.exports = class PatternLab { } writePatternFiles(headHTML, pattern, footerHTML, outputBasePath) { - const nullFormatter = (str) => str; - const defaultFormatter = (codeString) => + const nullFormatter = str => str; + const defaultFormatter = codeString => cleanHtml(codeString, { indent_size: 2 }); - const makePath = (type) => + const makePath = type => path.join( this.config.paths.public.patterns, pattern.getPatternLink(this, type) @@ -231,34 +231,34 @@ module.exports = class PatternLab { ? { rendered: eng.renderedCodeFormatter || defaultFormatter, rawTemplate: eng.rawTemplateCodeFormatter || defaultFormatter, - markupOnly: eng.markupOnlyCodeFormatter || defaultFormatter, + markupOnly: eng.markupOnlyCodeFormatter || defaultFormatter } : { rendered: nullFormatter, rawTemplate: nullFormatter, - markupOnly: nullFormatter, + markupOnly: nullFormatter }; //prepare the path and contents of each output file const outputFiles = [ { path: makePath('rendered'), - content: formatters.rendered(patternPage, pattern), + content: formatters.rendered(patternPage, pattern) }, { path: makePath('rawTemplate'), - content: formatters.rawTemplate(pattern.template, pattern), + content: formatters.rawTemplate(pattern.template, pattern) }, { path: makePath('markupOnly'), - content: formatters.markupOnly(pattern.patternPartialCode, pattern), - }, + content: formatters.markupOnly(pattern.patternPartialCode, pattern) + } ].concat( eng.addOutputFiles ? eng.addOutputFiles(this.config.paths, this) : [] ); //write the compiled template to the public patterns directory - outputFiles.forEach((outFile) => + outputFiles.forEach(outFile => fs.outputFileSync( path.join(process.cwd(), outputBasePath, outFile.path), outFile.content @@ -274,22 +274,22 @@ module.exports = class PatternLab { */ registerLogger(logLevel) { if (logLevel === undefined) { - logger.log.on('info', (msg) => console.info(msg)); - logger.log.on('warning', (msg) => console.info(msg)); - logger.log.on('error', (msg) => console.info(msg)); + logger.log.on('info', msg => console.info(msg)); + logger.log.on('warning', msg => console.info(msg)); + logger.log.on('error', msg => console.info(msg)); } else { if (logLevel === 'quiet') { return; } switch (logLevel) { case 'debug': - logger.log.on('debug', (msg) => console.info(msg)); + logger.log.on('debug', msg => console.info(msg)); case 'info': - logger.log.on('info', (msg) => console.info(msg)); + logger.log.on('info', msg => console.info(msg)); case 'warning': - logger.log.on('warning', (msg) => console.info(msg)); + logger.log.on('warning', msg => console.info(msg)); case 'error': - logger.log.on('error', (msg) => console.info(msg)); + logger.log.on('error', msg => console.info(msg)); } } } @@ -312,7 +312,7 @@ module.exports = class PatternLab { // deleted pattern would still be present in the patterns array this.patterns = []; - const promiseAllPatternFiles = new Promise(function (resolve) { + const promiseAllPatternFiles = new Promise(function(resolve) { dive( patterns_dir, (err, file) => { @@ -338,7 +338,7 @@ module.exports = class PatternLab { }); return promiseAllPatternFiles.then(() => { return Promise.all( - this.patterns.map((pattern) => { + this.patterns.map(pattern => { return processIterative(pattern, self); }) ).then(() => { @@ -353,7 +353,7 @@ module.exports = class PatternLab { processAllPatternsRecursive(patterns_dir) { const self = this; - const promiseAllPatternFiles = new Promise(function (resolve) { + const promiseAllPatternFiles = new Promise(function(resolve) { dive( patterns_dir, (err, file) => { diff --git a/packages/core/src/lib/plugin_manager.js b/packages/core/src/lib/plugin_manager.js index f79307beb..adb802953 100644 --- a/packages/core/src/lib/plugin_manager.js +++ b/packages/core/src/lib/plugin_manager.js @@ -1,6 +1,6 @@ 'use strict'; -const plugin_manager = function () { +const plugin_manager = function() { const logger = require('./log'); /** @@ -9,7 +9,7 @@ const plugin_manager = function () { */ function initializePlugins(patternlab) { const foundPlugins = Object.keys(patternlab.config.plugins || {}); - foundPlugins.forEach((plugin) => { + foundPlugins.forEach(plugin => { logger.info(`Found plugin: ${plugin}`); logger.info(`Attempting to load and initialize plugin.`); const pluginModule = require(plugin); @@ -19,8 +19,8 @@ const plugin_manager = function () { async function raiseEvent(patternlab, eventName, args) { patternlab.events.emit(eventName, args); - await (async function () { - const hookHandlers = (patternlab.hooks[eventName] || []).map((h) => + await (async function() { + const hookHandlers = (patternlab.hooks[eventName] || []).map(h => h(args) ); @@ -29,12 +29,12 @@ const plugin_manager = function () { } return { - intialize_plugins: (patternlab) => { + intialize_plugins: patternlab => { initializePlugins(patternlab); }, raiseEvent: async (patternlab, eventName, ...args) => { await raiseEvent(patternlab, eventName, args); - }, + } }; }; diff --git a/packages/core/src/lib/processIterative.js b/packages/core/src/lib/processIterative.js index e2433b1c8..1c65c85ca 100644 --- a/packages/core/src/lib/processIterative.js +++ b/packages/core/src/lib/processIterative.js @@ -5,7 +5,7 @@ const pph = require('./pseudopattern_hunter'); // This is now solely for analysis; loading of the pattern file is // above, in loadPatternIterative() -module.exports = function (pattern, patternlab) { +module.exports = function(pattern, patternlab) { //look for a pseudo pattern by checking if there is a file //containing same name, with ~ in it, ending in .json return pph diff --git a/packages/core/src/lib/processMetaPattern.js b/packages/core/src/lib/processMetaPattern.js index dea8fbe70..f793a103a 100644 --- a/packages/core/src/lib/processMetaPattern.js +++ b/packages/core/src/lib/processMetaPattern.js @@ -9,7 +9,7 @@ const logger = require('./log'); //this may be mocked in unit tests, so let it be overridden let fs = require('fs-extra'); // eslint-disable-line -module.exports = function (fileName, metaType, patternlab) { +module.exports = function(fileName, metaType, patternlab) { const metaPath = path.resolve(patternlab.config.paths.source.meta, fileName); const metaPattern = new Pattern(metaPath, null, patternlab); metaPattern.template = fs.readFileSync(metaPath, 'utf8'); @@ -19,7 +19,7 @@ module.exports = function (fileName, metaType, patternlab) { .then(() => { patternlab[metaType] = metaPattern; }) - .catch((reason) => { + .catch(reason => { logger.warning( `Could not find the user-editable template ${fileName}, currently configured to be at ${patternlab.config.paths.source.meta}. Your configured path may be incorrect (check paths.source.meta in your config file), the file may have been deleted, or it may have been left in the wrong place during a migration or update.` ); diff --git a/packages/core/src/lib/processRecursive.js b/packages/core/src/lib/processRecursive.js index 3c541c85c..97c4ac560 100644 --- a/packages/core/src/lib/processRecursive.js +++ b/packages/core/src/lib/processRecursive.js @@ -4,7 +4,7 @@ const logger = require('./log'); const decompose = require('./decompose'); const getPartial = require('./get'); -module.exports = function (file, patternlab) { +module.exports = function(file, patternlab) { //find current pattern in patternlab object using file as a partial const currentPattern = getPartial(file, patternlab, false); @@ -19,7 +19,7 @@ module.exports = function (file, patternlab) { } //call our helper method to actually unravel the pattern with any partials - return decompose(currentPattern, patternlab).catch((reason) => { + return decompose(currentPattern, patternlab).catch(reason => { console.log(reason); logger.error(reason); }); diff --git a/packages/core/src/lib/pseudopattern_hunter.js b/packages/core/src/lib/pseudopattern_hunter.js index 5e510de66..39dbd89b7 100644 --- a/packages/core/src/lib/pseudopattern_hunter.js +++ b/packages/core/src/lib/pseudopattern_hunter.js @@ -15,9 +15,9 @@ const changes_hunter = new ch(); const yaml = require('js-yaml'); const dataMerger = require('./dataMerger'); -const pseudopattern_hunter = function () {}; +const pseudopattern_hunter = function() {}; -pseudopattern_hunter.prototype.find_pseudopatterns = function ( +pseudopattern_hunter.prototype.find_pseudopatterns = function( currentPattern, patternlab ) { @@ -33,7 +33,7 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function ( const pseudoPatterns = glob.sync(needle, { cwd: paths.source.patterns, debug: false, - nodir: true, + nodir: true }); if (pseudoPatterns.length > 0) { @@ -70,7 +70,10 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function ( const variantName = pseudoPatterns[i] .substring(pseudoPatterns[i].indexOf('~') + 1) .split('.')[0]; - const variantExtension = pseudoPatterns[i].split('.').slice(-1).pop(); + const variantExtension = pseudoPatterns[i] + .split('.') + .slice(-1) + .pop(); const variantFilePath = path.join( currentPattern.subdir, currentPattern.fileName + '~' + variantName + '.' + variantExtension @@ -94,7 +97,7 @@ pseudopattern_hunter.prototype.find_pseudopatterns = function ( lastModified: Math.max(currentPattern.lastModified, lm.mtime), // use the same template engine as the non-variant - engine: currentPattern.engine, + engine: currentPattern.engine }, patternlab ); diff --git a/packages/core/src/lib/readDocumentation.js b/packages/core/src/lib/readDocumentation.js index 1159a0347..f2535cf4f 100644 --- a/packages/core/src/lib/readDocumentation.js +++ b/packages/core/src/lib/readDocumentation.js @@ -14,7 +14,7 @@ const markdown_parser = new mp(); const FILE_EXTENSION = '.md'; const GROUP_DOC_PREFIX = '_'; -module.exports = function (pattern, patternlab, isVariant) { +module.exports = function(pattern, patternlab, isVariant) { try { const markdownFileName = path.resolve( patternlab.config.paths.source.patterns, diff --git a/packages/core/src/lib/render.js b/packages/core/src/lib/render.js index b73d5369f..3ba1f2589 100644 --- a/packages/core/src/lib/render.js +++ b/packages/core/src/lib/render.js @@ -2,7 +2,7 @@ const logger = require('./log'); -module.exports = function (pattern, data, partials) { +module.exports = function(pattern, data, partials) { logger.debug( `render: ${ pattern.patternPartial !== '-.' diff --git a/packages/core/src/lib/replaceParameter.js b/packages/core/src/lib/replaceParameter.js index b045b58b2..7b0cd6734 100644 --- a/packages/core/src/lib/replaceParameter.js +++ b/packages/core/src/lib/replaceParameter.js @@ -2,7 +2,7 @@ const logger = require('./log'); -module.exports = function (template, prop, data) { +module.exports = function(template, prop, data) { let t = template; const valueRE = new RegExp(`{{{?\\s*[${prop}]+\\s*}?}}`); diff --git a/packages/core/src/lib/resolver.js b/packages/core/src/lib/resolver.js index d70961413..994e5cbf3 100644 --- a/packages/core/src/lib/resolver.js +++ b/packages/core/src/lib/resolver.js @@ -23,7 +23,7 @@ const resolvePackageLocations = () => { const resolveFileInPackage = (packageName, ...pathElements) => { if (process.env.projectDir) { return require.resolve(path.join(packageName, ...pathElements), { - paths: resolvePackageLocations(), + paths: resolvePackageLocations() }); } else { return require.resolve(path.join(packageName, ...pathElements)); @@ -34,7 +34,7 @@ const resolveFileInPackage = (packageName, ...pathElements) => { * @func resolvePackageFolder * Resolves the location of a package on disc */ -const resolvePackageFolder = (packageName) => { +const resolvePackageFolder = packageName => { return path.dirname(resolveFileInPackage(packageName, 'package.json')); }; @@ -49,5 +49,5 @@ const resolveDirInPackage = (packageName, ...pathElements) => { module.exports = { resolveFileInPackage, resolveDirInPackage, - resolvePackageFolder, + resolvePackageFolder }; diff --git a/packages/core/src/lib/server.js b/packages/core/src/lib/server.js index 58bef01a4..c8b41e06c 100644 --- a/packages/core/src/lib/server.js +++ b/packages/core/src/lib/server.js @@ -6,7 +6,7 @@ const liveServer = require('@pattern-lab/live-server'); const events = require('./events'); const logger = require('./log'); -const server = (patternlab) => { +const server = patternlab => { const _module = { serve: () => { let serverReady = false; @@ -17,10 +17,10 @@ const server = (patternlab) => { file: 'index.html', logLevel: 0, // errors only wait: 1000, - port: 3000, + port: 3000 }; - const servers = Object.keys(patternlab.uikits).map((kit) => { + const servers = Object.keys(patternlab.uikits).map(kit => { const uikit = patternlab.uikits[kit]; defaults.root = path.resolve( path.join( @@ -36,30 +36,6 @@ const server = (patternlab) => { patternlab.config.paths.public.root ) ); - defaults.assets = [ - path.resolve( - path.join( - process.cwd(), - patternlab.config.paths.source.js, - '**', - '*.js' // prevent preprocessors like typescript from reloading - ) - ), - path.resolve( - path.join(process.cwd(), patternlab.config.paths.source.images) - ), - path.resolve( - path.join(process.cwd(), patternlab.config.paths.source.fonts) - ), - path.resolve( - path.join( - process.cwd(), - patternlab.config.paths.source.css, - '**', - '*.css' // prevent preprocessors from reloading - ) - ), - ]; // allow for overrides should they exist inside patternlab-config.json const liveServerConfig = Object.assign( @@ -74,7 +50,7 @@ const server = (patternlab) => { if (serverReady) { _module.reload({ file: '', - action: 'reload', + action: 'reload' }); } }); @@ -106,10 +82,10 @@ const server = (patternlab) => { return Promise.all(servers); }, - reload: (data) => { + reload: data => { const _data = data || { file: '', - action: '', + action: '' }; return new Promise((resolve, reject) => { let action; @@ -132,9 +108,9 @@ const server = (patternlab) => { refreshCSS: () => { return _module.reload({ file: '', - action: 'refresh', + action: 'refresh' }); - }, + } }; return _module; }; diff --git a/packages/core/src/lib/starterkit_manager.js b/packages/core/src/lib/starterkit_manager.js index 737aadd9a..d5d6bb8ad 100644 --- a/packages/core/src/lib/starterkit_manager.js +++ b/packages/core/src/lib/starterkit_manager.js @@ -1,6 +1,6 @@ 'use strict'; -const starterkit_manager = function (config) { +const starterkit_manager = function(config) { const path = require('path'); const fetch = require('node-fetch'); const fs = require('fs-extra'); @@ -74,11 +74,11 @@ const starterkit_manager = function (config) { { method: 'GET', headers: { - Accept: 'application/json', - }, + Accept: 'application/json' + } } ) - .then(function (res) { + .then(function(res) { const contentType = res.headers.get('content-type'); if (contentType && contentType.indexOf('application/json') === -1) { throw new TypeError( @@ -87,15 +87,15 @@ const starterkit_manager = function (config) { } return res.json(); }) - .then(function (json) { + .then(function(json) { if (!json.items || !Array.isArray(json.items)) { return false; } - return json.items.map(function (repo) { + return json.items.map(function(repo) { return { name: repo.name, url: repo.html_url }; }); }) - .catch(function (err) { + .catch(function(err) { logger.error(err); return false; }); @@ -111,31 +111,29 @@ const starterkit_manager = function (config) { //TODO review for deletion or convert callers to use findModules() function detectStarterKits() { const node_modules_path = path.join(process.cwd(), 'node_modules'); - const npm_modules = fs - .readdirSync(node_modules_path) - .filter(function (dir) { - const module_path = path.join(process.cwd(), 'node_modules', dir); - return ( - fs.statSync(module_path).isDirectory() && - dir.indexOf('starterkit-') === 0 - ); - }); + const npm_modules = fs.readdirSync(node_modules_path).filter(function(dir) { + const module_path = path.join(process.cwd(), 'node_modules', dir); + return ( + fs.statSync(module_path).isDirectory() && + dir.indexOf('starterkit-') === 0 + ); + }); return npm_modules; } return { - load_starterkit: function (starterkitName, clean) { + load_starterkit: function(starterkitName, clean) { loadStarterKit(starterkitName, clean); }, - list_starterkits: function () { + list_starterkits: function() { return listStarterkits(); }, - pack_starterkit: function () { + pack_starterkit: function() { packStarterkit(); }, - detect_starterkits: function () { + detect_starterkits: function() { return detectStarterKits(); - }, + } }; }; diff --git a/packages/core/src/lib/style_modifier_hunter.js b/packages/core/src/lib/style_modifier_hunter.js index bd62c773a..1e3965ba3 100644 --- a/packages/core/src/lib/style_modifier_hunter.js +++ b/packages/core/src/lib/style_modifier_hunter.js @@ -2,7 +2,7 @@ const logger = require('./log'); -const style_modifier_hunter = function () { +const style_modifier_hunter = function() { /** * Modifies a patterns partial with any styleModifiers found on the supplied partial * @@ -36,9 +36,9 @@ const style_modifier_hunter = function () { } return { - consume_style_modifier: function (pattern, partial, patternlab) { + consume_style_modifier: function(pattern, partial, patternlab) { consumestylemodifier(pattern, partial, patternlab); - }, + } }; }; diff --git a/packages/core/src/lib/watchAssets.js b/packages/core/src/lib/watchAssets.js index 6f07626e7..f46870bed 100644 --- a/packages/core/src/lib/watchAssets.js +++ b/packages/core/src/lib/watchAssets.js @@ -10,7 +10,7 @@ let copyFile = require('./copyFile'); // eslint-disable-line prefer-const function onWatchTripped(patternlab, p, assetBase, basePath, dir, copyOptions) { const subPath = p.replace(assetBase, ''); - _.each(patternlab.uikits, (uikit) => { + _.each(patternlab.uikits, uikit => { const destination = path.resolve( basePath, uikit.outputDir, @@ -50,17 +50,17 @@ const watchAssets = ( ignoreInitial: false, awaitWriteFinish: { stabilityThreshold: 200, - pollInterval: 100, + pollInterval: 100 }, - persistent: !watchOnce, + persistent: !watchOnce }); //watch for changes and copy assetWatcher - .on('add', (p) => { + .on('add', p => { onWatchTripped(patternlab, p, assetBase, basePath, dir, copyOptions); }) - .on('change', (p) => { + .on('change', p => { onWatchTripped(patternlab, p, assetBase, basePath, dir, copyOptions); }); diff --git a/packages/core/src/lib/watchPatternLabFiles.js b/packages/core/src/lib/watchPatternLabFiles.js index c2eb681ab..17546ac68 100644 --- a/packages/core/src/lib/watchPatternLabFiles.js +++ b/packages/core/src/lib/watchPatternLabFiles.js @@ -18,13 +18,13 @@ const watchPatternLabFiles = ( // watch global structures, such as _data/* and _meta/ const globalSources = [ assetDirectories.source.data, - assetDirectories.source.meta, + assetDirectories.source.meta ]; - const globalPaths = globalSources.map((globalSource) => + const globalPaths = globalSources.map(globalSource => path.join(path.resolve(basePath, globalSource), '*') ); - _.each(globalPaths, (globalPath) => { + _.each(globalPaths, globalPath => { logger.debug(`Pattern Lab is watching ${globalPath} for changes!`); if (patternlab.watchers[globalPath]) { @@ -36,37 +36,37 @@ const watchPatternLabFiles = ( ignoreInitial: true, awaitWriteFinish: { stabilityThreshold: 200, - pollInterval: 100, + pollInterval: 100 }, - persistent: !watchOnce, + persistent: !watchOnce }); //watch for changes and rebuild globalWatcher - .on('addDir', async (p) => { + .on('addDir', async p => { await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_GLOBAL_CHANGE, { - file: p, + file: p } ); }) - .on('add', async (p) => { + .on('add', async p => { await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_GLOBAL_CHANGE, { - file: p, + file: p } ); }) - .on('change', async (p) => { + .on('change', async p => { await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_GLOBAL_CHANGE, { - file: p, + file: p } ); }); @@ -78,13 +78,13 @@ const watchPatternLabFiles = ( const baseFileExtensions = ['.json', '.yml', '.yaml', '.md']; const patternWatches = baseFileExtensions .concat(patternlab.engines.getSupportedFileExtensions()) - .map((dotExtension) => + .map(dotExtension => path.join( path.resolve(basePath, assetDirectories.source.patterns), `/**/*${dotExtension}` ) ); - _.each(patternWatches, (patternWatchPath) => { + _.each(patternWatches, patternWatchPath => { logger.debug( `Pattern Lab is watching ${patternWatchPath} for changes - local!` ); @@ -98,61 +98,61 @@ const watchPatternLabFiles = ( ignoreInitial: true, awaitWriteFinish: { stabilityThreshold: 200, - pollInterval: 100, + pollInterval: 100 }, - persistent: !watchOnce, + persistent: !watchOnce }); //watch for changes and rebuild patternWatcher - .on('addDir', async (p) => { + .on('addDir', async p => { await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_PATTERN_CHANGE, { - file: p, + file: p } ); }) - .on('add', async (p) => { + .on('add', async p => { await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_PATTERN_CHANGE, { - file: p, + file: p } ); }) - .on('change', async (p) => { + .on('change', async p => { await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_PATTERN_CHANGE, { - file: p, + file: p } ); }) // the watcher does not react on unlink and unlinkDir // events, so patterns are never removed - .on('unlink', async (p) => { + .on('unlink', async p => { patternlab.graph.sync(); patternlab.graph.upgradeVersion(); await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_PATTERN_CHANGE, { - file: p, + file: p } ); }) - .on('unlinkDir', async (p) => { + .on('unlinkDir', async p => { patternlab.graph.sync(); patternlab.graph.upgradeVersion(); await pluginMananger.raiseEvent( patternlab, events.PATTERNLAB_PATTERN_CHANGE, { - file: p, + file: p } ); }); diff --git a/packages/core/test/lineage_hunter_tests.js b/packages/core/test/lineage_hunter_tests.js index 8ede3683b..3ac79646a 100644 --- a/packages/core/test/lineage_hunter_tests.js +++ b/packages/core/test/lineage_hunter_tests.js @@ -413,8 +413,9 @@ tap.test( 'molecules-error' ); - var currentPatternLineageIndex = - patternlab.graph.lineageIndex(currentPattern); + var currentPatternLineageIndex = patternlab.graph.lineageIndex( + currentPattern + ); test.equal(currentPatternLineageIndex.length, 1); test.equal(currentPatternLineageIndex[0], 'atoms-error'); diff --git a/packages/core/test/pattern_engines_tests.js b/packages/core/test/pattern_engines_tests.js index 3a1e78f1f..9036984b2 100644 --- a/packages/core/test/pattern_engines_tests.js +++ b/packages/core/test/pattern_engines_tests.js @@ -28,8 +28,9 @@ var engineNames = Object.keys(patternEngines); tap.test( 'getEngineNameForPattern returns "mustache" from test pattern', function (test) { - var engineName = - patternEngines.getEngineNameForPattern(mustacheTestPattern); + var engineName = patternEngines.getEngineNameForPattern( + mustacheTestPattern + ); test.equal(engineName, 'mustache'); test.end(); } diff --git a/packages/core/test/pseudopattern_hunter_tests.js b/packages/core/test/pseudopattern_hunter_tests.js index 9c5bf40c1..f37b60363 100644 --- a/packages/core/test/pseudopattern_hunter_tests.js +++ b/packages/core/test/pseudopattern_hunter_tests.js @@ -96,10 +96,12 @@ tap.test( 'utf8' ); atomPattern.extendedTemplate = atomPattern.template; - atomPattern.stylePartials = - atomPattern.findPartialsWithStyleModifiers(atomPattern); - atomPattern.parameteredPartials = - atomPattern.findPartialsWithPatternParameters(atomPattern); + atomPattern.stylePartials = atomPattern.findPartialsWithStyleModifiers( + atomPattern + ); + atomPattern.parameteredPartials = atomPattern.findPartialsWithPatternParameters( + atomPattern + ); var pseudoPattern = new Pattern('test/pseudomodifier.mustache'); pseudoPattern.template = fs.readFileSync( @@ -107,10 +109,12 @@ tap.test( 'utf8' ); pseudoPattern.extendedTemplate = atomPattern.template; - pseudoPattern.stylePartials = - pseudoPattern.findPartialsWithStyleModifiers(pseudoPattern); - pseudoPattern.parameteredPartials = - pseudoPattern.findPartialsWithPatternParameters(pseudoPattern); + pseudoPattern.stylePartials = pseudoPattern.findPartialsWithStyleModifiers( + pseudoPattern + ); + pseudoPattern.parameteredPartials = pseudoPattern.findPartialsWithPatternParameters( + pseudoPattern + ); addPattern(atomPattern, pl); addPattern(pseudoPattern, pl); diff --git a/packages/development-edition-engine-react/source/_meta/_head.html b/packages/development-edition-engine-react/source/_meta/_head.html index 9e3094352..bcb87dcd0 100644 --- a/packages/development-edition-engine-react/source/_meta/_head.html +++ b/packages/development-edition-engine-react/source/_meta/_head.html @@ -20,4 +20,5 @@ {{{ patternLabHead }}} - + + diff --git a/packages/edition-node-gulp/gulpfile.js b/packages/edition-node-gulp/gulpfile.js index fd039bad7..0f02a0346 100644 --- a/packages/edition-node-gulp/gulpfile.js +++ b/packages/edition-node-gulp/gulpfile.js @@ -27,7 +27,6 @@ function serve() { return patternlab.server .serve({ cleanPublic: config.cleanPublic, - watch: true, }) .then(() => { // do something else when this promise resolves diff --git a/packages/engine-handlebars/lib/engine_handlebars.js b/packages/engine-handlebars/lib/engine_handlebars.js index fdd6dbd14..f3a3461c8 100644 --- a/packages/engine-handlebars/lib/engine_handlebars.js +++ b/packages/engine-handlebars/lib/engine_handlebars.js @@ -29,8 +29,7 @@ const glob = require('glob'); // regexes, stored here so they're only compiled once const findPartialsRE = /{{#?>\s*([\w-\/.]+)(?:.|\s+)*?}}/g; -const findListItemsRE = - /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g; +const findListItemsRE = /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g; const findAtPartialBlockRE = /{{#?>\s*@partial-block\s*}}/g; function escapeAtPartialBlock(partialString) { diff --git a/packages/engine-nunjucks/lib/engine_nunjucks.js b/packages/engine-nunjucks/lib/engine_nunjucks.js index 5e3a909fb..c4dffb0d8 100644 --- a/packages/engine-nunjucks/lib/engine_nunjucks.js +++ b/packages/engine-nunjucks/lib/engine_nunjucks.js @@ -37,11 +37,9 @@ const engine_nunjucks = { expandPartials: false, // regexes, stored here so they're only compiled once - findPartialsRE: - /{%\s*(?:extends|include|import|from)\s+(?:'[^']+'|"[^"]+").*%}/g, + findPartialsRE: /{%\s*(?:extends|include|import|from)\s+(?:'[^']+'|"[^"]+").*%}/g, findPartialKeyRE: /{%\s*(?:extends|include|import|from)\s+('[^']+'|"[^"]+")/, - findListItemsRE: - /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, // still requires mustache style syntax because of how PL implements lists + findListItemsRE: /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, // still requires mustache style syntax because of how PL implements lists // render it renderPattern: function renderPattern(pattern, data) { diff --git a/packages/engine-twig-php/lib/engine_twig_php.js b/packages/engine-twig-php/lib/engine_twig_php.js index c4ab2af72..73dc9c560 100644 --- a/packages/engine-twig-php/lib/engine_twig_php.js +++ b/packages/engine-twig-php/lib/engine_twig_php.js @@ -27,8 +27,7 @@ const engine_twig_php = { engineName: 'twig-php', engineFileExtension: '.twig', expandPartials: false, - findPartialsRE: - /{%\s*(?:extends|include|embed)\s+('[^']+'|"[^"]+").*?(with|%}|\s*%})/g, + findPartialsRE: /{%\s*(?:extends|include|embed)\s+('[^']+'|"[^"]+").*?(with|%}|\s*%})/g, findPartialKeyRE: /"((?:\\.|[^"\\])*)"|'((?:\\.|[^"\\])*)'/, namespaces: [], @@ -46,8 +45,12 @@ const engine_twig_php = { process.exit(1); } - const { namespaces, alterTwigEnv, relativeFrom, ...rest } = - config.engines.twig; + const { + namespaces, + alterTwigEnv, + relativeFrom, + ...rest + } = config.engines.twig; // Schema on config object being passed in: // https://github.com/basaltinc/twig-renderer/blob/master/config.schema.json diff --git a/packages/engine-twig/lib/engine_twig.js b/packages/engine-twig/lib/engine_twig.js index 76308ecef..6dd182659 100644 --- a/packages/engine-twig/lib/engine_twig.js +++ b/packages/engine-twig/lib/engine_twig.js @@ -126,8 +126,7 @@ var engine_twig = { // regexes, stored here so they're only compiled once findPartialsRE: /{%[-]?\s*(?:extends|include|embed|from|import|use)\s+('[^']+'|"[^"]+").*?%}/g, findPartialKeyRE: /"((?:\\.|[^"\\])*)"/, - findListItemsRE: - /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, // TODO + findListItemsRE: /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, // TODO // render it renderPattern: function renderPattern(pattern, data, partials) { diff --git a/packages/engine-underscore/_meta/_head.html b/packages/engine-underscore/_meta/_head.html index 9e3094352..bcb87dcd0 100644 --- a/packages/engine-underscore/_meta/_head.html +++ b/packages/engine-underscore/_meta/_head.html @@ -20,4 +20,5 @@ {{{ patternLabHead }}} - + + diff --git a/packages/engine-underscore/lib/engine_underscore.js b/packages/engine-underscore/lib/engine_underscore.js index d08b3a63f..a562a02a9 100644 --- a/packages/engine-underscore/lib/engine_underscore.js +++ b/packages/engine-underscore/lib/engine_underscore.js @@ -97,10 +97,8 @@ const engine_underscore = { expandPartials: false, // regexes, stored here so they're only compiled once - findPartialsRE: - /<%=\s*_\.renderNamedPartial[ \t]*\(\s*("(?:[^"].*?)"|'(?:[^'].*?)').*?%>/g, // TODO - findListItemsRE: - /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, + findPartialsRE: /<%=\s*_\.renderNamedPartial[ \t]*\(\s*("(?:[^"].*?)"|'(?:[^'].*?)').*?%>/g, // TODO + findListItemsRE: /({{#( )?)(list(I|i)tems.)(one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty)( )?}}/g, // render it renderPattern: function renderPattern(pattern, data, partials) { diff --git a/packages/uikit-workshop/src/html/partials/base-template.html b/packages/uikit-workshop/src/html/partials/base-template.html index 5f47c91a7..799af572b 100755 --- a/packages/uikit-workshop/src/html/partials/base-template.html +++ b/packages/uikit-workshop/src/html/partials/base-template.html @@ -2,10 +2,7 @@ {{# descBlockExists }}
{{# isPatternView }} diff --git a/packages/uikit-workshop/src/scripts/actions/app.js b/packages/uikit-workshop/src/scripts/actions/app.js index c3e335a22..16ed551bb 100644 --- a/packages/uikit-workshop/src/scripts/actions/app.js +++ b/packages/uikit-workshop/src/scripts/actions/app.js @@ -9,15 +9,17 @@ export const UPDATE_CURRENT_URL = 'UPDATE_CURRENT_URL'; export const UPDATE_CURRENT_PATTERN = 'UPDATE_CURRENT_PATTERN'; export const IS_VIEWALL_PAGE = 'IS_VIEWALL_PAGE'; -export const updateCurrentPattern = - (currentPattern) => (dispatch, getState) => { - if (getState().app.currentPattern !== currentPattern) { - dispatch({ - type: UPDATE_CURRENT_PATTERN, - currentPattern, - }); - } - }; +export const updateCurrentPattern = (currentPattern) => ( + dispatch, + getState +) => { + if (getState().app.currentPattern !== currentPattern) { + dispatch({ + type: UPDATE_CURRENT_PATTERN, + currentPattern, + }); + } +}; export const updateCurrentUrl = (currentUrl) => (dispatch, getState) => { if (getState().app.currentUrl !== currentUrl) { @@ -73,15 +75,17 @@ export const updateDrawerState = (opened) => (dispatch, getState) => { } }; -export const updateDrawerAnimationState = - (drawerIsAnimating) => (dispatch, getState) => { - if (getState().app.drawerIsAnimating !== drawerIsAnimating) { - dispatch({ - type: UPDATE_DRAWER_ANIMATION_STATE, - drawerIsAnimating, - }); - } - }; +export const updateDrawerAnimationState = (drawerIsAnimating) => ( + dispatch, + getState +) => { + if (getState().app.drawerIsAnimating !== drawerIsAnimating) { + dispatch({ + type: UPDATE_DRAWER_ANIMATION_STATE, + drawerIsAnimating, + }); + } +}; export const updateDrawerHeight = (height) => (dispatch, getState) => { if (getState().app.drawerHeight !== height) { diff --git a/packages/uikit-workshop/src/scripts/components/panels-viewer.js b/packages/uikit-workshop/src/scripts/components/panels-viewer.js index 08d0f27db..289102f5f 100644 --- a/packages/uikit-workshop/src/scripts/components/panels-viewer.js +++ b/packages/uikit-workshop/src/scripts/components/panels-viewer.js @@ -177,8 +177,9 @@ export const panelsViewer = { template = document.getElementById(panel.templateID); templateCompiled = Hogan.compile(template.innerHTML); templateRendered = templateCompiled.render(patternData); - const normalizedCode = - normalizeWhitespace.normalize(templateRendered); + const normalizedCode = normalizeWhitespace.normalize( + templateRendered + ); normalizedCode.replace(/[\r\n]+/g, '\n\n'); const highlightedCode = Prism.highlight( normalizedCode, diff --git a/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js b/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js index a00a1f8be..46d049a4f 100644 --- a/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js +++ b/packages/uikit-workshop/src/scripts/components/pl-search/pl-search.js @@ -242,8 +242,7 @@ class Search extends BaseComponent { return (
diff --git a/packages/uikit-workshop/src/scripts/lit-components/pl-tooltip/pl-tooltip.js b/packages/uikit-workshop/src/scripts/lit-components/pl-tooltip/pl-tooltip.js index 3c5bde8e9..e9ead5609 100644 --- a/packages/uikit-workshop/src/scripts/lit-components/pl-tooltip/pl-tooltip.js +++ b/packages/uikit-workshop/src/scripts/lit-components/pl-tooltip/pl-tooltip.js @@ -7,7 +7,7 @@ class Tooltip extends Slotify(LitElement) { return { message: { type: String }, position: { type: String }, - child: {}, + child: {} }; } diff --git a/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js b/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js index 79f6a9cf1..342f31035 100644 --- a/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js +++ b/packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js @@ -387,8 +387,7 @@ class IFrame extends BaseLitComponent { * Workaround to avoiding an infinite loop (if using srcdoc) which breaks the ability to * hit the back button if you hit a 404 */ - this.iframe.contentWindow.document.body.innerHTML = - this.iframe404Fallback; + this.iframe.contentWindow.document.body.innerHTML = this.iframe404Fallback; } }, 100); }