瀏覽代碼

Fix lint errors

Andrés Manelli 6 年之前
父節點
當前提交
17308dc5f3
共有 3 個文件被更改,包括 127 次插入134 次删除
  1. 3 3
      client/components/cards/cardDate.js
  2. 124 127
      client/lib/filter.js
  3. 0 4
      models/boards.js

+ 3 - 3
client/components/cards/cardDate.js

@@ -337,11 +337,11 @@ class CardEndDate extends CardDate {
     let classes = 'end-date' + ' ';
     const dueAt = this.data().getDue();
     const theDate = this.date.get();
-    if (this.date.get().diff(this.data().getDue(), 'days') >= 2)
+    if (theDate.diff(dueAt, 'days') >= 2)
       classes += 'long-overdue';
-    else if (this.date.get().diff(this.data().getDue(), 'days') >= 0)
+    else if (theDate.diff(dueAt, 'days') >= 0)
       classes += 'due';
-    else if (this.date.get().diff(this.data().getDue(), 'days') >= -2)
+    else if (theDate.diff(dueAt, 'days') >= -2)
       classes += 'almost-due';
     return classes;
   }

+ 124 - 127
client/lib/filter.js

@@ -187,27 +187,27 @@ class AdvancedFilter {
       if (commands[i].cmd) {
         switch (commands[i].cmd) {
         case '(':
-        {
-          level++;
-          if (start === -1) start = i;
-          continue;
-        }
+          {
+            level++;
+            if (start === -1) start = i;
+            continue;
+          }
         case ')':
-        {
-          level--;
-          commands.splice(i, 1);
-          i--;
-          continue;
-        }
-        default:
-        {
-          if (level > 0) {
-            subcommands.push(commands[i]);
+          {
+            level--;
             commands.splice(i, 1);
             i--;
             continue;
           }
-        }
+        default:
+          {
+            if (level > 0) {
+              subcommands.push(commands[i]);
+              commands.splice(i, 1);
+              i--;
+              continue;
+            }
+          }
         }
       }
     }
@@ -229,113 +229,112 @@ class AdvancedFilter {
         case '=':
         case '==':
         case '===':
-        {
-          const field = commands[i - 1].cmd;
-          const str = commands[i + 1].cmd;
-          if (commands[i + 1].regex)
           {
-            const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
-            let regex = null;
-            if (match.length > 2)
-              regex = new RegExp(match[1], match[2]);
+            const field = commands[i - 1].cmd;
+            const str = commands[i + 1].cmd;
+            if (commands[i + 1].regex)
+            {
+              const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
+              let regex = null;
+              if (match.length > 2)
+                regex = new RegExp(match[1], match[2]);
+              else
+                regex = new RegExp(match[1]);
+              commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': regex };
+            }
             else
-              regex = new RegExp(match[1]);
-            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': regex };
-          }
-          else
-          {
-            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} };
+            {
+              commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} };
+            }
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
           }
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
         case '!=':
         case '!==':
-        {
-          const field = commands[i - 1].cmd;
-          const str = commands[i + 1].cmd;
-          if (commands[i + 1].regex)
           {
-            const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
-            let regex = null;
-            if (match.length > 2)
-              regex = new RegExp(match[1], match[2]);
+            const field = commands[i - 1].cmd;
+            const str = commands[i + 1].cmd;
+            if (commands[i + 1].regex)
+            {
+              const match = str.match(new RegExp('^/(.*?)/([gimy]*)$'));
+              let regex = null;
+              if (match.length > 2)
+                regex = new RegExp(match[1], match[2]);
+              else
+                regex = new RegExp(match[1]);
+              commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: regex } };
+            }
             else
-              regex = new RegExp(match[1]);
-            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: regex } };
-          }
-          else
-          {
-            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} } };
+            {
+              commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $not: {$in: [this._fieldValueToId(field, str), parseInt(str, 10)]} } };
+            }
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
           }
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
         case '>':
         case 'gt':
         case 'Gt':
         case 'GT':
-        {
-          const field = commands[i - 1].cmd;
-          const str = commands[i + 1].cmd;
-          commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: parseInt(str, 10) } };
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
+          {
+            const field = commands[i - 1].cmd;
+            const str = commands[i + 1].cmd;
+            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gt: parseInt(str, 10) } };
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         case '>=':
         case '>==':
         case 'gte':
         case 'Gte':
         case 'GTE':
-        {
-          const field = commands[i - 1].cmd;
-          const str = commands[i + 1].cmd;
-          commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte:  parseInt(str, 10) } };
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
+          {
+            const field = commands[i - 1].cmd;
+            const str = commands[i + 1].cmd;
+            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $gte:  parseInt(str, 10) } };
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         case '<':
         case 'lt':
         case 'Lt':
         case 'LT':
-        {
-          const field = commands[i - 1].cmd;
-          const str = commands[i + 1].cmd;
-          commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt:  parseInt(str, 10) } };
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
+          {
+            const field = commands[i - 1].cmd;
+            const str = commands[i + 1].cmd;
+            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lt:  parseInt(str, 10) } };
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         case '<=':
         case '<==':
         case 'lte':
         case 'Lte':
         case 'LTE':
-        {
-          const field = commands[i - 1].cmd;
-          const str = commands[i + 1].cmd;
-          commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte:  parseInt(str, 10) } };
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
-
+          {
+            const field = commands[i - 1].cmd;
+            const str = commands[i + 1].cmd;
+            commands[i] = { 'customFields._id': this._fieldNameToId(field), 'customFields.value': { $lte:  parseInt(str, 10) } };
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         }
       }
     }
@@ -350,45 +349,43 @@ class AdvancedFilter {
         case 'OR':
         case '|':
         case '||':
-        {
-          const op1 = commands[i - 1];
-          const op2 = commands[i + 1];
-          commands[i] = { $or: [op1, op2] };
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
+          {
+            const op1 = commands[i - 1];
+            const op2 = commands[i + 1];
+            commands[i] = { $or: [op1, op2] };
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         case 'and':
         case 'And':
         case 'AND':
         case '&':
         case '&&':
-        {
-          const op1 = commands[i - 1];
-          const op2 = commands[i + 1];
-          commands[i] = { $and: [op1, op2] };
-          commands.splice(i - 1, 1);
-          commands.splice(i, 1);
-          //changed = true;
-          i--;
-          break;
-        }
-
+          {
+            const op1 = commands[i - 1];
+            const op2 = commands[i + 1];
+            commands[i] = { $and: [op1, op2] };
+            commands.splice(i - 1, 1);
+            commands.splice(i, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         case 'not':
         case 'Not':
         case 'NOT':
         case '!':
-        {
-          const op1 = commands[i + 1];
-          commands[i] = { $not: op1 };
-          commands.splice(i + 1, 1);
-          //changed = true;
-          i--;
-          break;
-        }
-
+          {
+            const op1 = commands[i + 1];
+            commands[i] = { $not: op1 };
+            commands.splice(i + 1, 1);
+            //changed = true;
+            i--;
+            break;
+          }
         }
       }
     }

+ 0 - 4
models/boards.js

@@ -246,10 +246,6 @@ Boards.helpers({
     return Swimlanes.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
   },
 
-  cards() {
-    return Cards.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
-  },
-
   hasOvertimeCards(){
     const card = Cards.findOne({isOvertime: true, boardId: this._id, archived: false} );
     return card !== undefined;