Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: updated depencencies regarding prettier #1307

Merged
1 change: 1 addition & 0 deletions .husky/.gitignore
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
1 change: 0 additions & 1 deletion .prettierrc
@@ -1,5 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5",
"endOfLine": "auto"
}
12 changes: 8 additions & 4 deletions package.json
Expand Up @@ -18,11 +18,11 @@
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.14.3",
"lerna": "3.17.0",
"pretty-quick": "^1.11.1",
"auto": "^9.40.5",
"@auto-it/released": "^9.40.5"
"@auto-it/released": "^9.40.5",
"prettier": "^2.2.1",
"pretty-quick": "^3.1.0"
},
"repository": {
"type": "git",
Expand All @@ -41,7 +41,8 @@
"publish": "npx lerna publish -m \"[skip travis] chore(release): publish %s\"",
"postpublish": "auto release",
"preview:docs": "cd packages/docs && yarn production",
"preview:hbs": "cd packages/development-edition-engine-handlebars && yarn pl:starterkit && yarn pl:build"
"preview:hbs": "cd packages/development-edition-engine-handlebars && yarn pl:starterkit && yarn pl:build",
"prepare": "husky install"
},
"nyc": {
"exclude": [
Expand All @@ -50,5 +51,8 @@
"packages/core/test",
"packages/live-server"
]
},
"devDependencies": {
"husky": "^6.0.0"
}
}
2 changes: 1 addition & 1 deletion packages/cli/package.json
Expand Up @@ -34,7 +34,7 @@
"eslint": "4.18.2",
"eslint-config-prettier": "2.9.0",
"eslint-plugin-prettier": "2.6.0",
"prettier": "1.11.1",
"prettier": "2.2.1",
"proxyquire": "2.1.3",
"tap": "14.11.0"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/core/package.json
Expand Up @@ -30,10 +30,8 @@
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.0",
"husky": "0.14.3",
"jsdoc-to-markdown": "5.0.1",
"prettier": "^1.14.3",
"pretty-quick": "^1.11.1",
"prettier": "^2.2.1",
"rewire": "2.5.2",
"standard-version": "9.1.1",
"tap": "14.11.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/addPattern.js
Expand Up @@ -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 = {};
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/lib/annotation_exporter.js
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -110,13 +110,13 @@ const annotations_exporter = function(pl) {
}

return {
gather: function() {
gather: function () {
return gatherAnnotations();
},
gatherJS: function() {
gatherJS: function () {
return parseAnnotationsJS();
},
gatherMD: function() {
gatherMD: function () {
return parseAnnotationsMD();
},
};
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/lib/buildFooter.js
Expand Up @@ -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,
}),
cacheBuster: patternlab.cacheBuster,
})
.then(footerPartial => {
.then((footerPartial) => {
let allFooterData;
try {
allFooterData = jsonCopy(
Expand All @@ -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');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/lib/buildListItems.js
Expand Up @@ -26,7 +26,7 @@ const items = [
'twenty',
];

module.exports = function(container) {
module.exports = function (container) {
//combine all list items into one structure
const list = [];
for (const item in container.listitems) {
Expand Down
20 changes: 10 additions & 10 deletions packages/core/src/lib/buildPatterns.js
Expand Up @@ -119,7 +119,7 @@ module.exports = async (deletePatternDir, patternlab, additionalData) => {
cacheBuster: patternlab.cacheBuster,
}
)
.then(results => {
.then((results) => {
patternlab.data.patternLabHead = results;

// If deletePatternDir == true or graph needs to be updated
Expand All @@ -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);
});

Expand All @@ -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 },
} = 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),
Expand Down Expand Up @@ -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()');
});
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/lib/changes_hunter.js
Expand Up @@ -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 = {
/**
Expand All @@ -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 +
Expand All @@ -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),
Expand Down Expand Up @@ -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);
Expand All @@ -110,7 +110,7 @@ ChangesHunter.prototype = {
}
},

needsRebuild: function(lastModified, p) {
needsRebuild: function (lastModified, p) {
if (p.compileState !== CompileState.CLEAN || !p.lastModified) {
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/cleanBuildDirectory.js
Expand Up @@ -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);
});
}
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/lib/compose.js
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -154,7 +154,7 @@ module.exports = async function(pattern, patternlab) {
patternPartialPromise,
footerPartialPromise,
])
.then(intermediateResults => {
.then((intermediateResults) => {
// retrieve results of promises
const headHTML = intermediateResults[0]; //headPromise
pattern.patternPartialCode = intermediateResults[1]; //patternPartialPromise
Expand All @@ -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
///////////////
Expand Down Expand Up @@ -212,7 +212,7 @@ module.exports = async function(pattern, patternlab) {
}
);
})
.catch(reason => {
.catch((reason) => {
console.log(reason);
});
})
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/lib/copier.js
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -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(
Expand All @@ -116,7 +116,7 @@ const copier = () => {
copyAndWatch: (assetDirectories, patternlab, options) => {
return copyAndWatch(assetDirectories, patternlab, options);
},
transformConfigPaths: paths => {
transformConfigPaths: (paths) => {
return transform_paths(paths);
},
};
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/copyFile.js
Expand Up @@ -7,10 +7,10 @@ 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, () => {
Expand Down