aboutsummaryrefslogtreecommitdiff
path: root/src/content/usecases
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2019-12-22 11:10:36 +0900
committerGitHub <noreply@github.com>2019-12-22 11:10:36 +0900
commitb1a6f374dca078dee2406ebe049715b826e37ca2 (patch)
tree5367c48648e2018f55f12d847baba94559e10040 /src/content/usecases
parentb2dcdedad729ff7087867da50e20578f9fc8fb29 (diff)
parentda72c2ddd916d79d134662e3985b53a4ac78af7a (diff)
Merge pull request #690 from ueokande/eslint-and-prettier
Eslint and prettier
Diffstat (limited to 'src/content/usecases')
-rw-r--r--src/content/usecases/AddonEnabledUseCase.ts2
-rw-r--r--src/content/usecases/ClipboardUseCase.ts8
-rw-r--r--src/content/usecases/FindUseCase.ts6
-rw-r--r--src/content/usecases/FollowMasterUseCase.ts46
-rw-r--r--src/content/usecases/FollowSlaveUseCase.ts6
-rw-r--r--src/content/usecases/HintKeyProducer.ts4
-rw-r--r--src/content/usecases/KeymapUseCase.ts16
-rw-r--r--src/content/usecases/MarkUseCase.ts6
-rw-r--r--src/content/usecases/ScrollUseCase.ts16
-rw-r--r--src/content/usecases/SettingUseCase.ts2
10 files changed, 56 insertions, 56 deletions
diff --git a/src/content/usecases/AddonEnabledUseCase.ts b/src/content/usecases/AddonEnabledUseCase.ts
index 2d6fa11..608a401 100644
--- a/src/content/usecases/AddonEnabledUseCase.ts
+++ b/src/content/usecases/AddonEnabledUseCase.ts
@@ -23,7 +23,7 @@ export default class AddonEnabledUseCase {
}
async toggle(): Promise<void> {
- let current = this.repository.get();
+ const current = this.repository.get();
await this.setEnabled(!current);
}
diff --git a/src/content/usecases/ClipboardUseCase.ts b/src/content/usecases/ClipboardUseCase.ts
index c8fe719..7f16f68 100644
--- a/src/content/usecases/ClipboardUseCase.ts
+++ b/src/content/usecases/ClipboardUseCase.ts
@@ -16,16 +16,16 @@ export default class ClipboardUseCase {
}
async yankCurrentURL(): Promise<string> {
- let url = window.location.href;
+ const url = window.location.href;
this.repository.write(url);
await this.consoleClient.info('Yanked ' + url);
return Promise.resolve(url);
}
async openOrSearch(newTab: boolean): Promise<void> {
- let search = this.settingRepository.get().search;
- let text = this.repository.read();
- let url = urls.searchUrl(text, search);
+ const search = this.settingRepository.get().search;
+ const text = this.repository.read();
+ const url = urls.searchUrl(text, search);
// TODO: Repeat pasting from clipboard instead of opening a certain url.
// 'Repeat last' command is implemented in the background script and cannot
diff --git a/src/content/usecases/FindUseCase.ts b/src/content/usecases/FindUseCase.ts
index 88b516c..c6a478f 100644
--- a/src/content/usecases/FindUseCase.ts
+++ b/src/content/usecases/FindUseCase.ts
@@ -19,7 +19,7 @@ export default class FindUseCase {
if (keyword) {
this.saveKeyword(keyword);
} else {
- let lastKeyword = await this.getKeyword();
+ const lastKeyword = await this.getKeyword();
if (!lastKeyword) {
return this.showNoLastKeywordError();
}
@@ -39,11 +39,11 @@ export default class FindUseCase {
private async findNextPrev(
backwards: boolean,
): Promise<void> {
- let keyword = await this.getKeyword();
+ const keyword = await this.getKeyword();
if (!keyword) {
return this.showNoLastKeywordError();
}
- let found = this.presenter.find(keyword, backwards);
+ const found = this.presenter.find(keyword, backwards);
if (found) {
this.consoleClient.info('Pattern found: ' + keyword);
} else {
diff --git a/src/content/usecases/FollowMasterUseCase.ts b/src/content/usecases/FollowMasterUseCase.ts
index 7d7e875..0e7f394 100644
--- a/src/content/usecases/FollowMasterUseCase.ts
+++ b/src/content/usecases/FollowMasterUseCase.ts
@@ -28,24 +28,24 @@ export default class FollowMasterUseCase {
}
startFollow(newTab: boolean, background: boolean): void {
- let hintchars = this.settingRepository.get().properties.hintchars;
+ const hintchars = this.settingRepository.get().properties.hintchars;
this.producer = new HintKeyProducer(hintchars);
this.followKeyRepository.clearKeys();
this.followMasterRepository.setCurrentFollowMode(newTab, background);
- let viewWidth = window.top.innerWidth;
- let viewHeight = window.top.innerHeight;
+ const viewWidth = window.top.innerWidth;
+ const viewHeight = window.top.innerHeight;
this.followSlaveClientFactory.create(window.top).requestHintCount(
{ width: viewWidth, height: viewHeight },
{ x: 0, y: 0 },
);
- let frameElements = window.document.querySelectorAll('iframe');
+ const frameElements = window.document.querySelectorAll('iframe');
for (let i = 0; i < frameElements.length; ++i) {
- let ele = frameElements[i] as HTMLFrameElement | HTMLIFrameElement;
- let { left: frameX, top: frameY } = ele.getBoundingClientRect();
- let client = this.followSlaveClientFactory.create(ele.contentWindow!!);
+ const ele = frameElements[i] as HTMLFrameElement | HTMLIFrameElement;
+ const { left: frameX, top: frameY } = ele.getBoundingClientRect();
+ const client = this.followSlaveClientFactory.create(ele.contentWindow!!);
client.requestHintCount(
{ width: viewWidth, height: viewHeight },
{ x: frameX, y: frameY },
@@ -55,28 +55,28 @@ export default class FollowMasterUseCase {
// eslint-disable-next-line max-statements
createSlaveHints(count: number, sender: Window): void {
- let produced = [];
+ const produced = [];
for (let i = 0; i < count; ++i) {
- let tag = this.producer!!.produce();
+ const tag = this.producer!!.produce();
produced.push(tag);
this.followMasterRepository.addTag(tag);
}
- let doc = window.document;
- let viewWidth = window.innerWidth || doc.documentElement.clientWidth;
- let viewHeight = window.innerHeight || doc.documentElement.clientHeight;
+ const doc = window.document;
+ const viewWidth = window.innerWidth || doc.documentElement.clientWidth;
+ const viewHeight = window.innerHeight || doc.documentElement.clientHeight;
let pos = { x: 0, y: 0 };
if (sender !== window) {
- let frameElements = window.document.querySelectorAll('iframe');
- let ele = Array.from(frameElements).find(e => e.contentWindow === sender);
+ const frameElements = window.document.querySelectorAll('iframe');
+ const ele = Array.from(frameElements).find(e => e.contentWindow === sender);
if (!ele) {
// elements of the sender is gone
return;
}
- let { left: frameX, top: frameY } = ele.getBoundingClientRect();
+ const { left: frameX, top: frameY } = ele.getBoundingClientRect();
pos = { x: frameX, y: frameY };
}
- let client = this.followSlaveClientFactory.create(sender);
+ const client = this.followSlaveClientFactory.create(sender);
client.createHints(
{ width: viewWidth, height: viewHeight },
pos,
@@ -100,8 +100,8 @@ export default class FollowMasterUseCase {
activate(tag: string): void {
this.followMasterRepository.clearTags();
- let newTab = this.followMasterRepository.getCurrentNewTabMode();
- let background = this.followMasterRepository.getCurrentBackgroundMode();
+ const newTab = this.followMasterRepository.getCurrentNewTabMode();
+ const background = this.followMasterRepository.getCurrentBackgroundMode();
this.broadcastToSlaves((client) => {
client.activateIfExists(tag, newTab, background);
client.clearHints();
@@ -125,8 +125,8 @@ export default class FollowMasterUseCase {
this.followKeyRepository.pushKey(key);
- let tag = this.getCurrentTag();
- let matched = this.followMasterRepository.getTagsByPrefix(tag);
+ const tag = this.getCurrentTag();
+ const matched = this.followMasterRepository.getTagsByPrefix(tag);
if (matched.length === 0) {
this.cancelFollow();
} else if (matched.length === 1) {
@@ -137,9 +137,9 @@ export default class FollowMasterUseCase {
}
private broadcastToSlaves(handler: (client: FollowSlaveClient) => void) {
- let allFrames = [window.self].concat(Array.from(window.frames as any));
- let clients = allFrames.map(w => this.followSlaveClientFactory.create(w));
- for (let client of clients) {
+ const allFrames = [window.self].concat(Array.from(window.frames as any));
+ const clients = allFrames.map(w => this.followSlaveClientFactory.create(w));
+ for (const client of clients) {
handler(client);
}
}
diff --git a/src/content/usecases/FollowSlaveUseCase.ts b/src/content/usecases/FollowSlaveUseCase.ts
index d471adb..fb805b9 100644
--- a/src/content/usecases/FollowSlaveUseCase.ts
+++ b/src/content/usecases/FollowSlaveUseCase.ts
@@ -34,7 +34,7 @@ export default class FollowSlaveUseCase {
}
countTargets(viewSize: Size, framePosition: Point): void {
- let count = this.presenter.getTargetCount(viewSize, framePosition);
+ const count = this.presenter.getTargetCount(viewSize, framePosition);
this.followMasterClient.responseHintCount(count);
}
@@ -56,13 +56,13 @@ export default class FollowSlaveUseCase {
}
async activate(tag: string, newTab: boolean, background: boolean) {
- let hint = this.presenter.getHint(tag);
+ const hint = this.presenter.getHint(tag);
if (!hint) {
return;
}
if (hint instanceof LinkHint) {
- let url = hint.getLink();
+ const url = hint.getLink();
let openNewTab = newTab;
// Open link by background script in order to prevent a popup block
if (hint.getLinkTarget() === '_blank') {
diff --git a/src/content/usecases/HintKeyProducer.ts b/src/content/usecases/HintKeyProducer.ts
index 241cd56..68f3fbd 100644
--- a/src/content/usecases/HintKeyProducer.ts
+++ b/src/content/usecases/HintKeyProducer.ts
@@ -19,14 +19,14 @@ export default class HintKeyProducer {
}
private increment(): void {
- let max = this.charset.length - 1;
+ const max = this.charset.length - 1;
if (this.counter.every(x => x === max)) {
this.counter = new Array(this.counter.length + 1).fill(0);
return;
}
this.counter.reverse();
- let len = this.charset.length;
+ const len = this.charset.length;
let num = this.counter.reduce((x, y, index) => x + y * len ** index) + 1;
for (let i = 0; i < this.counter.length; ++i) {
this.counter[i] = num % len;
diff --git a/src/content/usecases/KeymapUseCase.ts b/src/content/usecases/KeymapUseCase.ts
index a2e7cc3..074de72 100644
--- a/src/content/usecases/KeymapUseCase.ts
+++ b/src/content/usecases/KeymapUseCase.ts
@@ -37,17 +37,17 @@ export default class KeymapUseCase {
// eslint-disable-next-line max-statements
nextOps(key: Key): { repeat: number, op: operations.Operation } | null {
- let sequence = this.repository.enqueueKey(key);
- let baseSequence = sequence.trimNumericPrefix();
+ const sequence = this.repository.enqueueKey(key);
+ const baseSequence = sequence.trimNumericPrefix();
if (baseSequence.length() === 1 && this.blacklistKey(key)) {
// ignore if the input starts with black list keys
this.repository.clear();
return null;
}
- let keymaps = this.keymapEntityMap();
- let matched = keymaps.filter(([seq]) => seq.startsWith(sequence));
- let baseMatched = keymaps.filter(([seq]) => seq.startsWith(baseSequence));
+ const keymaps = this.keymapEntityMap();
+ const matched = keymaps.filter(([seq]) => seq.startsWith(sequence));
+ const baseMatched = keymaps.filter(([seq]) => seq.startsWith(baseSequence));
if (matched.length === 1 &&
sequence.length() === matched[0][0].length()) {
@@ -71,7 +71,7 @@ export default class KeymapUseCase {
}
private keymapEntityMap(): [KeySequence, operations.Operation][] {
- let keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps);
+ const keymaps = this.settingRepository.get().keymaps.combine(reservedKeymaps);
let entries = keymaps.entries().map(
([keys, op]) => [KeySequence.fromMapKeys(keys), op]
) as [KeySequence, operations.Operation][];
@@ -86,8 +86,8 @@ export default class KeymapUseCase {
}
private blacklistKey(key: Key): boolean {
- let url = this.addressRepository.getCurrentURL();
- let blacklist = this.settingRepository.get().blacklist;
+ const url = this.addressRepository.getCurrentURL();
+ const blacklist = this.settingRepository.get().blacklist;
return blacklist.includeKey(url, key);
}
}
diff --git a/src/content/usecases/MarkUseCase.ts b/src/content/usecases/MarkUseCase.ts
index a7d5ad8..8cd0c72 100644
--- a/src/content/usecases/MarkUseCase.ts
+++ b/src/content/usecases/MarkUseCase.ts
@@ -17,7 +17,7 @@ export default class MarkUseCase {
}
async set(key: string): Promise<void> {
- let pos = this.scrollPresenter.getScroll();
+ const pos = this.scrollPresenter.getScroll();
if (this.globalKey(key)) {
this.client.setGloablMark(key, pos);
await this.consoleClient.info(`Set global mark to '${key}'`);
@@ -31,7 +31,7 @@ export default class MarkUseCase {
if (this.globalKey(key)) {
await this.client.jumpGlobalMark(key);
} else {
- let pos = this.repository.get(key);
+ const pos = this.repository.get(key);
if (!pos) {
throw new Error('Mark is not set');
}
@@ -40,7 +40,7 @@ export default class MarkUseCase {
}
scroll(x: number, y: number): void {
- let smooth = this.settingRepository.get().properties.smoothscroll;
+ const smooth = this.settingRepository.get().properties.smoothscroll;
this.scrollPresenter.scrollTo(x, y, smooth);
}
diff --git a/src/content/usecases/ScrollUseCase.ts b/src/content/usecases/ScrollUseCase.ts
index 32cbef1..c68c889 100644
--- a/src/content/usecases/ScrollUseCase.ts
+++ b/src/content/usecases/ScrollUseCase.ts
@@ -11,42 +11,42 @@ export default class ScrollUseCase {
}
scrollVertically(count: number): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollVertically(count, smooth);
}
scrollHorizonally(count: number): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollHorizonally(count, smooth);
}
scrollPages(count: number): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollPages(count, smooth);
}
scrollToTop(): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollToTop(smooth);
}
scrollToBottom(): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollToBottom(smooth);
}
scrollToHome(): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollToHome(smooth);
}
scrollToEnd(): void {
- let smooth = this.getSmoothScroll();
+ const smooth = this.getSmoothScroll();
this.presenter.scrollToEnd(smooth);
}
private getSmoothScroll(): boolean {
- let settings = this.settingRepository.get();
+ const settings = this.settingRepository.get();
return settings.properties.smoothscroll;
}
}
diff --git a/src/content/usecases/SettingUseCase.ts b/src/content/usecases/SettingUseCase.ts
index 4608039..67d1be6 100644
--- a/src/content/usecases/SettingUseCase.ts
+++ b/src/content/usecases/SettingUseCase.ts
@@ -12,7 +12,7 @@ export default class SettingUseCase {
}
async reload(): Promise<Settings> {
- let settings = await this.client.load();
+ const settings = await this.client.load();
this.repository.set(settings);
return settings;
}