Skip to content

Commit

Permalink
add sort and tailwind prettier configs; run them
Browse files Browse the repository at this point in the history
  • Loading branch information
cloverich committed Sep 2, 2024
1 parent cd5decf commit 1f77968
Show file tree
Hide file tree
Showing 87 changed files with 307 additions and 346 deletions.
4 changes: 3 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"plugins": ["prettier-plugin-organize-imports", "prettier-plugin-tailwindcss"]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
"mobx-react-lite": "^2.0.7",
"mocha": "^10.2.0",
"prettier": "3.2.4",
"prettier-plugin-organize-imports": "^4.0.0",
"prettier-plugin-tailwindcss": "^0.6.6",
"react": "^18.2.0",
"react-day-picker": "^8.10.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion scripts/migrate-uuidv7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// NOTE: This script won't actually run here, because the databse is compiled
// against a target electron version, rather than the local node version. So
// I run it in the preload/client/index.ts file; keeping here for reference.
import { V7Generator } from "uuidv7";
import Knex from "knex";
import { V7Generator } from "uuidv7";

const knex = Knex({
client: "better-sqlite3",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { SelectField } from "evergreen-ui";
import React from "react";

interface SelectProps<T extends string> {
options: T[];
Expand Down
14 changes: 7 additions & 7 deletions src/components/Sidesheet.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from "react";
import * as SheetPrimitive from "@radix-ui/react-dialog";
import { Cross2Icon } from "@radix-ui/react-icons";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@udecode/cn";
import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";

const Sheet = SheetPrimitive.Root;

Expand Down Expand Up @@ -129,13 +129,13 @@ SheetDescription.displayName = SheetPrimitive.Description.displayName;

export {
Sheet,
SheetPortal,
SheetOverlay,
SheetTrigger,
SheetClose,
SheetContent,
SheetHeader,
SheetDescription,
SheetFooter,
SheetHeader,
SheetOverlay,
SheetPortal,
SheetTitle,
SheetDescription,
SheetTrigger,
};
7 changes: 3 additions & 4 deletions src/components/icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// icons in all their components. Will either prefer these throughou,
// or migrate the plate icons to use evergreens
// https://platejs.org/docs/components/installation/manual
import React from "react";
import { cva } from "class-variance-authority";
import {
AlignCenter,
Expand All @@ -12,16 +11,15 @@ import {
AlignRight,
Archive,
Baseline,
Bug,
Bold,
Bug,
Check,
ChevronUp,
ChevronDown,
ChevronRight,
ChevronUp,
ChevronsUpDown,
Code2,
Combine,
Edit2,
ExternalLink,
Eye,
FileCode,
Expand Down Expand Up @@ -75,6 +73,7 @@ import {
WrapText,
X,
} from "lucide-react";
import React from "react";

import type { LucideIcon } from "lucide-react";

Expand Down
22 changes: 11 additions & 11 deletions src/container.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React, { useState, useEffect, useContext, Fragment } from "react";
import { Alert } from "evergreen-ui";
import { observer } from "mobx-react-lite";
import Layout, { LayoutDummy } from "./layout";
import Preferences from "./views/preferences";
import Documents from "./views/documents";
import Editor from "./views/edit";
import DocumentCreator from "./views/create";
import { SearchProvider } from "./views/documents/SearchProvider";
import React from "react";
import "react-day-picker/dist/style.css";
import { Navigate, Route, Routes } from "react-router-dom";
import {
useJournalsLoader,
JournalsStoreContext,
useJournalsLoader,
} from "./hooks/useJournalsLoader";
import { Alert } from "evergreen-ui";
import { Routes, Route, Navigate } from "react-router-dom";
import "react-day-picker/dist/style.css";
import Layout, { LayoutDummy } from "./layout";
import DocumentCreator from "./views/create";
import Documents from "./views/documents";
import { SearchProvider } from "./views/documents/SearchProvider";
import Editor from "./views/edit";
import Preferences from "./views/preferences";

export default observer(function Container() {
const { journalsStore, loading, loadingErr } = useJournalsLoader();
Expand Down
2 changes: 1 addition & 1 deletion src/error.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Alert, Pane } from "evergreen-ui";
import React from "react";
import { Pane, Alert } from "evergreen-ui";

interface State {
hasError: boolean;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/stores/journals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { observable, computed, toJS } from "mobx";
import { JournalResponse, IClient } from "../useClient";
import { computed, observable, toJS } from "mobx";
import { IClient, JournalResponse } from "../useClient";

export class JournalsStore {
@observable loading: boolean = true;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import React, { useContext } from "react";
import { IClient } from "../preload/client/types";
export { IClient } from "../preload/client/types";

export { JournalResponse } from "../preload/client/journals";
export { SearchResponse } from "../preload/client/documents";
export { JournalResponse } from "../preload/client/journals";

export const ClientContext = React.createContext<any>(
(window as any).chronicles.createClient(),
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useEventListener.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRef, useEffect } from "react";
import { useEffect, useRef } from "react";

// NOTE: Copy pasta from
// https://usehooks.com/useEventListener/
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useJournalsLoader.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { JournalsStore } from "./stores/journals";
import { JournalResponse } from "../preload/client/journals";
import { JournalsStore } from "./stores/journals";
import useClient from "./useClient";

export const JournalsStoreContext = React.createContext<JournalsStore | null>(
Expand Down
6 changes: 3 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import "mobx-react-lite/batchingForReactDom";
import React from "react";
import { createRoot } from "react-dom/client";
import { HashRouter } from "react-router-dom";
import Container from "./container";
import "./index-compiled.css"; // generated by tailwindcss; see package.jsons scripts
import "./typography.css";
import "./prism-code-theme.css";
import { HashRouter } from "react-router-dom";
import "mobx-react-lite/batchingForReactDom";
import "./typography.css";

const root = createRoot(document.getElementById("app")!);

Expand Down
4 changes: 2 additions & 2 deletions src/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PropsWithChildren } from "react";
import { Pane, Tablist, Tab } from "evergreen-ui";
import { Pane } from "evergreen-ui";
import React from "react";
import ErrorBoundary from "./error";

interface Props2 {
Expand Down
2 changes: 1 addition & 1 deletion src/markdown/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it } from "mocha";
import { expect } from "chai";
import { describe, it } from "mocha";
import { stringToSlate } from "./";

describe("Markdown to Slate conversion", function () {
Expand Down
6 changes: 3 additions & 3 deletions src/markdown/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkGfm from "remark-gfm";
import remarkParse from "remark-parse";
import remarkStringify from "remark-stringify";
import remarkUnwrapImages from "remark-unwrap-images";
import { remarkToSlate, slateToRemark } from "./remark-slate-transformer";
import { Node as SNode } from "slate";
import { unified } from "unified";
import { remarkToSlate, slateToRemark } from "./remark-slate-transformer";

export * from "ts-mdast";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import * as slate from "../models/slate";
import * as mdast from "../models/mdast";
import * as slate from "../models/slate";

// One of the main reasons this fork exists:
// NOTE: https://github.com/inokawa/remark-slate-transformer/issues/31
import { prefixUrl, videoExtensions } from "../../../hooks/images";

// NOTE: added, and a good example of what changes I would want to make to this library!
import {
ELEMENT_CODE_BLOCK,
ELEMENT_CODE_LINE,
ELEMENT_LI,
ELEMENT_LIC,
ELEMENT_LINK,
ELEMENT_OL,
ELEMENT_UL,
ELEMENT_CODE_BLOCK,
ELEMENT_CODE_LINE,
ELEMENT_LINK,
} from "@udecode/plate"; // todo: sub-package which has only elements?

import { toSlateLink } from "../../../views/edit/editor/features/note-linking/toMdast";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as unistLib from "unist";
import * as slate from "../models/slate";
import * as mdast from "../models/mdast";
import * as slate from "../models/slate";
import * as SlateNodes from "./mdast-to-slate";

import { Node as SNode } from "slate";
Expand All @@ -10,12 +10,11 @@ import { Node as SNode } from "slate";
import { unPrefixUrl } from "../../../hooks/images";

import {
ELEMENT_CODE_BLOCK,
ELEMENT_LI,
ELEMENT_LIC,
ELEMENT_OL,
ELEMENT_TODO_LI,
ELEMENT_UL,
ELEMENT_CODE_BLOCK,
} from "@udecode/plate";

import {
Expand Down
10 changes: 5 additions & 5 deletions src/preload/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { JournalsClient } from "./journals";
import DB from "better-sqlite3";
import Knex from "knex";
import { DocumentsClient } from "./documents";
import { TagsClient } from "./tags";
import { PreferencesClient } from "./preferences";
import { FilesClient } from "./files";
import { JournalsClient } from "./journals";
import { PreferencesClient } from "./preferences";
import { TagsClient } from "./tags";
import { IClient } from "./types";
import DB from "better-sqlite3";
import Knex from "knex";

import Store from "electron-store";
const settings = new Store({
Expand Down
2 changes: 1 addition & 1 deletion src/preload/client/journals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { uuidv7 } from "uuidv7";
import { Database } from "better-sqlite3";
import { uuidv7 } from "uuidv7";

export interface JournalResponse {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/preload/client/preferences.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Store from "electron-store";
import { ipcRenderer } from "electron";
import Store from "electron-store";

export interface Preferences {
DATABASE_URL: string;
Expand Down
4 changes: 2 additions & 2 deletions src/preload/client/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { IJournalsClient } from "./journals";
import { IDocumentsClient } from "./documents";
import { IPreferencesClient } from "./preferences";
import { IFilesClient } from "./files";
import { IJournalsClient } from "./journals";
import { IPreferencesClient } from "./preferences";
import { ITagsClient } from "./tags";

// This interface was created with these "I" types like this
Expand Down
7 changes: 3 additions & 4 deletions src/preload/files.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import fs, { Stats } from "fs";
import mkdirp from "mkdirp";
import walk = require("klaw");
import path from "path";
import fs from "fs";
const { readFile, writeFile, access, stat } = fs.promises;
import { Stats } from "fs";
import { NotFoundError, ValidationError } from "./errors";
import walk = require("klaw");
const { readFile, writeFile, access, stat } = fs.promises;
const readFileStr = (path: string) => readFile(path, "utf8");

import { IncomingMessage } from "http";
Expand Down
8 changes: 4 additions & 4 deletions src/preload/importer/importChronicles.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Files } from "../files";
import { stringToMdast } from "../../markdown";
import { shouldIndexDay } from "./indexer";
import fs from "fs";
import path from "path";
import { DateTime } from "luxon";
import path from "path";
import { stringToMdast } from "../../markdown";
import { Files } from "../files";
import { shouldIndexDay } from "./indexer";

import { create } from "../client";
const client = create();
Expand Down
6 changes: 3 additions & 3 deletions src/preload/importer/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import path from "path";
import { stringToMdast, mdastToString, Root } from "../../markdown";
import { Database } from "better-sqlite3";
import { Files, PathStatsFile } from "../files";
import { DateTime } from "luxon";
import path from "path";
import { Root, mdastToString, stringToMdast } from "../../markdown";
import { Files, PathStatsFile } from "../files";

export interface IJournal {
// path to root folder
Expand Down
4 changes: 2 additions & 2 deletions src/titlebar/macos.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { PropsWithChildren } from "react";
import { cn } from "@udecode/cn";
import React, { PropsWithChildren } from "react";

interface Props extends PropsWithChildren {
className?: string;
Expand All @@ -10,7 +10,7 @@ export default function Titlebar({ children, className }: Props) {
<div
style={{ WebkitAppRegion: "drag" } as React.CSSProperties}
className={cn(
"bg-secondary border-b border-accent text-accent-foreground border-accent flex justify-between items-center py-3 px-2.5 pl-20 fixed w-full h-12 z-10 shadow",
"fixed z-10 flex h-12 w-full items-center justify-between border-b border-accent bg-secondary px-2.5 py-3 pl-20 text-accent-foreground shadow",
className,
)}
>
Expand Down
8 changes: 4 additions & 4 deletions src/views/create/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { useContext, useEffect, useState } from "react";
import { observer } from "mobx-react-lite";
import { EditLoadingComponent } from "../edit/loading";
import React, { useContext, useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import useClient from "../../hooks/useClient";
import { useIsMounted } from "../../hooks/useIsMounted";
import { JournalsStoreContext } from "../../hooks/useJournalsLoader";
import { useNavigate } from "react-router-dom";
import { SearchStoreContext } from "../documents/SearchStore";
import useClient from "../../hooks/useClient";
import { EditLoadingComponent } from "../edit/loading";

// Creates a new document and immediately navigates to it
function useCreateDocument() {
Expand Down
6 changes: 3 additions & 3 deletions src/views/documents/DocumentItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Badge } from "evergreen-ui";
import React from "react";
import { Pane, Badge } from "evergreen-ui";
import { SearchItem } from "./SearchStore";

export function DocumentItem(props: {
Expand All @@ -13,10 +13,10 @@ export function DocumentItem(props: {
<div
key={doc.id}
onClick={() => edit(doc.id)}
className="cursor-pointer flex hover:underline hover:underline-offset"
className="hover:underline-offset flex cursor-pointer hover:underline"
>
{/* Without mono font, dates won't be a uniform width */}
<div className="font-mono text-sm tracking-tight mr-6 shrink-0">
<div className="mr-6 shrink-0 font-mono text-sm tracking-tight">
{doc.createdAt.slice(0, 10)}
</div>
<div className="font-sans">
Expand Down
Loading

0 comments on commit 1f77968

Please sign in to comment.