Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pvh committed Jul 24, 2024
1 parent cd03dec commit 00fce66
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 26 deletions.
24 changes: 12 additions & 12 deletions packages/automerge-repo/src/DocHandle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,19 +447,19 @@ export class DocHandle<T> extends EventEmitter<DocHandleEvents<T>> {
export type DocHandleOptions<T> =
// NEW DOCUMENTS
| {
/** If we know this is a new document (because we're creating it) this should be set to true. */
isNew: true
/** If we know this is a new document (because we're creating it) this should be set to true. */
isNew: true

/** The initial value of the document. */
initialValue?: T
}
/** The initial value of the document. */
initialValue?: T
}
// EXISTING DOCUMENTS
| {
isNew?: false
isNew?: false

/** The number of milliseconds before we mark this document as unavailable if we don't have it and nobody shares it with us. */
timeoutDelay?: number
}
/** The number of milliseconds before we mark this document as unavailable if we don't have it and nobody shares it with us. */
timeoutDelay?: number
}

// EXTERNAL EVENTS

Expand Down Expand Up @@ -564,9 +564,9 @@ type DocHandleEvent<T> =
| { type: typeof REQUEST }
| { type: typeof DOC_READY }
| {
type: typeof UPDATE
payload: { callback: (doc: A.Doc<T>) => A.Doc<T> }
}
type: typeof UPDATE
payload: { callback: (doc: A.Doc<T>) => A.Doc<T> }
}
| { type: typeof TIMEOUT }
| { type: typeof DELETE }
| { type: typeof DOC_UNAVAILABLE }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ export class CollectionSynchronizer extends Synchronizer {
*/
async receiveMessage(message: DocMessage) {
log(
`onSyncMessage: ${message.senderId}, ${message.documentId}, ${"data" in message ? message.data.byteLength + "bytes" : ""
`onSyncMessage: ${message.senderId}, ${message.documentId}, ${
"data" in message ? message.data.byteLength + "bytes" : ""
}`
)

Expand Down
12 changes: 6 additions & 6 deletions packages/automerge-repo/test/DocHandle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe("DocHandle", () => {
const TEST_ID = parseAutomergeUrl(generateAutomergeUrl()).documentId
const setup = (options?) => {
const handle = new DocHandle<TestDoc>(TEST_ID, options)
handle.update( () => A.init() )
handle.update(() => A.init())
handle.doneLoading()
return handle
}
Expand Down Expand Up @@ -58,7 +58,7 @@ describe("DocHandle", () => {

it("should return the heads when requested", async () => {
const handle = setup()
handle.change( d => d.foo = "bar")
handle.change(d => (d.foo = "bar"))
assert.equal(handle.isReady(), true)

const heads = A.getHeads(handle.docSync())
Expand Down Expand Up @@ -143,7 +143,7 @@ describe("DocHandle", () => {

it("should emit a change message when changes happen", async () => {
const handle = setup()

const p = new Promise<DocHandleChangePayload<TestDoc>>(resolve =>
handle.once("change", d => resolve(d))
)
Expand Down Expand Up @@ -174,7 +174,7 @@ describe("DocHandle", () => {

it("should update the internal doc prior to emitting the change message", async () => {
const handle = setup()

const p = new Promise<void>(resolve =>
handle.once("change", ({ handle, doc }) => {
assert.equal(handle.docSync()?.foo, doc.foo)
Expand All @@ -192,7 +192,7 @@ describe("DocHandle", () => {

it("should emit distinct change messages when consecutive changes happen", async () => {
const handle = setup()

let calls = 0
const p = new Promise(resolve =>
handle.on("change", async ({ doc: d }) => {
Expand Down Expand Up @@ -284,7 +284,7 @@ describe("DocHandle", () => {

it("should not time out if the document is updated in time", async () => {
// set docHandle time out after 5 ms
const handle = setup({timeoutDelay:1})
const handle = setup({ timeoutDelay: 1 })

// simulate requesting from the network
handle.request()
Expand Down
4 changes: 2 additions & 2 deletions packages/automerge-repo/test/DocSynchronizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ describe("DocSynchronizer", () => {
const docId = parseAutomergeUrl(generateAutomergeUrl()).documentId
handle = new DocHandle<TestDoc>(docId)
handle.doneLoading()

docSynchronizer = new DocSynchronizer({
handle: handle as DocHandle<unknown>,
})

return { handle, docSynchronizer }
}

Expand Down
10 changes: 5 additions & 5 deletions packages/automerge-repo/test/Repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ describe("Repo", () => {
let resume = (documentIds?: DocumentId[]) => {
const savesToUnblock = documentIds
? Array.from(blockedSaves).filter(({ path }) =>
documentIds.some(documentId => path.includes(documentId))
)
documentIds.some(documentId => path.includes(documentId))
)
: Array.from(blockedSaves)
savesToUnblock.forEach(({ resolve }) => resolve())
}
Expand Down Expand Up @@ -1029,9 +1029,9 @@ describe("Repo", () => {
const doc =
Math.random() < 0.5
? // heads, create a new doc
repo.create<TestDoc>()
repo.create<TestDoc>()
: // tails, pick a random doc
(getRandomItem(docs) as DocHandle<TestDoc>)
(getRandomItem(docs) as DocHandle<TestDoc>)

// make sure the doc is ready
if (!doc.isReady()) {
Expand Down Expand Up @@ -1414,7 +1414,7 @@ describe("Repo", () => {
})

const warn = console.warn
const NO_OP = () => { }
const NO_OP = () => {}

const disableConsoleWarn = () => {
console.warn = NO_OP
Expand Down

0 comments on commit 00fce66

Please sign in to comment.