diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2016-02-13 03:12:01 +0100 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2016-03-17 16:26:14 +0100 |
commit | 90601eacae616c3bca46d6dcb643aa94b1fd05c6 (patch) | |
tree | 764e2aa0b91e392cdb1ef9faa92ff6c9ffe7efd1 | |
parent | b8aefedcc3dcaf62d1b45f1e4ffb1dc4fdc55f63 (diff) | |
download | wekan-90601eacae616c3bca46d6dcb643aa94b1fd05c6.tar.gz wekan-90601eacae616c3bca46d6dcb643aa94b1fd05c6.tar.bz2 wekan-90601eacae616c3bca46d6dcb643aa94b1fd05c6.zip |
Upgrade ESLint to v2
This commit also tweak the code style following backward-incompatible v2 rules.
-rw-r--r-- | .eslintrc | 129 | ||||
-rw-r--r-- | .eslintrc.json | 121 | ||||
-rw-r--r-- | client/components/lists/listBody.js | 4 | ||||
-rw-r--r-- | client/components/main/editor.js | 22 | ||||
-rw-r--r-- | client/components/sidebar/sidebarFilters.js | 4 | ||||
-rw-r--r-- | client/config/blazeHelpers.js | 4 | ||||
-rw-r--r-- | client/lib/cssEvents.js | 2 | ||||
-rw-r--r-- | client/lib/escapeActions.js | 1 | ||||
-rw-r--r-- | client/lib/multiSelection.js | 3 | ||||
-rw-r--r-- | client/lib/popup.js | 3 | ||||
-rw-r--r-- | client/lib/textComplete.js | 1 | ||||
-rw-r--r-- | models/boards.js | 8 | ||||
-rw-r--r-- | models/import.js | 19 | ||||
-rw-r--r-- | package.json | 4 |
14 files changed, 161 insertions, 164 deletions
diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index f5f0733a..00000000 --- a/.eslintrc +++ /dev/null @@ -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' diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..939f7b46 --- /dev/null +++ b/.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 + } +} diff --git a/client/components/lists/listBody.js b/client/components/lists/listBody.js index 907c2157..34c2dcd6 100644 --- a/client/components/lists/listBody.js +++ b/client/components/lists/listBody.js @@ -208,11 +208,12 @@ BlazeComponent.extendComponent({ label.color.indexOf(term) > -1) { return label; } + return null; })); }, template(label) { return Blaze.toHTMLWithData(Template.autocompleteLabelLine, { - hasNoName: !Boolean(label.name), + hasNoName: !label.name, colorName: label.color, labelName: label.name || label.color, }); @@ -233,6 +234,7 @@ BlazeComponent.extendComponent({ evt.stopPropagation(); return commands.KEY_ENTER; } + return null; }, }); }, diff --git a/client/components/main/editor.js b/client/components/main/editor.js index a30a5e1d..bf92e9a0 100644 --- a/client/components/main/editor.js +++ b/client/components/main/editor.js @@ -61,18 +61,20 @@ Blaze.Template.registerHelper('mentions', new Template('mentions', function() { const mentionRegex = /\B@(\w*)/gi; 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; + } - 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'; - link = HTML.A({ + } + const link = HTML.A({ 'class': linkClass, // XXX Hack. Since we stringify this render function result below with // `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, }, linkValue); - content = content.replace(currentMention[0], Blaze.toHTML(link)); + content = content.replace(fullMention, Blaze.toHTML(link)); } return HTML.Raw(content); diff --git a/client/components/sidebar/sidebarFilters.js b/client/components/sidebar/sidebarFilters.js index 0a57f02c..f02d3a4a 100644 --- a/client/components/sidebar/sidebarFilters.js +++ b/client/components/sidebar/sidebarFilters.js @@ -68,7 +68,7 @@ BlazeComponent.extendComponent({ const popup = Popup.open('disambiguateMultiLabel'); // XXX We need to have a better integration between the popup and the // UI components systems. - return popup.call(this.currentData(), evt); + popup.call(this.currentData(), evt); } }, 'click .js-toggle-member-multiselection'(evt) { @@ -82,7 +82,7 @@ BlazeComponent.extendComponent({ const popup = Popup.open('disambiguateMultiMember'); // XXX We need to have a better integration between the popup and the // UI components systems. - return popup.call(this.currentData(), evt); + popup.call(this.currentData(), evt); } }, 'click .js-move-selection': Popup.open('moveSelection'), diff --git a/client/config/blazeHelpers.js b/client/config/blazeHelpers.js index f3a1757f..ef075907 100644 --- a/client/config/blazeHelpers.js +++ b/client/config/blazeHelpers.js @@ -2,6 +2,8 @@ Blaze.registerHelper('currentBoard', () => { const boardId = Session.get('currentBoard'); if (boardId) { return Boards.findOne(boardId); + } else { + return null; } }); @@ -9,6 +11,8 @@ Blaze.registerHelper('currentCard', () => { const cardId = Session.get('currentCard'); if (cardId) { return Cards.findOne(cardId); + } else { + return null; } }); diff --git a/client/lib/cssEvents.js b/client/lib/cssEvents.js index 39c3fb90..04f5707e 100644 --- a/client/lib/cssEvents.js +++ b/client/lib/cssEvents.js @@ -15,6 +15,7 @@ function whichTransitionEvent() { return transitions[t]; } } + return null; } function whichAnimationEvent() { @@ -32,6 +33,7 @@ function whichAnimationEvent() { return transitions[t]; } } + return null; } CSSEvents = { diff --git a/client/lib/escapeActions.js b/client/lib/escapeActions.js index f2dc3dcb..49b80422 100644 --- a/client/lib/escapeActions.js +++ b/client/lib/escapeActions.js @@ -64,6 +64,7 @@ EscapeActions = { clickExecute(target, maxLabel) { if (this._nextclickPrevented) { this._nextclickPrevented = false; + return false; } else { return this._execute({ maxLabel, diff --git a/client/lib/multiSelection.js b/client/lib/multiSelection.js index eeb2015d..30577fd4 100644 --- a/client/lib/multiSelection.js +++ b/client/lib/multiSelection.js @@ -109,12 +109,11 @@ MultiSelection = { toggleRange(cardId) { const selectedCards = this._selectedCards.get(); - let startRange; this.reset(); if (!this.isActive() || selectedCards.length === 0) { this.toggle(cardId); } else { - startRange = selectedCards[selectedCards.length - 1]; + const startRange = selectedCards[selectedCards.length - 1]; this.toggle(getCardsBetween(startRange, cardId)); } }, diff --git a/client/lib/popup.js b/client/lib/popup.js index 7cceaa4f..3166ca30 100644 --- a/client/lib/popup.js +++ b/client/lib/popup.js @@ -38,7 +38,8 @@ window.Popup = new class { if (self.isOpen()) { const previousOpenerElement = self._getTopStack().openerElement; if (previousOpenerElement === evt.currentTarget) { - return self.close(); + self.close(); + return; } else { $(previousOpenerElement).removeClass('is-active'); } diff --git a/client/lib/textComplete.js b/client/lib/textComplete.js index 3e69d07f..69820514 100644 --- a/client/lib/textComplete.js +++ b/client/lib/textComplete.js @@ -14,6 +14,7 @@ $.fn.escapeableTextComplete = function(strategies, options, ...otherArgs) { evt.stopPropagation(); return commands.KEY_ENTER; } + return null; }, ...options, }; diff --git a/models/boards.js b/models/boards.js index 64d6df62..52272cce 100644 --- a/models/boards.js +++ b/models/boards.js @@ -201,6 +201,7 @@ Boards.mutations({ const _id = Random.id(6); return { $push: {labels: { _id, name, color }}}; } + return {}; }, editLabel(labelId, name, color) { @@ -213,6 +214,7 @@ Boards.mutations({ }, }; } + return {}; }, removeLabel(labelId) { @@ -397,8 +399,9 @@ if (Meteor.isServer) { if (!_.contains(fieldNames, 'labels') || !modifier.$pull || !modifier.$pull.labels || - !modifier.$pull.labels._id) + !modifier.$pull.labels._id) { return; + } const removedLabelId = modifier.$pull.labels._id; Cards.update( @@ -414,8 +417,9 @@ if (Meteor.isServer) { // Add a new activity if we add or remove a member to the board Boards.after.update((userId, doc, fieldNames, modifier) => { - if (!_.contains(fieldNames, 'members')) + if (!_.contains(fieldNames, 'members')) { return; + } let memberId; diff --git a/models/import.js b/models/import.js index fecc5c4d..86ef75b3 100644 --- a/models/import.js +++ b/models/import.js @@ -397,8 +397,7 @@ class TrelloCreator { parseActions(trelloActions) { 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. // In that case Trello still reports its addition, but removes its 'url' field. // So we test for that @@ -412,30 +411,22 @@ class TrelloCreator { } this.attachments[trelloCardId].push(trelloAttachment); } - break; - case 'commentCard': + } else if (action.type === 'commentCard') { const id = action.data.card.id; if (this.comments[id]) { this.comments[id].push(action); } else { this.comments[id] = [action]; } - break; - case 'createBoard': + } else if (action.type === 'createBoard') { this.createdAt.board = action.date; - break; - case 'createCard': + } else if (action.type === 'createCard') { const cardId = action.data.card.id; this.createdAt.cards[cardId] = action.date; this.createdBy.cards[cardId] = action.idMemberCreator; - break; - case 'createList': + } else if (action.type === 'createList') { const listId = action.data.list.id; this.createdAt.lists[listId] = action.date; - break; - default: - // do nothing - break; } }); } diff --git a/package.json b/package.json index e844c9ec..dcf7cbb2 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,6 @@ }, "homepage": "https://wekan.io", "devDependencies": { - "babel-eslint": "4.1.3", - "eslint": "1.7.3", - "eslint-plugin-meteor": "1.7.0" + "eslint": "^2.0.0" } } |