Skip to content

Commit 4493c94

Browse files
committed
switching over to biome from eslint, also cleaned up some markdown
1 parent ba762ce commit 4493c94

34 files changed

+2574
-1694
lines changed

.vscode/settings.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,23 @@
44
"lldb.consoleMode": "commands",
55
// this allows rust-analyzer to compile sqlsync_reducer::host_ffi
66
"rust-analyzer.cargo.features": ["host"],
7-
"rust-analyzer.showUnlinkedFileNotification": false
7+
"rust-analyzer.showUnlinkedFileNotification": false,
8+
"[typescriptreact][typescript][javascript][javascriptreact]": {
9+
"editor.defaultFormatter": "biomejs.biome",
10+
"editor.formatOnSave": false,
11+
"editor.codeActionsOnSave": {
12+
"source.fixAll.eslint": "never",
13+
"quickfix.biome": "always",
14+
"source.addMissingImports": "always",
15+
"source.formatDocument": "always",
16+
"source.organizeImports": "always"
17+
},
18+
"editor.tabSize": 2,
19+
"editor.insertSpaces": true
20+
},
21+
"[json][jsonc]": {
22+
"editor.defaultFormatter": "biomejs.biome",
23+
"editor.tabSize": 2,
24+
"editor.insertSpaces": true
25+
}
826
}

GUIDE.md

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
11
# The SQLSync Guide
22

3-
<!-- prettier-ignore-start -->
43
> [!IMPORTANT]
5-
> SQLSync is in active development and thus is changing quickly.
6-
> Currently, do not use it in a production application as there is no backwards
7-
> compatibility or stability promise.
8-
<!-- prettier-ignore-end -->
4+
> SQLSync is in active development and thus is changing quickly. Currently, do not use it in a production application as there is no backwards compatibility or stability promise.
95
10-
SQLSync is distributed as a Javascript package as well as a Rust Crate.
11-
Currently both are required to use SQLSync. Also, React is the only supported
12-
framework at the moment.
6+
SQLSync is distributed as a JavaScript package as well as a Rust Crate. Currently, both are required to use SQLSync. Also, React is the only supported framework at the moment.
137

14-
If you want to jump ahead to a working demo, check out the finished product at:
15-
https://github.com/orbitinghail/sqlsync-demo-guestbook
8+
If you want to jump ahead to a working demo, check out the finished product at: https://github.com/orbitinghail/sqlsync-demo-guestbook
169

1710
## Step 1: Creating the Reducer
1811

19-
SQLSync requires that all mutations are handled by a piece of code called "The
20-
Reducer". Currently this code has to be written in Rust, however we have plans
21-
to make it possible to write Reducers using JS or other languages. The fastest
22-
way to create a reducer is to initialize a new Rust project like so:
12+
SQLSync requires that all mutations are handled by a piece of code called "The Reducer". Currently, this code has to be written in Rust, however we have plans to make it possible to write Reducers using JS or other languages. The fastest way to create a reducer is to initialize a new Rust project like so:
2313

2414
1. Make sure you have Rust installed; if not install using [rustup].
2515
2. Install support for the `wasm32-unknown-unknown` target:
@@ -112,17 +102,11 @@ cargo build --target wasm32-unknown-unknown --release
112102
npm install @orbitinghail/sqlsync-react @orbitinghail/sqlsync-worker
113103
```
114104

115-
The following examples will be using Typescript to make everything a bit more
116-
precise. If you are not using Typescript you can still use SQLSync, just skip
117-
the type descriptions and annotations.
105+
The following examples will be using Typescript to make everything a bit more precise. If you are not using Typescript you can still use SQLSync, just skip the type descriptions and annotations.
118106

119-
Also, make sure your JS bundling tool supports importing assets from the
120-
filesystem, as will need that to easily get access to the Reducer we compiled
121-
earlier in this guide. If in doubt, [Vite] is highly recommended.
107+
Also, make sure your JS bundling tool supports importing assets from the file system, as will need that to easily get access to the Reducer we compiled earlier in this guide. If in doubt, [Vite] is highly recommended.
122108

123-
Create a file which will contain type information for your Mutations, the
124-
reducer URL, and export some useful React hooks for your app to consume. It
125-
should look something like this:
109+
Create a file which will contain type information for your Mutations, the reducer URL, and export some useful React hooks for your app to consume. It should look something like this:
126110

127111
```typescript
128112
import {
@@ -160,12 +144,9 @@ export const { useMutate, useQuery, useSetConnectionEnabled } =
160144

161145
## Step 3: Hooking it up to your app
162146

163-
Using the hooks exported from the file in
164-
[Step 2](#step-2-install-and-configure-the-react-library) we can easily hook
165-
SQLSync up to our application.
147+
Using the hooks exported from the file in [Step 2](#step-2-install-and-configure-the-react-library) we can easily hook SQLSync up to our application.
166148

167-
Here is a complete example of a very trivial guestbook application which uses
168-
the reducer we created above. If
149+
Here is a complete example of a very trivial guestbook application which uses the reducer we created above.
169150

170151
```tsx
171152
import React, { FormEvent, useEffect } from "react";
@@ -268,8 +249,7 @@ export function App() {
268249

269250
## Step 4: Connect to the coordinator (COMING SOON)
270251

271-
This step still requires using SQLSync from source. For now you'll have to
272-
follow the directions in the [Contribution Guide] to setup a Local Coordinator.
252+
This step still requires using SQLSync from source. For now, you'll have to follow the directions in the [Contribution Guide] to set up a Local Coordinator.
273253

274254
[rustup]: https://rustup.rs/
275255
[Vite]: https://vitejs.dev/

README.md

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,23 @@
33
[![github actions](https://github.com/orbitinghail/sqlsync/actions/workflows/actions.yaml/badge.svg?branch=main)](https://github.com/orbitinghail/sqlsync/actions?query=branch%3Amain)
44
[![Join the SQLSync Community](https://discordapp.com/api/guilds/1149205110262595634/widget.png?style=shield)][discord]
55

6-
**SQLSync is a collaborative offline-first wrapper around SQLite** designed to
7-
synchronize web application state between users, devices, and the edge.
6+
**SQLSync is a collaborative offline-first wrapper around SQLite** designed to synchronize web application state between users, devices, and the edge.
87

98
**Example use cases**
109

11-
- A web app with a structured file oriented data model like Figma. Each file
12-
could be a SQLSync database, enabling real-time local first collaboration and
13-
presense
14-
- An embedded systems deployment running SQLSync on the edge with high tolerance
15-
for unreliable network conditions
10+
- A web app with a structured file oriented data model like Figma. Each file could be a SQLSync database, enabling real-time local first collaboration and presence
11+
- Running SQLSync on the edge with high tolerance for unreliable network conditions
1612
- Enabling optimistic mutations on SQLite read replicas
1713

1814
**SQLSync Demo**
1915

20-
The best way to get a feel for how SQLSync behaves is to play with the
21-
[Todo list demo](https://sqlsync-todo.pages.dev/). Clicking
22-
[this link](https://sqlsync-todo.pages.dev/) will create a unique todo list and
23-
redirect you to it's unique URL. You can then share that URL with friends or
24-
open it on multiple devices (or browsers) to see the power of offline-first
25-
collaborative SQLite.
16+
The best way to get a feel for how SQLSync behaves is to play with the [Todo list demo][todo-demo]. Clicking [this link][todo-demo] will create a unique to-do list and redirect you to its unique URL. You can then share that URL with friends or open it on multiple devices (or browsers) to see the power of offline-first collaborative SQLite.
2617

27-
You can also learn more about SQLSync and it's goals by watching Carl's WasmCon
28-
2023 talk.
29-
[The recording can be found here](https://youtu.be/oLYda9jmNpk?si=7BBBdLxEj9ZQ4OvS).
18+
[todo-demo]: https://sqlsync-todo.pages.dev/
19+
20+
You can also learn more about SQLSync and it's goals by watching Carl's WasmCon 2023 talk. [The recording can be found here][wasmcon-talk].
21+
22+
[wasmcon-talk]: https://youtu.be/oLYda9jmNpk?si=7BBBdLxEj9ZQ4OvS
3023

3124
**Features**
3225

@@ -38,21 +31,15 @@ You can also learn more about SQLSync and it's goals by watching Carl's WasmCon
3831
- Cross-tab sync
3932
- React library
4033

41-
If you are interested in using or contributing to SQLSync, please [join the
42-
Discord community][discord] and let us know what you want to build. We are
43-
excited to collaborate with you!
34+
If you are interested in using or contributing to SQLSync, please [join the Discord community][discord] and let us know what you want to build. We are excited to collaborate with you!
4435

4536
## Installation & Getting started
4637

47-
Please refer to [the guide](./GUIDE.md) to learn how to add SQLSync to your
48-
application.
38+
Please refer to [the guide](./GUIDE.md) to learn how to add SQLSync to your application.
4939

5040
## Community & Contributing
5141

52-
If you are interested in contributing to SQLSync, please [join the Discord
53-
community][discord] and let us know what you want to build. All contributions
54-
will be held to a high standard, and are more likely to be accepted if they are
55-
tied to an existing task and agreed upon specification.
42+
If you are interested in contributing to SQLSync, please [join the Discord community][discord] and let us know what you want to build. All contributions will be held to a high standard, and are more likely to be accepted if they are tied to an existing task and agreed upon specification.
5643

5744
[![Join the SQLSync Community](https://discordapp.com/api/guilds/1149205110262595634/widget.png?style=banner2)][discord]
5845

biome.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.4.0/schema.json",
3+
"organizeImports": {
4+
"enabled": false
5+
},
6+
"linter": {
7+
"enabled": true,
8+
"rules": {
9+
"recommended": true,
10+
"style": {
11+
"useSingleVarDeclarator": "off"
12+
}
13+
}
14+
},
15+
"formatter": {
16+
"enabled": true,
17+
"formatWithErrors": false,
18+
"indentStyle": "space",
19+
"indentWidth": 2,
20+
"lineWidth": 100
21+
},
22+
"json": {
23+
"parser": {
24+
"allowComments": true
25+
}
26+
},
27+
"files": {
28+
"ignore": [
29+
"lib/sqlsync-worker/sqlsync-wasm",
30+
"lib/sqlsync-worker/dist",
31+
"lib/sqlsync-react/dist",
32+
"demo/cloudflare-backend/build",
33+
"demo/cloudflare-backend/dist",
34+
"demo/frontend/dist",
35+
"target"
36+
]
37+
}
38+
}

demo/cloudflare-backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
"devDependencies": {
1111
"wrangler": "^3.14.0"
1212
}
13-
}
13+
}

demo/frontend/.eslintrc.cjs

Lines changed: 0 additions & 27 deletions
This file was deleted.

demo/frontend/package.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"dev": "vite",
88
"build": "tsc && vite build",
9-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
9+
"lint": "biome check .",
1010
"preview": "vite preview",
1111
"release": "pnpm build && wrangler pages deploy dist"
1212
},
@@ -31,14 +31,8 @@
3131
"@types/react-dom": "^18.2.14",
3232
"@types/uuid": "^9.0.6",
3333
"@types/wicg-file-system-access": "^2020.9.8",
34-
"@typescript-eslint/eslint-plugin": "^6.9.0",
35-
"@typescript-eslint/parser": "^6.9.0",
3634
"@vitejs/plugin-react": "^4.1.0",
3735
"autoprefixer": "^10.4.16",
38-
"eslint": "^8.52.0",
39-
"eslint-plugin-react": "^7.33.2",
40-
"eslint-plugin-react-hooks": "^4.6.0",
41-
"eslint-plugin-react-refresh": "^0.4.3",
4236
"postcss": "^8.4.31",
4337
"postcss-preset-mantine": "^1.9.0",
4438
"typescript": "^5.2.2",

demo/frontend/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { Container, Stack } from "@mantine/core";
22
import { JournalId } from "@orbitinghail/sqlsync-worker";
33
import { useEffect } from "react";
4-
import { useMutate } from "./doctype";
54
import { Header } from "./components/Header";
6-
import { TaskList } from "./components/TaskList";
75
import { QueryViewer } from "./components/QueryViewer";
6+
import { TaskList } from "./components/TaskList";
7+
import { useMutate } from "./doctype";
88

99
export const App = ({ docId }: { docId: JournalId }) => {
1010
const mutate = useMutate(docId);

demo/frontend/src/components/ConnectionStatus.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { rem, Button } from "@mantine/core";
1+
import { Button, rem } from "@mantine/core";
22
import { useConnectionStatus } from "@orbitinghail/sqlsync-react";
33
import { JournalId } from "@orbitinghail/sqlsync-worker";
4+
import { IconWifi, IconWifiOff } from "@tabler/icons-react";
45
import { useCallback } from "react";
56
import { useSetConnectionEnabled } from "../doctype";
6-
import { IconWifi, IconWifiOff } from "@tabler/icons-react";
77

88
export const ConnectionStatus = ({ docId }: { docId: JournalId }) => {
99
const status = useConnectionStatus();

demo/frontend/src/components/QueryViewer.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ export const QueryViewerInner = ({ docId }: Props) => {
2222
if (typeof value === "bigint") {
2323
return value.toString();
2424
}
25-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
2625
return value;
2726
},
28-
2
27+
2,
2928
);
3029
}, [result.rows]);
3130

demo/frontend/src/components/TaskForm.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Button, Flex, TextInput } from "@mantine/core";
22
import { useForm } from "@mantine/form";
33
import { useCallback } from "react";
4-
import { Mutation } from "../doctype";
54
import { v4 as uuidv4 } from "uuid";
5+
import { Mutation } from "../doctype";
66

77
interface TaskFormProps {
88
mutate: (m: Mutation) => Promise<void>;
@@ -30,8 +30,8 @@ export const TaskForm = ({ mutate }: TaskFormProps) => {
3030
console.error("Failed to create task", err);
3131
});
3232
},
33-
[mutate, form]
34-
)
33+
[mutate, form],
34+
),
3535
);
3636

3737
return (

demo/frontend/src/components/TaskItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Text, ActionIcon, Checkbox, Flex } from "@mantine/core";
1+
import { ActionIcon, Checkbox, Flex, Text } from "@mantine/core";
2+
import { IconX } from "@tabler/icons-react";
23
import { useCallback } from "react";
34
import { Mutation } from "../doctype";
4-
import { IconX } from "@tabler/icons-react";
55

66
export interface Task {
77
id: string;

demo/frontend/src/components/TaskList.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Center, Flex, Paper, Stack, Title } from "@mantine/core";
22
import { sql } from "@orbitinghail/sqlsync-react";
33
import { JournalId } from "@orbitinghail/sqlsync-worker";
4-
import { ConnectionStatus } from "./ConnectionStatus";
54
import { useMutate, useQuery } from "../doctype";
6-
import { Task, TaskItem } from "./TaskItem";
5+
import { ConnectionStatus } from "./ConnectionStatus";
76
import { TaskForm } from "./TaskForm";
7+
import { Task, TaskItem } from "./TaskItem";
88

99
export const TaskList = ({ docId }: { docId: JournalId }) => {
1010
const { rows: tasks } = useQuery<Task>(
1111
docId,
12-
sql`select id, description, completed from tasks order by description`
12+
sql`select id, description, completed from tasks order by description`,
1313
);
1414
const mutate = useMutate(docId);
1515

demo/frontend/src/doctype.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { DocType, createDocHooks, serializeMutationAsJSON } from "@orbitinghail/
22

33
const REDUCER_URL = new URL(
44
"../../../target/wasm32-unknown-unknown/release/demo_reducer.wasm",
5-
import.meta.url
5+
import.meta.url,
66
);
77

88
// matches the Mutation type in demo/demo-reducer

0 commit comments

Comments
 (0)