Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: make import/export named #484

Merged
merged 3 commits into from
Jul 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
8 changes: 8 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@
},
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/consistent-type-imports": "error",
"@typescript-eslint/no-import-type-side-effects": "error",
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"no-restricted-exports": ["error", {
"restrictDefaultExports": {
"direct": true,
"named": true
}
}],
"no-console": "error"
},
"overrides": [
Expand Down
2 changes: 1 addition & 1 deletion e2e/blacklist.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "./lib/fixture";
import { newScrollableServer } from "./lib/servers";
import SettingRepository from "./lib/SettingRepository";
import { SettingRepository } from "./lib/SettingRepository";

const server = newScrollableServer();
const READY_STATE_SELECTOR =
Expand Down
2 changes: 1 addition & 1 deletion e2e/clipboard.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "./lib/fixture";
import * as clipboard from "./lib/clipboard";
import SettingRepository from "./lib/SettingRepository";
import { SettingRepository } from "./lib/SettingRepository";
import { newNopServer } from "./lib/servers";

const server = newNopServer();
Expand Down
2 changes: 1 addition & 1 deletion e2e/command.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "./lib/fixture";
import { newNopServer } from "./lib/servers";
import SettingRepository from "./lib/SettingRepository";
import { SettingRepository } from "./lib/SettingRepository";

const server = newNopServer();

Expand Down
2 changes: 1 addition & 1 deletion e2e/completion_open.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "./lib/fixture";
import { newNopServer } from "./lib/servers";
import SettingRepository from "./lib/SettingRepository";
import { SettingRepository } from "./lib/SettingRepository";

const server = newNopServer();

Expand Down
2 changes: 1 addition & 1 deletion e2e/find.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import { test, expect } from "./lib/fixture";
import { newSingleContentServer } from "./lib/servers";

Expand Down
2 changes: 1 addition & 1 deletion e2e/follow_properties.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { test, expect } from "./lib/fixture";
import { newSingleContentServer } from "./lib/servers";
import SettingRepository from "./lib/SettingRepository";
import { SettingRepository } from "./lib/SettingRepository";

const setupHintchars = async (api: typeof browser) => {
await new SettingRepository(api).save({
Expand Down
4 changes: 2 additions & 2 deletions e2e/lib/SettingRepository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SerializedSettings } from "../../src/settings/schema";
import type { SerializedSettings } from "../../src/settings/schema";

export default class SettingRepository {
export class SettingRepository {
constructor(private readonly api: typeof browser) {}

async save(serialized: SerializedSettings): Promise<void> {
Expand Down
16 changes: 8 additions & 8 deletions src/background/Application.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { injectable, inject } from "inversify";
import BackgroundMessageListener from "./messaging/BackgroundMessageListener";
import FindPortListener from "./messaging/FindPortListener";
import VersionUseCase from "./usecases/VersionUseCase";
import { BackgroundMessageListener } from "./messaging/BackgroundMessageListener";
import { FindPortListener } from "./messaging/FindPortListener";
import { VersionUseCase } from "./usecases/VersionUseCase";
import type { FindRepository } from "./repositories/FindRepository";
import type { ReadyFrameRepository } from "./repositories/ReadyFrameRepository";
import SettingsEventUseCase from "./usecases/SettingsEventUseCase";
import { SettingsEventUseCase } from "./usecases/SettingsEventUseCase";
import type { FrameClient } from "./clients/FrameClient";
import AddonEnabledEventUseCase from "./usecases/AddonEnabledEventUseCase";
import { AddonEnabledEventUseCase } from "./usecases/AddonEnabledEventUseCase";
import type { LastSelectedTabRepository } from "./repositories/LastSelectedTabRepository";
import ModeUseCase from "./usecases/ModeUseCase";
import HintModeUseCase from "./usecases/HintModeUseCase";
import { ModeUseCase } from "./usecases/ModeUseCase";
import { HintModeUseCase } from "./usecases/HintModeUseCase";

@injectable()
export default class Application {
export class Application {
constructor(
@inject(BackgroundMessageListener)
private readonly backgroundMessageListener: BackgroundMessageListener,
Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/ModeClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";
import { Mode } from "../../shared/mode";
import type { Mode } from "../../shared/mode";

export interface ModeClient {
setMode(tabid: number, mode: Mode): Promise<void>;
Expand Down
4 changes: 1 addition & 3 deletions src/background/command/AddBookmarkCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Command, CommandContext, Completions } from "./types";
import type { ConsoleClient } from "../clients/ConsoleClient";

class AddBookmarkCommand implements Command {
export class AddBookmarkCommand implements Command {
constructor(private readonly consoleClient: ConsoleClient) {}

names(): string[] {
Expand Down Expand Up @@ -49,5 +49,3 @@ class AddBookmarkCommand implements Command {
return this.consoleClient.showInfo(sender.tabId, message);
}
}

export default AddBookmarkCommand;
6 changes: 2 additions & 4 deletions src/background/command/BufferCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Command, CommandContext, Completions } from "./types";
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";
import BufferCommandHelper from "./BufferCommandHelper";
import { BufferCommandHelper } from "./BufferCommandHelper";

class BufferCommand implements Command {
export class BufferCommand implements Command {
constructor(
private readonly lastSelectedTabRepository: LastSelectedTabRepository,
private readonly bufferCommandHelper = new BufferCommandHelper(
Expand Down Expand Up @@ -87,5 +87,3 @@ class BufferCommand implements Command {
await chrome.tabs.update(tabId, { active: true });
}
}

export default BufferCommand;
2 changes: 1 addition & 1 deletion src/background/command/BufferCommandHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Completions } from "../../shared/completions";
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";

export default class BufferCommandHelper {
export class BufferCommandHelper {
constructor(
private readonly lastSelectedTabRepository: LastSelectedTabRepository,
) {}
Expand Down
6 changes: 2 additions & 4 deletions src/background/command/BufferDeleteCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Command, CommandContext, Completions } from "./types";
import type BufferCommandHelper from "./BufferCommandHelper";
import type { BufferCommandHelper } from "./BufferCommandHelper";

class BufferDeleteCommand implements Command {
export class BufferDeleteCommand implements Command {
constructor(private readonly bufferCommandHelper: BufferCommandHelper) {}

names(): string[] {
Expand Down Expand Up @@ -35,5 +35,3 @@ class BufferDeleteCommand implements Command {
return chrome.tabs.remove(tabs[0].id!);
}
}

export default BufferDeleteCommand;
6 changes: 2 additions & 4 deletions src/background/command/BufferDeletesCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Command, CommandContext, Completions } from "./types";
import type BufferCommandHelper from "./BufferCommandHelper";
import type { BufferCommandHelper } from "./BufferCommandHelper";

class BDeletesCommand implements Command {
export class BufferDeletesCommand implements Command {
constructor(private readonly bufferCommandHelper: BufferCommandHelper) {}

names(): string[] {
Expand Down Expand Up @@ -34,5 +34,3 @@ class BDeletesCommand implements Command {
await chrome.tabs.remove(ids);
}
}

export default BDeletesCommand;
4 changes: 1 addition & 3 deletions src/background/command/HelpCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Command, CommandContext, Completions } from "./types";

const url = "https://ueokande.github.io/vimmatic/";

class HelpCommand implements Command {
export class HelpCommand implements Command {
names(): string[] {
return ["h", "help"];
}
Expand All @@ -27,5 +27,3 @@ class HelpCommand implements Command {
await chrome.tabs.create({ url, active: true });
}
}

export default HelpCommand;
6 changes: 2 additions & 4 deletions src/background/command/OpenCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Command, CommandContext, Completions } from "./types";
import * as urls from "../../shared/urls";
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";
import OpenCommandHelper from "./OpenCommandHelper";
import { OpenCommandHelper } from "./OpenCommandHelper";

class OpenCommand implements Command {
export class OpenCommand implements Command {
constructor(
private readonly searchEngineSettings: SearchEngineSettings,
propertySettings: PropertySettings,
Expand Down Expand Up @@ -40,5 +40,3 @@ class OpenCommand implements Command {
await chrome.tabs.update({ url });
}
}

export default OpenCommand;
2 changes: 1 addition & 1 deletion src/background/command/OpenCommandHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { PropertySettings } from "../settings/PropertySettings";

const COMPLETION_ITEM_LIMIT = 10;

export default class OpenCommandHelper {
export class OpenCommandHelper {
constructor(
private readonly searchEngineSettings: SearchEngineSettings,
private readonly propertySettings: PropertySettings,
Expand Down
4 changes: 1 addition & 3 deletions src/background/command/QuitAllCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Command, CommandContext, Completions } from "./types";

class QuitAllCommand implements Command {
export class QuitAllCommand implements Command {
names(): string[] {
return ["qa", "quitall"];
}
Expand Down Expand Up @@ -30,5 +30,3 @@ class QuitAllCommand implements Command {
await chrome.tabs.remove(ids);
}
}

export default QuitAllCommand;
4 changes: 1 addition & 3 deletions src/background/command/QuitCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Completions, Command, CommandContext } from "./types";

class QuitCommand implements Command {
export class QuitCommand implements Command {
names(): string[] {
return ["q", "quit"];
}
Expand Down Expand Up @@ -28,5 +28,3 @@ class QuitCommand implements Command {
await chrome.tabs.remove(sender.tabId);
}
}

export default QuitCommand;
4 changes: 1 addition & 3 deletions src/background/command/SetCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const mustNumber = (v: any): number => {
return num;
};

class SetCommand implements Command {
export class SetCommand implements Command {
constructor(
private readonly propretySettings: PropertySettings,
private readonly propertyRegsitry: PropertyRegistry,
Expand Down Expand Up @@ -160,5 +160,3 @@ class SetCommand implements Command {
}
}
}

export default SetCommand;
6 changes: 2 additions & 4 deletions src/background/command/TabOpenCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Command, CommandContext, Completions } from "./types";
import * as urls from "../../shared/urls";
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";
import OpenCommandHelper from "./OpenCommandHelper";
import { OpenCommandHelper } from "./OpenCommandHelper";

class TabOpenCommand implements Command {
export class TabOpenCommand implements Command {
constructor(
private readonly searchEngineSettings: SearchEngineSettings,
propertySettings: PropertySettings,
Expand Down Expand Up @@ -40,5 +40,3 @@ class TabOpenCommand implements Command {
await chrome.tabs.create({ url });
}
}

export default TabOpenCommand;
6 changes: 2 additions & 4 deletions src/background/command/WindowOpenCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { Completions, Command, CommandContext } from "./types";
import * as urls from "../../shared/urls";
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";
import OpenCommandHelper from "./OpenCommandHelper";
import { OpenCommandHelper } from "./OpenCommandHelper";

class WindowOpenCommand implements Command {
export class WindowOpenCommand implements Command {
constructor(
private readonly searchEngineSettings: SearchEngineSettings,
propertySettings: PropertySettings,
Expand Down Expand Up @@ -40,5 +40,3 @@ class WindowOpenCommand implements Command {
await chrome.windows.create({ url });
}
}

export default WindowOpenCommand;
24 changes: 12 additions & 12 deletions src/background/command/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { injectable, inject } from "inversify";
import AddBookmarkCommand from "./AddBookmarkCommand";
import BufferCommand from "./BufferCommand";
import BufferDeleteCommand from "./BufferDeleteCommand";
import BufferDeletesCommand from "./BufferDeletesCommand";
import HelpCommand from "./HelpCommand";
import OpenCommand from "./OpenCommand";
import QuitAllCommand from "./QuitAllCommand";
import QuitCommand from "./QuitCommand";
import SetCommand from "./SetCommand";
import TabOpenCommand from "./TabOpenCommand";
import WindowOpenCommand from "./WindowOpenCommand";
import BufferCommandHelper from "./BufferCommandHelper";
import { AddBookmarkCommand } from "./AddBookmarkCommand";
import { BufferCommand } from "./BufferCommand";
import { BufferDeleteCommand } from "./BufferDeleteCommand";
import { BufferDeletesCommand } from "./BufferDeletesCommand";
import { HelpCommand } from "./HelpCommand";
import { OpenCommand } from "./OpenCommand";
import { QuitAllCommand } from "./QuitAllCommand";
import { QuitCommand } from "./QuitCommand";
import { SetCommand } from "./SetCommand";
import { TabOpenCommand } from "./TabOpenCommand";
import { WindowOpenCommand } from "./WindowOpenCommand";
import { BufferCommandHelper } from "./BufferCommandHelper";
import type { PropertyRegistry } from "../property/PropertyRegistry";
import type { PropertySettings } from "../settings/PropertySettings";
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
Expand Down
4 changes: 2 additions & 2 deletions src/background/controllers/CommandController.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { injectable, inject } from "inversify";
import type { Completions } from "../../shared/completions";
import CommandUseCase from "../usecases/CommandUseCase";
import { CommandUseCase } from "../usecases/CommandUseCase";
import type { RequestContext } from "../messaging/types";

@injectable()
export default class CommandController {
export class CommandController {
constructor(
@inject(CommandUseCase)
private readonly commandUseCase: CommandUseCase,
Expand Down
4 changes: 2 additions & 2 deletions src/background/controllers/ConsoleController.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { injectable, inject } from "inversify";
import ConsoleUseCase from "../usecases/ConsoleUseCase";
import { ConsoleUseCase } from "../usecases/ConsoleUseCase";
import type { RequestContext } from "../messaging/types";

@injectable()
export default class ConsoleController {
export class ConsoleController {
constructor(
@inject(ConsoleUseCase)
private readonly consoleUseCase: ConsoleUseCase,
Expand Down
4 changes: 2 additions & 2 deletions src/background/controllers/FindController.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { injectable, inject } from "inversify";
import type { Completions } from "../../shared/completions";
import FindUseCase from "../usecases/FindUseCase";
import { FindUseCase } from "../usecases/FindUseCase";
import type { RequestContext } from "../messaging/types";

@injectable()
export default class FindController {
export class FindController {
constructor(
@inject(FindUseCase)
private findUseCase: FindUseCase,
Expand Down
Loading
Loading