diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000000..1b8ac8894b --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000000..1a10c07912 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,10 @@ +{ + "semi":"true", + "singleQuote":"true", + "trailingComa":"es5", + "useTabs":"true", + "arrowParens":"avoid", + "printWidth":80, + "tabWidth":2, + "bracketSpacing": true +} diff --git a/install/package.json b/install/package.json index e698a223a0..65568103ef 100644 --- a/install/package.json +++ b/install/package.json @@ -154,6 +154,7 @@ "zxcvbn": "4.4.2" }, "devDependencies": { + "prettier": "3.3.3", "jshint": "^2.13.6", "flow-bin":"^0.250.0", "@stryker-mutator/core": "^8.6.0", diff --git a/src/categories/delete.js b/src/categories/delete.js index a03d96ee37..4c1f27884c 100644 --- a/src/categories/delete.js +++ b/src/categories/delete.js @@ -11,25 +11,40 @@ const cache = require('../cache'); module.exports = function (Categories) { Categories.purge = async function (cid, uid) { - await batch.processSortedSet(`cid:${cid}:tids`, async (tids) => { - await async.eachLimit(tids, 10, async (tid) => { - await topics.purgePostsAndTopic(tid, uid); - }); - }, { alwaysStartAt: 0 }); + await batch.processSortedSet( + `cid:${cid}:tids`, + async (tids) => { + await async.eachLimit(tids, 10, async (tid) => { + await topics.purgePostsAndTopic(tid, uid); + }); + }, + { alwaysStartAt: 0 }, + ); - const pinnedTids = await db.getSortedSetRevRange(`cid:${cid}:tids:pinned`, 0, -1); + const pinnedTids = await db.getSortedSetRevRange( + `cid:${cid}:tids:pinned`, + 0, + -1, + ); await async.eachLimit(pinnedTids, 10, async (tid) => { await topics.purgePostsAndTopic(tid, uid); }); const categoryData = await Categories.getCategoryData(cid); await purgeCategory(cid, categoryData); - plugins.hooks.fire('action:category.delete', { cid: cid, uid: uid, category: categoryData }); + plugins.hooks.fire('action:category.delete', { + cid: cid, + uid: uid, + category: categoryData, + }); }; async function purgeCategory(cid, categoryData) { const bulkRemove = [['categories:cid', cid]]; if (categoryData && categoryData.name) { - bulkRemove.push(['categories:name', `${categoryData.name.slice(0, 200).toLowerCase()}:${cid}`]); + bulkRemove.push([ + 'categories:name', + `${categoryData.name.slice(0, 200).toLowerCase()}:${cid}`, + ]); } await db.sortedSetRemoveBulk(bulkRemove); @@ -51,7 +66,9 @@ module.exports = function (Categories) { `category:${cid}`, ]); const privilegeList = await privileges.categories.getPrivilegeList(); - await groups.destroy(privilegeList.map(privilege => `cid:${cid}:privileges:${privilege}`)); + await groups.destroy( + privilegeList.map(privilege => `cid:${cid}:privileges:${privilege}`), + ); } async function removeFromParent(cid) {