caverav / auditforge

Prefer not using an async function as a Promise executor JS-0031
Anti-pattern
Major
11 days ago11 days old
Promise executor functions should not be async
 75
 76// Update client
 77ClientSchema.statics.update = (clientId, client, company) => {
 78  return new Promise(async (resolve, reject) => { 79    if (company) {
 80      var Company = mongoose.model('Company');
 81      var query = Company.findOneAndUpdate(
Promise executor functions should not be async
 36
 37// Create client
 38ClientSchema.statics.create = (client, company) => {
 39  return new Promise(async (resolve, reject) => { 40    if (company) {
 41      var Company = mongoose.model('Company');
 42      var query = Company.findOneAndUpdate(
Promise executor functions should not be async
1166
1167// Delete audit parent
1168AuditSchema.statics.deleteParent = (isAdmin, auditId, userId) => {
1169  return new Promise(async (resolve, reject) => {1170    var query = Audit.findByIdAndUpdate(auditId, { parentId: null });
1171    if (!isAdmin) query.or([{ creator: userId }, { collaborators: userId }]);
1172    query
Promise executor functions should not be async
1144
1145// Update audit parent
1146AuditSchema.statics.updateParent = (isAdmin, auditId, userId, parentId) => {
1147  return new Promise(async (resolve, reject) => {1148    var query = Audit.findByIdAndUpdate(auditId, { parentId: parentId });
1149    if (!isAdmin) query.or([{ creator: userId }, { collaborators: userId }]);
1150    query
Promise executor functions should not be async
1111  });
1112
1113AuditSchema.statics.updateApprovals = (isAdmin, auditId, userId, update) => {
1114  return new Promise(async (resolve, reject) => {1115    var Settings = mongoose.model('Settings');
1116    var settings = await Settings.getAll();
1117