From 9ae814dfe45426f8df9b89b305392770344a7d50 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sun, 17 Sep 2017 08:59:12 +0900 Subject: more strict lint --- src/background/tabs.js | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/background/tabs.js') diff --git a/src/background/tabs.js b/src/background/tabs.js index bd69b4b..32f71ba 100644 --- a/src/background/tabs.js +++ b/src/background/tabs.js @@ -12,9 +12,8 @@ const reopenTab = () => { let session = sessions[0]; if (session.tab) { return browser.sessions.restore(session.tab.sessionId); - } else { - return browser.sessions.restore(session.window.sessionId); } + return browser.sessions.restore(session.window.sessionId); }); }; @@ -24,20 +23,20 @@ const selectAt = (index) => { return; } if (index < 0 || tabs.length <= index) { - throw new RangeError(`tab ${index} does not exist`) + throw new RangeError(`tab ${index} does not exist`); } let id = tabs[index].id; - return browser.tabs.update(id, { active: true }) + return browser.tabs.update(id, { active: true }); }); }; const selectByKeyword = (current, keyword) => { return browser.tabs.query({ currentWindow: true }).then((tabs) => { let matched = tabs.filter((t) => { - return t.url.includes(keyword) || t.title.includes(keyword) - }) + return t.url.includes(keyword) || t.title.includes(keyword); + }); - if (matched.length == 0) { + if (matched.length === 0) { throw new RangeError('No matching buffer for ' + keyword); } for (let tab of matched) { @@ -47,13 +46,13 @@ const selectByKeyword = (current, keyword) => { } return browser.tabs.update(matched[0].id, { active: true }); }); -} +}; const getCompletions = (keyword) => { return browser.tabs.query({ currentWindow: true }).then((tabs) => { let matched = tabs.filter((t) => { - return t.url.includes(keyword) || t.title.includes(keyword) - }) + return t.url.includes(keyword) || t.title.includes(keyword); + }); return matched; }); }; @@ -63,9 +62,9 @@ const selectPrevTab = (current, count) => { if (tabs.length < 2) { return; } - let select = (current - count) % tabs.length + let select = (current - count) % tabs.length; let id = tabs[select].id; - return browser.tabs.update(id, { active: true }) + return browser.tabs.update(id, { active: true }); }); }; @@ -74,9 +73,9 @@ const selectNextTab = (current, count) => { if (tabs.length < 2) { return; } - let select = (current + count + tabs.length) % tabs.length + let select = (current + count + tabs.length) % tabs.length; let id = tabs[select].id; - return browser.tabs.update(id, { active: true }) + return browser.tabs.update(id, { active: true }); }); }; @@ -87,4 +86,7 @@ const reload = (current, cache) => { ); }; -export { closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, selectPrevTab, selectNextTab, reload }; +export { + closeTab, reopenTab, selectAt, selectByKeyword, getCompletions, + selectPrevTab, selectNextTab, reload +}; -- cgit v1.2.3