From 388fd455ea546165c0421d68836952b8e0fa1939 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Tue, 8 Mar 2016 13:01:40 -0500 Subject: [PATCH] fix(lint): fix linter issues --- .../lib/link-tracking-after-send.es6 | 5 ++-- internal_packages/link-tracking/lib/main.es6 | 1 - .../link-tracking-composer-extension-spec.es6 | 4 +-- .../lib/open-tracking-after-send.es6 | 3 +- .../lib/open-tracking-message-status.jsx | 1 + .../open-tracking-composer-extension-spec.es6 | 5 ++-- .../spec/open-tracking-icon-spec.jsx | 6 ++-- .../open-tracking-message-status-spec.jsx | 3 +- spec/tasks/change-mail-task-spec.coffee | 1 - src/flux/tasks/task-factory.es6 | 29 ++++++++++--------- 10 files changed, 31 insertions(+), 27 deletions(-) diff --git a/internal_packages/link-tracking/lib/link-tracking-after-send.es6 b/internal_packages/link-tracking/lib/link-tracking-after-send.es6 index 57a1d2617..8a85a8064 100644 --- a/internal_packages/link-tracking/lib/link-tracking-after-send.es6 +++ b/internal_packages/link-tracking/lib/link-tracking-after-send.es6 @@ -2,7 +2,7 @@ import request from 'request'; import {Actions} from 'nylas-exports'; import {PLUGIN_ID, PLUGIN_URL} from './link-tracking-constants' -export default class LinkTrackingAfterSend{ +export default class LinkTrackingAfterSend { static post = Promise.promisify(request.post, {multiArgs: true}); static afterDraftSend({message}) { @@ -34,4 +34,5 @@ export default class LinkTrackingAfterSend{ }); } } -} \ No newline at end of file +} + diff --git a/internal_packages/link-tracking/lib/main.es6 b/internal_packages/link-tracking/lib/main.es6 index c0a12e728..c85506d62 100644 --- a/internal_packages/link-tracking/lib/main.es6 +++ b/internal_packages/link-tracking/lib/main.es6 @@ -1,4 +1,3 @@ -import request from 'request'; import {ComponentRegistry, ExtensionRegistry, Actions} from 'nylas-exports'; import LinkTrackingButton from './link-tracking-button'; import LinkTrackingComposerExtension from './link-tracking-composer-extension'; diff --git a/internal_packages/link-tracking/spec/link-tracking-composer-extension-spec.es6 b/internal_packages/link-tracking/spec/link-tracking-composer-extension-spec.es6 index 59ced484f..7c6745dd5 100644 --- a/internal_packages/link-tracking/spec/link-tracking-composer-extension-spec.es6 +++ b/internal_packages/link-tracking/spec/link-tracking-composer-extension-spec.es6 @@ -23,14 +23,13 @@ const testBody = `${testContent}${quote}`; const replacedBody = (accountId, messageUid, unquoted) => `${replacedContent(accountId, messageUid)}${unquoted ? "" : quote}`; describe("Open tracking composer extension", () => { - // Set up a draft, session that returns the draft, and metadata beforeEach(()=>{ this.draft = new Message({accountId: "test"}); this.draft.body = testBody; this.session = { draft: () => this.draft, - changes: jasmine.createSpyObj('changes', ['add', 'commit']) + changes: jasmine.createSpyObj('changes', ['add', 'commit']), }; }); @@ -83,3 +82,4 @@ describe("Open tracking composer extension", () => { }) }); }); + diff --git a/internal_packages/open-tracking/lib/open-tracking-after-send.es6 b/internal_packages/open-tracking/lib/open-tracking-after-send.es6 index 7cdfafc4a..c7ff2289a 100644 --- a/internal_packages/open-tracking/lib/open-tracking-after-send.es6 +++ b/internal_packages/open-tracking/lib/open-tracking-after-send.es6 @@ -34,4 +34,5 @@ export default class OpenTrackingAfterSend { }); } } -} \ No newline at end of file +} + diff --git a/internal_packages/open-tracking/lib/open-tracking-message-status.jsx b/internal_packages/open-tracking/lib/open-tracking-message-status.jsx index fdc53b474..127c69975 100644 --- a/internal_packages/open-tracking/lib/open-tracking-message-status.jsx +++ b/internal_packages/open-tracking/lib/open-tracking-message-status.jsx @@ -52,3 +52,4 @@ export default class OpenTrackingMessageStatus extends React.Component { ) } } + diff --git a/internal_packages/open-tracking/spec/open-tracking-composer-extension-spec.es6 b/internal_packages/open-tracking/spec/open-tracking-composer-extension-spec.es6 index ca39cdfe3..fe639ca11 100644 --- a/internal_packages/open-tracking/spec/open-tracking-composer-extension-spec.es6 +++ b/internal_packages/open-tracking/spec/open-tracking-composer-extension-spec.es6 @@ -5,14 +5,13 @@ import {Message, QuotedHTMLTransformer} from 'nylas-exports'; const quote = `
On Feb 25 2016, at 3:38 pm, Drew <drew@nylas.com> wrote:
twst
`; describe("Open tracking composer extension", () => { - // Set up a draft, session that returns the draft, and metadata beforeEach(()=>{ this.draft = new Message(); this.draft.body = `TEST_BODY ${quote}`; this.session = { draft: () => this.draft, - changes: jasmine.createSpyObj('changes', ['add', 'commit']) + changes: jasmine.createSpyObj('changes', ['add', 'commit']), }; }); @@ -60,5 +59,5 @@ describe("Open tracking composer extension", () => { OpenTrackingComposerExtension.finalizeSessionBeforeSending({session: this.session}); expect(NylasEnv.reportError).toHaveBeenCalled() }); - }); + diff --git a/internal_packages/open-tracking/spec/open-tracking-icon-spec.jsx b/internal_packages/open-tracking/spec/open-tracking-icon-spec.jsx index 69eb59b0c..89a194111 100644 --- a/internal_packages/open-tracking/spec/open-tracking-icon-spec.jsx +++ b/internal_packages/open-tracking/spec/open-tracking-icon-spec.jsx @@ -22,7 +22,7 @@ function addOpenMetadata(obj, openCount) { describe("Open tracking icon", () => { beforeEach(() => { - this.thread = {metadata:[]}; + this.thread = {metadata: []}; }); @@ -65,7 +65,6 @@ describe("Open tracking icon", () => { expect(icon.children.length).toEqual(1); expect(icon.querySelector("img.unopened")).not.toBeNull(); expect(icon.querySelector("img.opened")).toBeNull(); - }); it("shows an opened icon if all messages with metadata are opened", () => { @@ -77,4 +76,5 @@ describe("Open tracking icon", () => { expect(icon.querySelector("img.opened")).not.toBeNull(); }); }); -}); \ No newline at end of file +}); + diff --git a/internal_packages/open-tracking/spec/open-tracking-message-status-spec.jsx b/internal_packages/open-tracking/spec/open-tracking-message-status-spec.jsx index 6c941322f..bb0643070 100644 --- a/internal_packages/open-tracking/spec/open-tracking-message-status-spec.jsx +++ b/internal_packages/open-tracking/spec/open-tracking-message-status-spec.jsx @@ -51,4 +51,5 @@ describe("Open tracking message status", () => { expect(icon.querySelector("img.unopened")).toBeNull(); expect(icon.querySelector("img.opened")).not.toBeNull(); }); -}); \ No newline at end of file +}); + diff --git a/spec/tasks/change-mail-task-spec.coffee b/spec/tasks/change-mail-task-spec.coffee index 05adf717c..753930950 100644 --- a/spec/tasks/change-mail-task-spec.coffee +++ b/spec/tasks/change-mail-task-spec.coffee @@ -557,7 +557,6 @@ describe "ChangeMailTask", -> b.threads = ['t3', 't4', 't7'] b.sequentialId = 1 c = new ChangeMailTask() - console.log([a,b,c].map((x) -> x.sequentialId)) c.threads = ['t0', 't7'] c.sequentialId = 2 expect(a.isDependentOnTask(b)).toEqual(false) diff --git a/src/flux/tasks/task-factory.es6 b/src/flux/tasks/task-factory.es6 index 64b0e07e2..97547fcec 100644 --- a/src/flux/tasks/task-factory.es6 +++ b/src/flux/tasks/task-factory.es6 @@ -30,23 +30,26 @@ const TaskFactory = { byAccount[accountId].threadsToUpdate.push(thread) }) - _.each(byAccount, ({categoriesToAdd, categoriesToRemove, threadsToUpdate}, accountId)=> { - const account = AccountStore.accountForId(accountId) - if (!(categoriesToAdd instanceof Array)) { - throw new Error("tasksForApplyingCategories: `categoriesToAdd` must return an array of Categories") + _.each(byAccount, (data, accountId) => { + const catToAdd = data.categoriesToAdd; + const catToRemove = data.categoriesToRemove; + const threadsToUpdate = data.threadsToUpdate; + const account = AccountStore.accountForId(accountId); + if (!(catToAdd instanceof Array)) { + throw new Error("tasksForApplyingCategories: `catToAdd` must return an array of Categories") } - if (!(categoriesToRemove instanceof Array)) { - throw new Error("tasksForApplyingCategories: `categoriesToRemove` must return an array of Categories") + if (!(catToRemove instanceof Array)) { + throw new Error("tasksForApplyingCategories: `catToRemove` must return an array of Categories") } if (account.usesFolders()) { - if (categoriesToAdd.length === 0) return; - if (categoriesToAdd.length > 1) { - throw new Error("tasksForApplyingCategories: `categoriesToAdd` must return a single `Category` (folder) for Exchange accounts") + if (catToAdd.length === 0) return; + if (catToAdd.length > 1) { + throw new Error("tasksForApplyingCategories: `catToAdd` must return a single `Category` (folder) for Exchange accounts") } - const folder = categoriesToAdd[0] + const folder = catToAdd[0] if (!(folder instanceof Category)) { - throw new Error("tasksForApplyingCategories: `categoriesToAdd` must return a Categories") + throw new Error("tasksForApplyingCategories: `catToAdd` must return a Categories") } tasks.push(new ChangeFolderTask({ @@ -55,8 +58,8 @@ const TaskFactory = { taskDescription, })) } else { - const labelsToAdd = categoriesToAdd - const labelsToRemove = categoriesToRemove + const labelsToAdd = catToAdd + const labelsToRemove = catToRemove if (labelsToAdd.length === 0 && labelsToRemove.length === 0) return; tasks.push(new ChangeLabelsTask({