aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-08-12 21:01:02 +0900
committerGitHub <noreply@github.com>2020-08-12 21:01:02 +0900
commitbf6762f0c0c47a20b6a3e722711fafc6611793a9 (patch)
tree67bfdcee88c8fb2bc19277e58684dcf5d2d03be4 /src
parent6f7f501c699c53eb63ce5576cf2464ecf4cfe162 (diff)
parent7e8c99d43a402b9e025a710a00879d557ac5b071 (diff)
Merge pull request #798 from ueokande/eslint
Improve eslint
Diffstat (limited to 'src')
-rw-r--r--src/@types/browser/index.d.ts13
-rw-r--r--src/@types/web-ext-api/index.d.ts14
-rw-r--r--src/background/completion/impl/BookmarkRepositoryImpl.ts8
-rw-r--r--src/background/completion/impl/HistoryRepositoryImpl.ts8
-rw-r--r--src/background/completion/impl/TabRepositoryImpl.ts6
-rw-r--r--src/background/presenters/TabPresenter.ts24
-rw-r--r--src/background/repositories/BrowserSettingRepository.ts15
-rw-r--r--src/background/usecases/NavigateUseCase.ts12
-rw-r--r--src/background/usecases/SettingUseCase.ts2
-rw-r--r--src/content/presenters/FindPresenter.ts20
-rw-r--r--src/content/repositories/ClipboardRepository.ts2
-rw-r--r--src/content/usecases/FollowMasterUseCase.ts4
-rw-r--r--src/settings/components/index.tsx4
-rw-r--r--src/shared/Command.ts29
-rw-r--r--src/shared/settings/Settings.ts2
15 files changed, 73 insertions, 90 deletions
diff --git a/src/@types/browser/index.d.ts b/src/@types/browser/index.d.ts
new file mode 100644
index 0000000..14acfe0
--- /dev/null
+++ b/src/@types/browser/index.d.ts
@@ -0,0 +1,13 @@
+// NOTE: window.find is not standard API
+// https://developer.mozilla.org/en-US/docs/Web/API/Window/find
+interface Window {
+ find(
+ aString: string,
+ aCaseSensitive?: boolean,
+ aBackwards?: boolean,
+ aWrapAround?: boolean,
+ aWholeWord?: boolean,
+ aSearchInFrames?: boolean,
+ aShowDialog?: boolean
+ ): boolean;
+}
diff --git a/src/@types/web-ext-api/index.d.ts b/src/@types/web-ext-api/index.d.ts
new file mode 100644
index 0000000..7eed334
--- /dev/null
+++ b/src/@types/web-ext-api/index.d.ts
@@ -0,0 +1,14 @@
+declare namespace browser.browserSettings.homepageOverride {
+ type BrowserSettings = {
+ value: string;
+ levelOfControl: LevelOfControlType;
+ };
+
+ type LevelOfControlType =
+ | "not_controllable"
+ | "controlled_by_other_extensions"
+ | "controllable_by_this_extension"
+ | "controlled_by_this_extension";
+
+ function get(param: { [key: string]: string }): Promise<BrowserSettings>;
+}
diff --git a/src/background/completion/impl/BookmarkRepositoryImpl.ts b/src/background/completion/impl/BookmarkRepositoryImpl.ts
index 2bc779d..ed6c5a6 100644
--- a/src/background/completion/impl/BookmarkRepositoryImpl.ts
+++ b/src/background/completion/impl/BookmarkRepositoryImpl.ts
@@ -23,7 +23,7 @@ export default class CachedBookmarkRepository implements BookmarkRepository {
.filter((item) => {
let url = undefined;
try {
- url = new URL(item.url!!);
+ url = new URL(item.url!);
} catch (e) {
return false;
}
@@ -31,8 +31,8 @@ export default class CachedBookmarkRepository implements BookmarkRepository {
})
.slice(0, COMPLETION_ITEM_LIMIT)
.map((item) => ({
- title: item.title!!,
- url: item.url!!,
+ title: item.title!,
+ url: item.url!,
}));
}
@@ -41,7 +41,7 @@ export default class CachedBookmarkRepository implements BookmarkRepository {
return query.split(" ").every((keyword) => {
return (
item.title.toLowerCase().includes(keyword.toLowerCase()) ||
- item.url!!.includes(keyword)
+ item.url!.includes(keyword)
);
});
});
diff --git a/src/background/completion/impl/HistoryRepositoryImpl.ts b/src/background/completion/impl/HistoryRepositoryImpl.ts
index b1992a4..3bf064e 100644
--- a/src/background/completion/impl/HistoryRepositoryImpl.ts
+++ b/src/background/completion/impl/HistoryRepositoryImpl.ts
@@ -36,8 +36,8 @@ export default class CachedHistoryRepository implements HistoryRepository {
.sort((x, y) => Number(y.visitCount) - Number(x.visitCount))
.slice(0, COMPLETION_ITEM_LIMIT)
.map((item) => ({
- title: item.title!!,
- url: item.url!!,
+ title: item.title!,
+ url: item.url!,
}));
}
@@ -59,8 +59,8 @@ export default class CachedHistoryRepository implements HistoryRepository {
return items.filter((item) => {
return query.split(" ").every((keyword) => {
return (
- item.title!!.toLowerCase().includes(keyword.toLowerCase()) ||
- item.url!!.includes(keyword)
+ item.title!.toLowerCase().includes(keyword.toLowerCase()) ||
+ item.url!.includes(keyword)
);
});
});
diff --git a/src/background/completion/impl/TabRepositoryImpl.ts b/src/background/completion/impl/TabRepositoryImpl.ts
index 5e33e5a..a279bd4 100644
--- a/src/background/completion/impl/TabRepositoryImpl.ts
+++ b/src/background/completion/impl/TabRepositoryImpl.ts
@@ -30,10 +30,10 @@ export default class TabRepositoryImpl implements TabRepository {
private static toEntity(tab: browser.tabs.Tab): Tab {
return {
- id: tab.id!!,
- url: tab.url!!,
+ id: tab.id!,
+ url: tab.url!,
active: tab.active,
- title: tab.title!!,
+ title: tab.title!,
faviconUrl: tab.favIconUrl,
index: tab.index,
};
diff --git a/src/background/presenters/TabPresenter.ts b/src/background/presenters/TabPresenter.ts
index 09cfa23..2f8f5d9 100644
--- a/src/background/presenters/TabPresenter.ts
+++ b/src/background/presenters/TabPresenter.ts
@@ -8,7 +8,17 @@ type Tab = browser.tabs.Tab;
export default interface TabPresenter {
open(url: string, tabId?: number): Promise<Tab>;
- create(url: string, opts?: object): Promise<Tab>;
+ create(
+ url: string,
+ opts?: {
+ active?: boolean;
+ cookieStoreId?: string;
+ index?: number;
+ openerTabId?: number;
+ pinned?: boolean;
+ windowId?: number;
+ }
+ ): Promise<Tab>;
getCurrent(): Promise<Tab>;
@@ -44,7 +54,17 @@ export class TabPresenterImpl implements TabPresenter {
return browser.tabs.update(tabId, { url });
}
- create(url: string, opts?: object): Promise<Tab> {
+ create(
+ url: string,
+ opts?: {
+ active?: boolean;
+ cookieStoreId?: string;
+ index?: number;
+ openerTabId?: number;
+ pinned?: boolean;
+ windowId?: number;
+ }
+ ): Promise<Tab> {
return browser.tabs.create({ url, ...opts });
}
diff --git a/src/background/repositories/BrowserSettingRepository.ts b/src/background/repositories/BrowserSettingRepository.ts
index 20013f4..e24874b 100644
--- a/src/background/repositories/BrowserSettingRepository.ts
+++ b/src/background/repositories/BrowserSettingRepository.ts
@@ -1,21 +1,6 @@
import { injectable } from "tsyringe";
import * as urls from "../../shared/urls";
-declare namespace browser.browserSettings.homepageOverride {
- type BrowserSettings = {
- value: string;
- levelOfControl: LevelOfControlType;
- };
-
- type LevelOfControlType =
- | "not_controllable"
- | "controlled_by_other_extensions"
- | "controllable_by_this_extension"
- | "controlled_by_this_extension";
-
- function get(param: object): Promise<BrowserSettings>;
-}
-
@injectable()
export default class BrowserSettingRepository {
async getHomepageUrls(): Promise<string[]> {
diff --git a/src/background/usecases/NavigateUseCase.ts b/src/background/usecases/NavigateUseCase.ts
index 2e887e7..974606c 100644
--- a/src/background/usecases/NavigateUseCase.ts
+++ b/src/background/usecases/NavigateUseCase.ts
@@ -11,27 +11,27 @@ export default class NavigateUseCase {
async openHistoryNext(): Promise<void> {
const tab = await this.tabPresenter.getCurrent();
- await this.navigateClient.historyNext(tab.id!!);
+ await this.navigateClient.historyNext(tab.id!);
}
async openHistoryPrev(): Promise<void> {
const tab = await this.tabPresenter.getCurrent();
- await this.navigateClient.historyPrev(tab.id!!);
+ await this.navigateClient.historyPrev(tab.id!);
}
async openLinkNext(): Promise<void> {
const tab = await this.tabPresenter.getCurrent();
- await this.navigateClient.linkNext(tab.id!!);
+ await this.navigateClient.linkNext(tab.id!);
}
async openLinkPrev(): Promise<void> {
const tab = await this.tabPresenter.getCurrent();
- await this.navigateClient.linkPrev(tab.id!!);
+ await this.navigateClient.linkPrev(tab.id!);
}
async openParent(): Promise<void> {
const tab = await this.tabPresenter.getCurrent();
- const url = new URL(tab.url!!);
+ const url = new URL(tab.url!);
if (url.hash.length > 0) {
url.hash = "";
} else if (url.search.length > 0) {
@@ -50,7 +50,7 @@ export default class NavigateUseCase {
async openRoot(): Promise<void> {
const tab = await this.tabPresenter.getCurrent();
- const url = new URL(tab.url!!);
+ const url = new URL(tab.url!);
await this.tabPresenter.open(url.origin);
}
}
diff --git a/src/background/usecases/SettingUseCase.ts b/src/background/usecases/SettingUseCase.ts
index ccee227..34c1f3a 100644
--- a/src/background/usecases/SettingUseCase.ts
+++ b/src/background/usecases/SettingUseCase.ts
@@ -36,7 +36,7 @@ export default class SettingUseCase {
this.showUnableToLoad(e);
value = DefaultSettingData.toSettings();
}
- await this.cachedSettingRepository.update(value!!);
+ await this.cachedSettingRepository.update(value!);
return value;
}
diff --git a/src/content/presenters/FindPresenter.ts b/src/content/presenters/FindPresenter.ts
index 117142c..b25190c 100644
--- a/src/content/presenters/FindPresenter.ts
+++ b/src/content/presenters/FindPresenter.ts
@@ -4,26 +4,6 @@ export default interface FindPresenter {
clearSelection(): void;
}
-// window.find(aString, aCaseSensitive, aBackwards, aWrapAround,
-// aWholeWord, aSearchInFrames);
-//
-// NOTE: window.find is not standard API
-// https://developer.mozilla.org/en-US/docs/Web/API/Window/find
-interface MyWindow extends Window {
- find(
- aString: string,
- aCaseSensitive?: boolean,
- aBackwards?: boolean,
- aWrapAround?: boolean,
- aWholeWord?: boolean,
- aSearchInFrames?: boolean,
- aShowDialog?: boolean
- ): boolean;
-}
-
-// eslint-disable-next-line no-var, vars-on-top, init-declarations
-declare var window: MyWindow;
-
export class FindPresenterImpl implements FindPresenter {
find(keyword: string, backwards: boolean): boolean {
const caseSensitive = false;
diff --git a/src/content/repositories/ClipboardRepository.ts b/src/content/repositories/ClipboardRepository.ts
index a700543..20e7367 100644
--- a/src/content/repositories/ClipboardRepository.ts
+++ b/src/content/repositories/ClipboardRepository.ts
@@ -15,7 +15,7 @@ export class ClipboardRepositoryImpl {
textarea.focus();
const ok = window.document.execCommand("paste");
- const value = textarea.textContent!!;
+ const value = textarea.textContent!;
textarea.remove();
if (!ok) {
diff --git a/src/content/usecases/FollowMasterUseCase.ts b/src/content/usecases/FollowMasterUseCase.ts
index 329f05a..88c682e 100644
--- a/src/content/usecases/FollowMasterUseCase.ts
+++ b/src/content/usecases/FollowMasterUseCase.ts
@@ -47,7 +47,7 @@ export default class FollowMasterUseCase {
for (let i = 0; i < frameElements.length; ++i) {
const ele = frameElements[i] as HTMLFrameElement | HTMLIFrameElement;
const { left: frameX, top: frameY } = ele.getBoundingClientRect();
- const client = this.followSlaveClientFactory.create(ele.contentWindow!!);
+ const client = this.followSlaveClientFactory.create(ele.contentWindow!);
client.requestHintCount(
{ width: viewWidth, height: viewHeight },
{ x: frameX, y: frameY }
@@ -59,7 +59,7 @@ export default class FollowMasterUseCase {
createSlaveHints(count: number, sender: Window): void {
const produced = [];
for (let i = 0; i < count; ++i) {
- const tag = this.producer!!.produce();
+ const tag = this.producer!.produce();
produced.push(tag);
this.followMasterRepository.addTag(tag);
}
diff --git a/src/settings/components/index.tsx b/src/settings/components/index.tsx
index 5793a8f..9d71cac 100644
--- a/src/settings/components/index.tsx
+++ b/src/settings/components/index.tsx
@@ -106,9 +106,9 @@ class SettingsComponent extends React.Component<Props> {
let fields = null;
const disabled = this.props.error.length > 0;
if (this.props.source === "form") {
- fields = this.renderFormFields(this.props.form!!);
+ fields = this.renderFormFields(this.props.form!);
} else if (this.props.source === "json") {
- fields = this.renderJsonFields(this.props.json!!, this.props.error);
+ fields = this.renderJsonFields(this.props.json!, this.props.error);
}
return (
<div>
diff --git a/src/shared/Command.ts b/src/shared/Command.ts
index 05b8b83..70347bf 100644
--- a/src/shared/Command.ts
+++ b/src/shared/Command.ts
@@ -13,32 +13,3 @@ export enum Command {
Set = "set",
Help = "help",
}
-
-export namespace Command {
- export function members(): Command[] {
- return [
- Command.Open,
- Command.TabOpen,
- Command.WindowOpen,
- Command.Buffer,
- Command.BufferDelete,
- Command.BufferDeleteForce,
- Command.BuffersDelete,
- Command.BuffersDeleteForce,
- Command.AddBookmark,
- Command.Quit,
- Command.QuitAll,
- Command.Set,
- Command.Help,
- ];
- }
-
- export function valueOf(value: string): Command {
- const map = new Map(members().map((cmd) => [cmd.toString(), cmd]));
- const cmd = map.get(value);
- if (!cmd) {
- throw new Error(`unknown command '${value}`);
- }
- return cmd;
- }
-}
diff --git a/src/shared/settings/Settings.ts b/src/shared/settings/Settings.ts
index 6f178ea..f37fbf0 100644
--- a/src/shared/settings/Settings.ts
+++ b/src/shared/settings/Settings.ts
@@ -43,7 +43,7 @@ export default class Settings {
const valid = validate(json);
if (!valid) {
const message = (validate as any)
- .errors!!.map((err: Ajv.ErrorObject) => {
+ .errors!.map((err: Ajv.ErrorObject) => {
return `'${err.dataPath}' ${err.message}`;
})
.join("; ");