Skip to content

Commit

Permalink
chore: enable verbatimModuleSyntax (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
ueokande authored Feb 26, 2024
1 parent 154a5be commit 0b1ae5a
Show file tree
Hide file tree
Showing 324 changed files with 656 additions and 851 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
node-version-file: 'package.json'
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm tsc
- run: pnpm type-checks
- run: pnpm lint
- run: pnpm test
- run: pnpm package
Expand Down
11 changes: 11 additions & 0 deletions jest.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
verbose: true,
testMatch: ["<rootDir>/test/**/*.test.+(ts|tsx|js|jsx)"],
transform: {
// Use isolated tsconfig for jest to disable verbatimModuleSyntax
// https://github.com/kulshekhar/ts-jest/issues/4081
"^.+\\.(ts|tsx)$": ["ts-jest", { tsconfig: "tsconfig.jest.json" }],
},
setupFiles: ["./test/main.ts"],
};
11 changes: 0 additions & 11 deletions jest.config.ts

This file was deleted.

10 changes: 5 additions & 5 deletions src/background/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { injectable, inject } from "inversify";
import BackgroundMessageListener from "./messaging/BackgroundMessageListener";
import FindPortListener from "./messaging/FindPortListener";
import VersionUseCase from "./usecases/VersionUseCase";
import FindRepositoryImpl from "./repositories/FindRepository";
import ReadyFrameRepository from "./repositories/ReadyFrameRepository";
import type { FindRepository } from "./repositories/FindRepository";
import type { ReadyFrameRepository } from "./repositories/ReadyFrameRepository";
import SettingsEventUseCase from "./usecases/SettingsEventUseCase";
import FrameClient from "./clients/FrameClient";
import type { FrameClient } from "./clients/FrameClient";
import AddonEnabledEventUseCase from "./usecases/AddonEnabledEventUseCase";
import LastSelectedTabRepository from "./repositories/LastSelectedTabRepository";
import type { LastSelectedTabRepository } from "./repositories/LastSelectedTabRepository";
import ModeUseCase from "./usecases/ModeUseCase";
import HintModeUseCase from "./usecases/HintModeUseCase";

Expand All @@ -19,7 +19,7 @@ export default class Application {
@inject(VersionUseCase)
private readonly versionUseCase: VersionUseCase,
@inject("FindRepository")
private readonly findRepository: FindRepositoryImpl,
private readonly findRepository: FindRepository,
@inject("ReadyFrameRepository")
private readonly frameRepository: ReadyFrameRepository,
@inject("LastSelectedTabRepository")
Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/AddonEnabledClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";

export default interface AddonEnabledClient {
export interface AddonEnabledClient {
enable(tabId: number): Promise<void>;

disable(tabId: number): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/ConsoleClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from "inversify";
import { newSender } from "./ConsoleMessageSender";

export default interface ConsoleClient {
export interface ConsoleClient {
showCommand(tabId: number, command: string): Promise<void>;

showFind(tabId: number): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/ConsoleFrameClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";

export default interface ConsoleFrameClient {
export interface ConsoleFrameClient {
resize(tabId: number, width: number, height: number): Promise<void>;
}

Expand Down
4 changes: 1 addition & 3 deletions src/background/clients/ConsoleMessageSender.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { Schema, Key, Request } from "../../messaging/schema/console";
import { Sender } from "../../messaging";

type ConsoleMessageSender = Sender<Schema>;

export const newSender = (tabId: number, frameId?: number) => {
const sender = new Sender<Schema>((type: Key, args: Request) => {
if (process.env.NODE_ENV === "development") {
Expand All @@ -17,4 +15,4 @@ export const newSender = (tabId: number, frameId?: number) => {
return sender;
};

export default ConsoleMessageSender;
export type ConsoleMessageSender = Sender<Schema>;
2 changes: 1 addition & 1 deletion src/background/clients/ContentMessageClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";

export default interface ContentMessageClient {
export interface ContentMessageClient {
scrollTo(
tabId: number,
frameId: number,
Expand Down
4 changes: 1 addition & 3 deletions src/background/clients/ContentMessageSender.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { Schema, Key, Request } from "../../messaging/schema/content";
import { Sender } from "../../messaging";

type ContentMessageSender = Sender<Schema>;

export const newSender = (tabId: number, frameId?: number) => {
const sender = new Sender<Schema>((type: Key, args: Request) => {
if (process.env.NODE_ENV === "development") {
Expand All @@ -18,4 +16,4 @@ export const newSender = (tabId: number, frameId?: number) => {
return sender;
};

export default ContentMessageSender;
export type ContentMessageSender = Sender<Schema>;
4 changes: 2 additions & 2 deletions src/background/clients/FindClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";
import type FindQuery from "../../shared/FindQuery";
import type { FindQuery } from "../../shared/findQuery";

export default interface FindClient {
export interface FindClient {
findNext(tabId: number, frameId: number, query: FindQuery): Promise<boolean>;

findPrev(tabId: number, frameId: number, query: FindQuery): Promise<boolean>;
Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/FrameClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";

export default interface FrameClient {
export interface FrameClient {
notifyFrameId(tabId: number, frameId: number): Promise<void>;
}

Expand Down
4 changes: 2 additions & 2 deletions src/background/clients/HintClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";
import type HTMLElementType from "../../shared/HTMLElementType";
import type { HTMLElementType } from "../../shared/HTMLElementType";

export type Point = {
x: number;
Expand All @@ -12,7 +12,7 @@ export type Size = {
height: number;
};

export default interface HintClient {
export interface HintClient {
lookupTargets(
tabId: number,
frameId: number,
Expand Down
4 changes: 2 additions & 2 deletions src/background/clients/ModeClient.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";
import Mode from "../../shared/Mode";
import { Mode } from "../../shared/mode";

export default interface ModeClient {
export interface ModeClient {
setMode(tabid: number, mode: Mode): Promise<void>;
}

Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/NavigateClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable } from "inversify";
import { newSender } from "./ContentMessageSender";

export default interface NavigateClient {
export interface NavigateClient {
historyNext(tabId: number): Promise<void>;

historyPrev(tabId: number): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion src/background/clients/TopFrameClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type Point = {
y: number;
};

export default interface TopFrameClient {
export interface TopFrameClient {
getWindowViewport(tabId: number): Promise<Rect>;

getFramePosition(tabId: number, frameId: number): Promise<Point | undefined>;
Expand Down
6 changes: 2 additions & 4 deletions src/background/command/AddBookmarkCommand.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type Command from "./Command";
import type { CommandContext } from "./Command";
import type { Completions } from "./Command";
import type ConsoleClient from "../clients/ConsoleClient";
import type { Command, CommandContext, Completions } from "./types";
import type { ConsoleClient } from "../clients/ConsoleClient";

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

class BufferCommand implements Command {
Expand Down
4 changes: 2 additions & 2 deletions src/background/command/BufferCommandHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Completions } from "../../shared/Completions";
import LastSelectedTabRepository from "../repositories/LastSelectedTabRepository";
import type { Completions } from "../../shared/completions";
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";

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

class BufferDeleteCommand implements Command {
Expand Down
4 changes: 1 addition & 3 deletions src/background/command/BufferDeletesCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type Command from "./Command";
import type { CommandContext } from "./Command";
import type { Completions } from "./Command";
import type { Command, CommandContext, Completions } from "./types";
import type BufferCommandHelper from "./BufferCommandHelper";

class BDeletesCommand implements Command {
Expand Down
4 changes: 2 additions & 2 deletions src/background/command/CommandRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Command from "./Command";
import type { Command } from "./types";

export default interface CommandRegistry {
export interface CommandRegistry {
register(cmd: Command): void;

getCommand(name: string): Command | undefined;
Expand Down
4 changes: 1 addition & 3 deletions src/background/command/HelpCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type Command from "./Command";
import type { CommandContext } from "./Command";
import type { Completions } from "./Command";
import type { Command, CommandContext, Completions } from "./types";

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

Expand Down
7 changes: 3 additions & 4 deletions src/background/command/OpenCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type Command from "./Command";
import type { CommandContext, Completions } from "./Command";
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 type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";
import OpenCommandHelper from "./OpenCommandHelper";

class OpenCommand implements Command {
Expand Down
6 changes: 3 additions & 3 deletions src/background/command/OpenCommandHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Completions, CompletionItem } from "./Command";
import type { Completions, CompletionItem } from "./types";
import * as filters from "./filters";
import type SearchEngineSettings from "../settings/SearchEngineSettings";
import type PropertySettings from "../settings/PropertySettings";
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";

const COMPLETION_ITEM_LIMIT = 10;

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

class QuitAllCommand implements Command {
names(): string[] {
Expand Down
3 changes: 1 addition & 2 deletions src/background/command/QuitCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type Command from "./Command";
import type { CommandContext, Completions } from "./Command";
import type { Completions, Command, CommandContext } from "./types";

class QuitCommand implements Command {
names(): string[] {
Expand Down
9 changes: 4 additions & 5 deletions src/background/command/SetCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type Command from "./Command";
import type { CommandContext, Completions } from "./Command";
import type PropertySettings from "../settings/PropertySettings";
import type PropertyRegistry from "../property/PropertyRegistry";
import type ConsoleClient from "../clients/ConsoleClient";
import type { Command, CommandContext, Completions } from "./types";
import type { PropertySettings } from "../settings/PropertySettings";
import type { PropertyRegistry } from "../property/PropertyRegistry";
import type { ConsoleClient } from "../clients/ConsoleClient";

const mustNumber = (v: any): number => {
const num = Number(v);
Expand Down
7 changes: 3 additions & 4 deletions src/background/command/TabOpenCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type Command from "./Command";
import type { CommandContext, Completions } from "./Command";
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 type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";
import OpenCommandHelper from "./OpenCommandHelper";

class TabOpenCommand implements Command {
Expand Down
7 changes: 3 additions & 4 deletions src/background/command/WindowOpenCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type Command from "./Command";
import type { CommandContext, Completions } from "./Command";
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 type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import type { PropertySettings } from "../settings/PropertySettings";
import OpenCommandHelper from "./OpenCommandHelper";

class WindowOpenCommand implements Command {
Expand Down
12 changes: 6 additions & 6 deletions src/background/command/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import SetCommand from "./SetCommand";
import TabOpenCommand from "./TabOpenCommand";
import WindowOpenCommand from "./WindowOpenCommand";
import BufferCommandHelper from "./BufferCommandHelper";
import PropertyRegistry from "../property/PropertyRegistry";
import PropertySettings from "../settings/PropertySettings";
import SearchEngineSettings from "../settings/SearchEngineSettings";
import CommandRegistry, { CommandRegistryImpl } from "./CommandRegistry";
import LastSelectedTabRepository from "../repositories/LastSelectedTabRepository";
import ConsoleClient from "../clients/ConsoleClient";
import type { PropertyRegistry } from "../property/PropertyRegistry";
import type { PropertySettings } from "../settings/PropertySettings";
import type { SearchEngineSettings } from "../settings/SearchEngineSettings";
import { type CommandRegistry, CommandRegistryImpl } from "./CommandRegistry";
import type { LastSelectedTabRepository } from "../repositories/LastSelectedTabRepository";
import type { ConsoleClient } from "../clients/ConsoleClient";

@injectable()
export class CommandRegistryFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {
Completions as CompletionsType,
CompletionGroup as CompletionGroupType,
CompletionItem as CompletionItemType,
} from "../../shared/Completions";
} from "../../shared/completions";

export type Completions = CompletionsType;
export type CompletionGroup = CompletionGroupType;
Expand All @@ -16,7 +16,7 @@ export type CommandContext = {
};
};

interface Command {
export interface Command {
names(): string[];

fullname(): string;
Expand All @@ -27,5 +27,3 @@ interface Command {

exec(ctx: CommandContext, force: boolean, args: string): Promise<void>;
}

export default Command;
4 changes: 2 additions & 2 deletions src/background/controllers/CommandController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { injectable, inject } from "inversify";
import { Completions } from "../../shared/Completions";
import type { Completions } from "../../shared/completions";
import CommandUseCase from "../usecases/CommandUseCase";
import RequestContext from "../messaging/RequestContext";
import type { RequestContext } from "../messaging/types";

@injectable()
export default class CommandController {
Expand Down
2 changes: 1 addition & 1 deletion src/background/controllers/ConsoleController.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { injectable, inject } from "inversify";
import ConsoleUseCase from "../usecases/ConsoleUseCase";
import RequestContext from "../messaging/RequestContext";
import type { RequestContext } from "../messaging/types";

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

@injectable()
export default class FindController {
Expand Down
Loading

0 comments on commit 0b1ae5a

Please sign in to comment.