Explorar o código

Upgrade ESLint to v2

This commit also tweak the code style following backward-incompatible v2 rules.
Maxime Quandalle %!s(int64=9) %!d(string=hai) anos
pai
achega
90601eacae

+ 0 - 129
.eslintrc

@@ -1,129 +0,0 @@
-ecmaFeatures:
-  experimentalObjectRestSpread: true
-
-rules:
-  strict: 0
-  no-undef: 2
-  accessor-pairs: 2
-  comma-dangle: [2, 'always-multiline']
-  consistent-return: 2
-  dot-notation: 2
-  eqeqeq: 2
-  indent: [2, 2]
-  no-cond-assign: 2
-  no-constant-condition: 2
-  no-eval: 2
-  no-inner-declarations: [0]
-  no-unneeded-ternary: 2
-  radix: 2
-  semi: [2, always]
-
-  # Stylistic Issues
-  camelcase: 2
-  comma-spacing: 2
-  comma-style: 2
-  eol-last: 2
-  linebreak-style: [2, unix]
-  new-parens: 2
-  no-lonely-if: 2
-  no-multiple-empty-lines: 2
-  no-nested-ternary: 2
-  no-spaced-func: 2
-  no-trailing-spaces: 2
-  operator-linebreak: 2
-  quotes: [2, single]
-  semi-spacing: 2
-  space-unary-ops: 2
-  spaced-comment: [2, always, markers: ['/']]
-
-  # ECMAScript 6
-  arrow-parens: 2
-  arrow-spacing: 2
-  no-class-assign: 2
-  no-dupe-class-members: 2
-  no-var: 2
-  object-shorthand: 2
-  prefer-const: 2
-  prefer-spread: 2
-  prefer-template: 2
-
-globals:
-  # Meteor globals
-  Meteor: false
-  Session: false
-  HTML: false
-  check: false
-  Tracker: false
-  Blaze: false
-  Accounts: false
-  Match: false
-  Mongo: false
-  Random: false
-  ReactiveVar: false
-  Email: false
-  Template: false
-
-  # Exported by packages we use
-  '$': false
-  _: false
-  autosize: false
-  Avatar: true
-  Avatars: true
-  BlazeComponent: false
-  BlazeLayout: false
-  DocHead: false
-  ESSearchResults: false
-  FastRender: false
-  FlowRouter: false
-  FS: false
-  getSlug: false
-  Migrations: false
-  moment: false
-  Mousetrap: false
-  Picker: false
-  Presence: true
-  presences: true
-  Ps: true
-  ReactiveTabs: false
-  Restivus: false
-  SimpleSchema: false
-  SubsManager: false
-  T9n: false
-  TAPi18n: false
-
-  # Our collections
-  AccountsTemplates: true
-  Activities: true
-  Attachments: true
-  Boards: true
-  CardComments: true
-  Cards: true
-  Lists: true
-  UnsavedEditCollection: true
-  Users: true
-
-  # Our objects
-  CSSEvents: true
-  EscapeActions: true
-  Filter: true
-  Mixins: true
-  Modal: true
-  MultiSelection: true
-  Popup: true
-  Sidebar: true
-  Utils: true
-  InlinedForm: true
-  UnsavedEdits: true
-  Notifications: true
-
-  # XXX Temp, we should remove these
-  allowIsBoardAdmin: true
-  allowIsBoardMember: true
-  Emoji: true
-
-env:
-  es6: true
-  node: true
-  browser: true
-
-extends: 'eslint:recommended'

+ 121 - 0
.eslintrc.json

@@ -0,0 +1,121 @@
+{
+  "extends": "eslint:recommended",
+  "env": {
+    "es6": true,
+    "node": true,
+    "browser": true
+  },
+  "parserOptions": {
+    "ecmaVersion": 6,
+    "sourceType": "module",
+    "ecmaFeatures": {
+      "experimentalObjectRestSpread": true
+    }
+  },
+  "rules": {
+    "strict": 0,
+    "no-undef": 2,
+    "accessor-pairs": 2,
+    "comma-dangle": [2, "always-multiline"],
+    "consistent-return": 2,
+    "dot-notation": 2,
+    "eqeqeq": 2,
+    "indent": [2, 2],
+    "no-cond-assign": 2,
+    "no-constant-condition": 2,
+    "no-eval": 2,
+    "no-inner-declarations": [0],
+    "no-unneeded-ternary": 2,
+    "radix": 2,
+    "semi": [2, "always"],
+    "camelcase": 2,
+    "comma-spacing": 2,
+    "comma-style": 2,
+    "eol-last": 2,
+    "linebreak-style": [2, "unix"],
+    "new-parens": 2,
+    "no-lonely-if": 2,
+    "no-multiple-empty-lines": 2,
+    "no-nested-ternary": 2,
+    "no-spaced-func": 2,
+    "no-trailing-spaces": 2,
+    "operator-linebreak": 2,
+    "quotes": [2, "single"],
+    "semi-spacing": 2,
+    "space-unary-ops": 2,
+    "arrow-parens": 2,
+    "arrow-spacing": 2,
+    "no-class-assign": 2,
+    "no-dupe-class-members": 2,
+    "no-var": 2,
+    "object-shorthand": 2,
+    "prefer-const": 2,
+    "prefer-spread": 2,
+    "prefer-template": 2
+  },
+  "globals": {
+    "Meteor": false,
+    "Session": false,
+    "HTML": false,
+    "check": false,
+    "Tracker": false,
+    "Blaze": false,
+    "Accounts": false,
+    "Match": false,
+    "Mongo": false,
+    "Random": false,
+    "ReactiveVar": false,
+    "Email": false,
+    "Template": false,
+    "$": false,
+    "_": false,
+    "autosize": false,
+    "Avatar": true,
+    "Avatars": true,
+    "BlazeComponent": false,
+    "BlazeLayout": false,
+    "DocHead": false,
+    "ESSearchResults": false,
+    "FastRender": false,
+    "FlowRouter": false,
+    "FS": false,
+    "getSlug": false,
+    "Migrations": false,
+    "moment": false,
+    "Mousetrap": false,
+    "Picker": false,
+    "Presence": true,
+    "presences": true,
+    "Ps": true,
+    "ReactiveTabs": false,
+    "Restivus": false,
+    "SimpleSchema": false,
+    "SubsManager": false,
+    "T9n": false,
+    "TAPi18n": false,
+    "AccountsTemplates": true,
+    "Activities": true,
+    "Attachments": true,
+    "Boards": true,
+    "CardComments": true,
+    "Cards": true,
+    "Lists": true,
+    "UnsavedEditCollection": true,
+    "Users": true,
+    "CSSEvents": true,
+    "EscapeActions": true,
+    "Filter": true,
+    "Mixins": true,
+    "Modal": true,
+    "MultiSelection": true,
+    "Popup": true,
+    "Sidebar": true,
+    "Utils": true,
+    "InlinedForm": true,
+    "UnsavedEdits": true,
+    "Notifications": true,
+    "allowIsBoardAdmin": true,
+    "allowIsBoardMember": true,
+    "Emoji": true
+  }
+}

+ 3 - 1
client/components/lists/listBody.js

@@ -208,11 +208,12 @@ BlazeComponent.extendComponent({
                 label.color.indexOf(term) > -1) {
                 label.color.indexOf(term) > -1) {
               return label;
               return label;
             }
             }
+            return null;
           }));
           }));
         },
         },
         template(label) {
         template(label) {
           return Blaze.toHTMLWithData(Template.autocompleteLabelLine, {
           return Blaze.toHTMLWithData(Template.autocompleteLabelLine, {
-            hasNoName: !Boolean(label.name),
+            hasNoName: !label.name,
             colorName: label.color,
             colorName: label.color,
             labelName: label.name || label.color,
             labelName: label.name || label.color,
           });
           });
@@ -233,6 +234,7 @@ BlazeComponent.extendComponent({
           evt.stopPropagation();
           evt.stopPropagation();
           return commands.KEY_ENTER;
           return commands.KEY_ENTER;
         }
         }
+        return null;
       },
       },
     });
     });
   },
   },

+ 12 - 10
client/components/main/editor.js

@@ -61,18 +61,20 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
   const mentionRegex = /\B@(\w*)/gi;
   const mentionRegex = /\B@(\w*)/gi;
   let content = Blaze.toHTML(view.templateContentBlock);
   let content = Blaze.toHTML(view.templateContentBlock);
 
 
-  let currentMention, knowedUser, linkClass, linkValue, link;
-  while (Boolean(currentMention = mentionRegex.exec(content))) {
-
-    knowedUser = _.findWhere(knowedUsers, { username: currentMention[1] });
-    if (!knowedUser)
+  let currentMention;
+  while ((currentMention = mentionRegex.exec(content)) !== null) {
+    const [fullMention, username] = currentMention;
+    const knowedUser = _.findWhere(knowedUsers, { username });
+    if (!knowedUser) {
       continue;
       continue;
+    }
 
 
-    linkValue = [' ', at, knowedUser.username];
-    linkClass = 'atMention js-open-member';
-    if (knowedUser.userId === Meteor.userId())
+    const linkValue = [' ', at, knowedUser.username];
+    let linkClass = 'atMention js-open-member';
+    if (knowedUser.userId === Meteor.userId()) {
       linkClass += ' me';
       linkClass += ' me';
-    link = HTML.A({
+    }
+    const link = HTML.A({
       'class': linkClass,
       'class': linkClass,
       // XXX Hack. Since we stringify this render function result below with
       // XXX Hack. Since we stringify this render function result below with
       // `Blaze.toHTML` we can't rely on blaze data contexts to pass the
       // `Blaze.toHTML` we can't rely on blaze data contexts to pass the
@@ -81,7 +83,7 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() {
       'data-userId': knowedUser.userId,
       'data-userId': knowedUser.userId,
     }, linkValue);
     }, linkValue);
 
 
-    content = content.replace(currentMention[0], Blaze.toHTML(link));
+    content = content.replace(fullMention, Blaze.toHTML(link));
   }
   }
 
 
   return HTML.Raw(content);
   return HTML.Raw(content);

+ 2 - 2
client/components/sidebar/sidebarFilters.js

@@ -68,7 +68,7 @@ BlazeComponent.extendComponent({
           const popup = Popup.open('disambiguateMultiLabel');
           const popup = Popup.open('disambiguateMultiLabel');
           // XXX We need to have a better integration between the popup and the
           // XXX We need to have a better integration between the popup and the
           // UI components systems.
           // UI components systems.
-          return popup.call(this.currentData(), evt);
+          popup.call(this.currentData(), evt);
         }
         }
       },
       },
       'click .js-toggle-member-multiselection'(evt) {
       'click .js-toggle-member-multiselection'(evt) {
@@ -82,7 +82,7 @@ BlazeComponent.extendComponent({
           const popup = Popup.open('disambiguateMultiMember');
           const popup = Popup.open('disambiguateMultiMember');
           // XXX We need to have a better integration between the popup and the
           // XXX We need to have a better integration between the popup and the
           // UI components systems.
           // UI components systems.
-          return popup.call(this.currentData(), evt);
+          popup.call(this.currentData(), evt);
         }
         }
       },
       },
       'click .js-move-selection': Popup.open('moveSelection'),
       'click .js-move-selection': Popup.open('moveSelection'),

+ 4 - 0
client/config/blazeHelpers.js

@@ -2,6 +2,8 @@ Blaze.registerHelper('currentBoard', () => {
   const boardId = Session.get('currentBoard');
   const boardId = Session.get('currentBoard');
   if (boardId) {
   if (boardId) {
     return Boards.findOne(boardId);
     return Boards.findOne(boardId);
+  } else {
+    return null;
   }
   }
 });
 });
 
 
@@ -9,6 +11,8 @@ Blaze.registerHelper('currentCard', () => {
   const cardId = Session.get('currentCard');
   const cardId = Session.get('currentCard');
   if (cardId) {
   if (cardId) {
     return Cards.findOne(cardId);
     return Cards.findOne(cardId);
+  } else {
+    return null;
   }
   }
 });
 });
 
 

+ 2 - 0
client/lib/cssEvents.js

@@ -15,6 +15,7 @@ function whichTransitionEvent() {
       return transitions[t];
       return transitions[t];
     }
     }
   }
   }
+  return null;
 }
 }
 
 
 function whichAnimationEvent() {
 function whichAnimationEvent() {
@@ -32,6 +33,7 @@ function whichAnimationEvent() {
       return transitions[t];
       return transitions[t];
     }
     }
   }
   }
+  return null;
 }
 }
 
 
 CSSEvents = {
 CSSEvents = {

+ 1 - 0
client/lib/escapeActions.js

@@ -64,6 +64,7 @@ EscapeActions = {
   clickExecute(target, maxLabel) {
   clickExecute(target, maxLabel) {
     if (this._nextclickPrevented) {
     if (this._nextclickPrevented) {
       this._nextclickPrevented = false;
       this._nextclickPrevented = false;
+      return false;
     } else {
     } else {
       return this._execute({
       return this._execute({
         maxLabel,
         maxLabel,

+ 1 - 2
client/lib/multiSelection.js

@@ -109,12 +109,11 @@ MultiSelection = {
 
 
   toggleRange(cardId) {
   toggleRange(cardId) {
     const selectedCards = this._selectedCards.get();
     const selectedCards = this._selectedCards.get();
-    let startRange;
     this.reset();
     this.reset();
     if (!this.isActive() || selectedCards.length === 0) {
     if (!this.isActive() || selectedCards.length === 0) {
       this.toggle(cardId);
       this.toggle(cardId);
     } else {
     } else {
-      startRange = selectedCards[selectedCards.length - 1];
+      const startRange = selectedCards[selectedCards.length - 1];
       this.toggle(getCardsBetween(startRange, cardId));
       this.toggle(getCardsBetween(startRange, cardId));
     }
     }
   },
   },

+ 2 - 1
client/lib/popup.js

@@ -38,7 +38,8 @@ window.Popup = new class {
       if (self.isOpen()) {
       if (self.isOpen()) {
         const previousOpenerElement = self._getTopStack().openerElement;
         const previousOpenerElement = self._getTopStack().openerElement;
         if (previousOpenerElement === evt.currentTarget) {
         if (previousOpenerElement === evt.currentTarget) {
-          return self.close();
+          self.close();
+          return;
         } else {
         } else {
           $(previousOpenerElement).removeClass('is-active');
           $(previousOpenerElement).removeClass('is-active');
         }
         }

+ 1 - 0
client/lib/textComplete.js

@@ -14,6 +14,7 @@ $.fn.escapeableTextComplete = function(strategies, options, ...otherArgs) {
         evt.stopPropagation();
         evt.stopPropagation();
         return commands.KEY_ENTER;
         return commands.KEY_ENTER;
       }
       }
+      return null;
     },
     },
     ...options,
     ...options,
   };
   };

+ 6 - 2
models/boards.js

@@ -201,6 +201,7 @@ Boards.mutations({
       const _id = Random.id(6);
       const _id = Random.id(6);
       return { $push: {labels: { _id, name, color }}};
       return { $push: {labels: { _id, name, color }}};
     }
     }
+    return {};
   },
   },
 
 
   editLabel(labelId, name, color) {
   editLabel(labelId, name, color) {
@@ -213,6 +214,7 @@ Boards.mutations({
         },
         },
       };
       };
     }
     }
+    return {};
   },
   },
 
 
   removeLabel(labelId) {
   removeLabel(labelId) {
@@ -397,8 +399,9 @@ if (Meteor.isServer) {
     if (!_.contains(fieldNames, 'labels') ||
     if (!_.contains(fieldNames, 'labels') ||
       !modifier.$pull ||
       !modifier.$pull ||
       !modifier.$pull.labels ||
       !modifier.$pull.labels ||
-      !modifier.$pull.labels._id)
+      !modifier.$pull.labels._id) {
       return;
       return;
+    }
 
 
     const removedLabelId = modifier.$pull.labels._id;
     const removedLabelId = modifier.$pull.labels._id;
     Cards.update(
     Cards.update(
@@ -414,8 +417,9 @@ if (Meteor.isServer) {
 
 
   // Add a new activity if we add or remove a member to the board
   // Add a new activity if we add or remove a member to the board
   Boards.after.update((userId, doc, fieldNames, modifier) => {
   Boards.after.update((userId, doc, fieldNames, modifier) => {
-    if (!_.contains(fieldNames, 'members'))
+    if (!_.contains(fieldNames, 'members')) {
       return;
       return;
+    }
 
 
     let memberId;
     let memberId;
 
 

+ 5 - 14
models/import.js

@@ -397,8 +397,7 @@ class TrelloCreator {
 
 
   parseActions(trelloActions) {
   parseActions(trelloActions) {
     trelloActions.forEach((action) => {
     trelloActions.forEach((action) => {
-      switch (action.type) {
-      case 'addAttachmentToCard':
+      if (action.type === 'addAttachmentToCard') {
         // We have to be cautious, because the attachment could have been removed later.
         // We have to be cautious, because the attachment could have been removed later.
         // In that case Trello still reports its addition, but removes its 'url' field.
         // In that case Trello still reports its addition, but removes its 'url' field.
         // So we test for that
         // So we test for that
@@ -412,30 +411,22 @@ class TrelloCreator {
           }
           }
           this.attachments[trelloCardId].push(trelloAttachment);
           this.attachments[trelloCardId].push(trelloAttachment);
         }
         }
-        break;
-      case 'commentCard':
+      } else if (action.type === 'commentCard') {
         const id = action.data.card.id;
         const id = action.data.card.id;
         if (this.comments[id]) {
         if (this.comments[id]) {
           this.comments[id].push(action);
           this.comments[id].push(action);
         } else {
         } else {
           this.comments[id] = [action];
           this.comments[id] = [action];
         }
         }
-        break;
-      case 'createBoard':
+      } else if (action.type === 'createBoard') {
         this.createdAt.board = action.date;
         this.createdAt.board = action.date;
-        break;
-      case 'createCard':
+      } else if (action.type === 'createCard') {
         const cardId = action.data.card.id;
         const cardId = action.data.card.id;
         this.createdAt.cards[cardId] = action.date;
         this.createdAt.cards[cardId] = action.date;
         this.createdBy.cards[cardId] = action.idMemberCreator;
         this.createdBy.cards[cardId] = action.idMemberCreator;
-        break;
-      case 'createList':
+      } else if (action.type === 'createList') {
         const listId = action.data.list.id;
         const listId = action.data.list.id;
         this.createdAt.lists[listId] = action.date;
         this.createdAt.lists[listId] = action.date;
-        break;
-      default:
-        // do nothing
-        break;
       }
       }
     });
     });
   }
   }

+ 1 - 3
package.json

@@ -17,8 +17,6 @@
   },
   },
   "homepage": "https://wekan.io",
   "homepage": "https://wekan.io",
   "devDependencies": {
   "devDependencies": {
-    "babel-eslint": "4.1.3",
-    "eslint": "1.7.3",
-    "eslint-plugin-meteor": "1.7.0"
+    "eslint": "^2.0.0"
   }
   }
 }
 }