Skip to content

Commit

Permalink
refactor: updated depencencies regarding prettier (#1307)
Browse files Browse the repository at this point in the history
* refactor: updated husky and pretty-quick dependencies

and updated to the new config storage model and removed husky and pretty-quick from packages/core, as this should be possible to get triggered from root

* refactor: updated prettier dependency

and removed rules "trailingComma": "es5" as this is the new default

* fix: added missing comma

* refactor: regenerated yarn.lock file

* refactor(husky): made additional necessary changes for the installation

as well as moved husky to the devDependencies, as defined by the software doc itself

* refactor(pinst): remove that solution again

see typicode/husky#884

* refactor(code): integrated prettier feedback

that was enforced like this by eslint

* refactor(husky): updated husky and added pinst

Yarn 2 doesn't support prepare lifecycle script, so husky needs to be installed differently (this doesn't apply to Yarn 1 though)

* Revert "refactor(husky): updated husky and added pinst"

This reverts commit e834b42.

* refactor(husky): updated husky

Co-authored-by: Josef Bredreck <[email protected]>
  • Loading branch information
mfranzke and JosefBredereck authored Apr 17, 2021
1 parent 7ecca69 commit 639801a
Show file tree
Hide file tree
Showing 59 changed files with 352 additions and 354 deletions.
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no-install pretty-quick --staged
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"singleQuote": true,
"trailingComma": "es5",
"endOfLine": "auto"
}
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 639801a

Please sign in to comment.