Skip to content

Commit

Permalink
chore: migrate to prefixed imports for everything
Browse files Browse the repository at this point in the history
  • Loading branch information
jamiebrynes7 committed Nov 13, 2024
1 parent 0ac6c84 commit 2c47e2b
Show file tree
Hide file tree
Showing 23 changed files with 80 additions and 76 deletions.
2 changes: 1 addition & 1 deletion plugin/src/api/domain/section.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ProjectId } from "./project";
import type { ProjectId } from "@/api/domain/project";

export type SectionId = string;

Expand Down
6 changes: 3 additions & 3 deletions plugin/src/api/domain/task.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DueDate } from "./dueDate";
import type { ProjectId } from "./project";
import type { SectionId } from "./section";
import type { DueDate } from "@/api/domain/dueDate";
import type { ProjectId } from "@/api/domain/project";
import type { SectionId } from "@/api/domain/section";

export type TaskId = string;

Expand Down
12 changes: 6 additions & 6 deletions plugin/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Label } from "@/api/domain/label";
import type { Project } from "@/api/domain/project";
import type { Section } from "@/api/domain/section";
import type { CreateTaskParams, Task, TaskId } from "@/api/domain/task";
import type { RequestParams, WebFetcher, WebResponse } from "@/api/fetcher";
import debug from "@/log";
import camelize from "camelize-ts";
import snakify from "snakify-ts";
import debug from "../log";
import type { Label } from "./domain/label";
import type { Project } from "./domain/project";
import type { Section } from "./domain/section";
import type { CreateTaskParams, Task, TaskId } from "./domain/task";
import type { RequestParams, WebFetcher, WebResponse } from "./fetcher";

export class TodoistApiClient {
private token: string;
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/commands/addTask.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { MakeCommand } from "@/commands";
import type { Translations } from "@/i18n/translation";
import { MarkdownView, Notice, type TFile } from "obsidian";
import type { MakeCommand } from ".";
import type TodoistPlugin from "..";
import type { TaskCreationOptions } from "../ui/createTaskModal";
import type TodoistPlugin from "@/index";
import type { TaskCreationOptions } from "@/ui/createTaskModal";
import { MarkdownView, type TFile } from "obsidian";

export const addTask: MakeCommand = (plugin: TodoistPlugin, i18n: Translations["commands"]) => {
return {
Expand Down
10 changes: 7 additions & 3 deletions plugin/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {
addTask,
addTaskWithPageInContent,
addTaskWithPageInDescription,
} from "@/commands/addTask";
import { t } from "@/i18n";
import type { Translations } from "@/i18n/translation";
import type TodoistPlugin from "@/index";
import debug from "@/log";
import type { Command as ObsidianCommand } from "obsidian";
import type TodoistPlugin from "..";
import debug from "../log";
import { addTask, addTaskWithPageInContent, addTaskWithPageInDescription } from "./addTask";

export type MakeCommand = (
plugin: TodoistPlugin,
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/data/dueDateInfo.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DueDate } from "@/api/domain/dueDate";
import { DueDateInfo } from "@/data/dueDateInfo";
import { describe, expect, it, vi } from "vitest";
import type { DueDate } from "../api/domain/dueDate";
import { DueDateInfo } from "./dueDateInfo";

vi.mock("../now.ts", () => {
return {
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/data/dueDateInfo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DueDate } from "@/api/domain/dueDate";
import { now } from "@/now";
import moment from "moment";
import type { DueDate } from "../api/domain/dueDate";
import { now } from "../now";

export class DueDateInfo {
private m: moment.Moment | undefined;
Expand Down
18 changes: 9 additions & 9 deletions plugin/src/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { type TodoistApiClient, TodoistApiError } from "../api";
import type { Label, LabelId } from "../api/domain/label";
import type { Project, ProjectId } from "../api/domain/project";
import type { Section, SectionId } from "../api/domain/section";
import type { Task as ApiTask, CreateTaskParams, TaskId } from "../api/domain/task";
import { Maybe } from "../utils/maybe";
import { Repository, type RepositoryReader } from "./repository";
import { SubscriptionManager, type UnsubscribeCallback } from "./subscriptions";
import type { Task } from "./task";
import { type TodoistApiClient, TodoistApiError } from "@/api";
import type { Label, LabelId } from "@/api/domain/label";
import type { Project, ProjectId } from "@/api/domain/project";
import type { Section, SectionId } from "@/api/domain/section";
import type { Task as ApiTask, CreateTaskParams, TaskId } from "@/api/domain/task";
import { Repository, type RepositoryReader } from "@/data/repository";
import { SubscriptionManager, type UnsubscribeCallback } from "@/data/subscriptions";
import type { Task } from "@/data/task";
import { Maybe } from "@/utils/maybe";

export enum QueryErrorKind {
BadRequest = 0,
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/data/task.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { DueDate } from "@/api/domain/dueDate";
import type { Label } from "@/api/domain/label";
import type { DueDate } from "../api/domain/dueDate";
import type { Project } from "../api/domain/project";
import type { Section } from "../api/domain/section";
import type { Priority, TaskId } from "../api/domain/task";
import type { Project } from "@/api/domain/project";
import type { Section } from "@/api/domain/section";
import type { Priority, TaskId } from "@/api/domain/task";

export type Task = {
id: TaskId;
Expand Down
12 changes: 6 additions & 6 deletions plugin/src/data/transformations/grouping.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { DueDate } from "@/api/domain/dueDate";
import type { Label } from "@/api/domain/label";
import type { Project } from "@/api/domain/project";
import type { Section } from "@/api/domain/section";
import type { Task } from "@/data/task";
import { type GroupedTasks, groupBy } from "@/data/transformations/grouping";
import { GroupVariant } from "@/query/query";
import { describe, expect, it, vi } from "vitest";
import type { DueDate } from "../../api/domain/dueDate";
import type { Project } from "../../api/domain/project";
import type { Section } from "../../api/domain/section";
import { GroupVariant } from "../../query/query";
import type { Task } from "../task";
import { type GroupedTasks, groupBy } from "./grouping";

vi.mock("../../now.ts", () => {
return {
Expand Down
12 changes: 6 additions & 6 deletions plugin/src/data/transformations/grouping.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { Project } from "../../api/domain/project";
import type { Section } from "../../api/domain/section";
import type { Priority } from "../../api/domain/task";
import { GroupVariant } from "../../query/query";
import { DueDateInfo } from "../dueDateInfo";
import type { Task } from "../task";
import type { Project } from "@/api/domain/project";
import type { Section } from "@/api/domain/section";
import type { Priority } from "@/api/domain/task";
import { DueDateInfo } from "@/data/dueDateInfo";
import type { Task } from "@/data/task";
import { GroupVariant } from "@/query/query";

export type GroupedTasks = {
header: string;
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/data/transformations/relationships.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Task } from "@/data/task";
import { type TaskTree, buildTaskTree } from "@/data/transformations/relationships";
import { describe, expect, it } from "vitest";
import type { Task } from "../task";
import { type TaskTree, buildTaskTree } from "./relationships";

function makeTask(id: string, opts?: Partial<Task>): Task {
return {
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/data/transformations/relationships.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { TaskId } from "../../api/domain/task";
import type { Task } from "../task";
import type { TaskId } from "@/api/domain/task";
import type { Task } from "@/data/task";

export type TaskTree = Task & { children: TaskTree[] };

Expand Down
6 changes: 3 additions & 3 deletions plugin/src/data/transformations/sorting.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Task } from "@/data/task";
import { sortTasks } from "@/data/transformations/sorting";
import { SortingVariant } from "@/query/query";
import { describe, expect, it } from "vitest";
import { SortingVariant } from "../../query/query";
import type { Task } from "../task";
import { sortTasks } from "./sorting";

function makeTask(id: string, opts?: Partial<Task>): Task {
return {
Expand Down
6 changes: 3 additions & 3 deletions plugin/src/data/transformations/sorting.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Task } from "@/data//task";
import { DueDateInfo } from "@/data/dueDateInfo";
import { SortingVariant } from "@/query/query";
import moment from "moment";
import { SortingVariant } from "../../query/query";
import { DueDateInfo } from "../dueDateInfo";
import type { Task } from "../task";

export function sortTasks<T extends Task>(tasks: T[], sort: SortingVariant[]) {
tasks.sort((first, second) => {
Expand Down
14 changes: 7 additions & 7 deletions plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { setLanguage } from "@/i18n";
import "@/styles/main.scss";
import { TodoistApiClient } from "@/api";
import { ObsidianFetcher } from "@/api/fetcher";
import { registerCommands } from "@/commands";
import { QueryInjector } from "@/query/injector";
import { type Services, makeServices } from "@/services";
import { type Settings, useSettingsStore } from "@/settings";
import { SettingsTab } from "@/ui/settings";
import { type App, Plugin } from "obsidian";
import type { PluginManifest } from "obsidian";
import { TodoistApiClient } from "./api";
import { ObsidianFetcher } from "./api/fetcher";
import { registerCommands } from "./commands";
import { QueryInjector } from "./query/injector";
import { type Services, makeServices } from "./services";
import { type Settings, useSettingsStore } from "./settings";
import { SettingsTab } from "./ui/settings";

export default class TodoistPlugin extends Plugin {
public readonly services: Services;
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/query/parser.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ParsingError, type QueryWarning, parseQuery } from "@/query/parser";
import { GroupVariant, type Query, ShowMetadataVariant, SortingVariant } from "@/query/query";
import { describe, expect, it } from "vitest";
import { ParsingError, type QueryWarning, parseQuery } from "./parser";
import { GroupVariant, type Query, ShowMetadataVariant, SortingVariant } from "./query";

describe("parseQuery - rejections", () => {
type Testcase = {
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/query/parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { GroupVariant, type Query, ShowMetadataVariant, SortingVariant } from "@/query/query";
import YAML from "yaml";
import { GroupVariant, type Query, ShowMetadataVariant, SortingVariant } from "./query";

const possibleWarnings: Record<string, string> = {
JsonQuery:
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/query/replacements.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { GroupVariant, type Query } from "@/query/query";
import { applyReplacements } from "@/query/replacements";
import type {
MarkdownPostProcessorContext,
MarkdownRenderChild,
MarkdownSectionInformation,
} from "obsidian";
import { describe, expect, it } from "vitest";
import { GroupVariant, type Query } from "./query";
import { applyReplacements } from "./replacements";

class FakeContext implements MarkdownPostProcessorContext {
docId = "";
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/query/replacements.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Query } from "@/query/query";
import type { MarkdownPostProcessorContext } from "obsidian";
import type { Query } from "./query";

export function applyReplacements(query: Query, ctx: MarkdownPostProcessorContext) {
// Replace {filename} with the base file name of file where the query originated.
Expand Down
8 changes: 4 additions & 4 deletions plugin/src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type TodoistPlugin from "..";
import { TodoistAdapter } from "../data";
import { ModalHandler } from "./modals";
import { VaultTokenAccessor } from "./tokenAccessor";
import { TodoistAdapter } from "@/data";
import type TodoistPlugin from "@/index";
import { ModalHandler } from "@/services/modals";
import { VaultTokenAccessor } from "@/services/tokenAccessor";

export type Services = {
modals: ModalHandler;
Expand Down
4 changes: 2 additions & 2 deletions plugin/src/token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TodoistApiClient } from "@/api";
import { ObsidianFetcher } from "@/api/fetcher";
import { t } from "@/i18n";
import { TodoistApiClient } from "./api";
import { ObsidianFetcher } from "./api/fetcher";

export namespace TokenValidation {
export type Result =
Expand Down
2 changes: 1 addition & 1 deletion plugin/src/utils/types.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DeepPartial } from "@/utils/types";
import { describe, expect, it } from "vitest";
import { DeepPartial } from "./types";

type TestObject = {
a: number;
Expand Down

0 comments on commit 2c47e2b

Please sign in to comment.