From 043a844f0d762490c0bd5bab77829c7eba420516 Mon Sep 17 00:00:00 2001 From: Cody Olsen Date: Mon, 24 Jul 2023 13:20:17 +0200 Subject: [PATCH] chore: prettier formatting --- README.md | 2 +- example/index.html | 2 +- src/browser/getDocuments.ts | 2 +- src/browser/index.ts | 4 ++-- src/groqStore.ts | 4 ++-- src/listen.ts | 16 ++++++++-------- src/node/getDocuments.ts | 2 +- src/patch.ts | 2 +- src/syncingDataset.ts | 4 ++-- src/types.ts | 4 ++-- test/allowList.test.ts | 2 +- test/getDocuments.test.ts | 2 +- test/limits.test.ts | 2 +- test/query.test.ts | 6 +++--- test/subscribe.test.ts | 4 ++-- types/simple-get.d.ts | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index c9c5bd7..dd21af7 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ const sub = store.subscribe( } console.log('Result:', result) - } + }, ) // Later, to close subscription: diff --git a/example/index.html b/example/index.html index ac35119..66a0238 100644 --- a/example/index.html +++ b/example/index.html @@ -1,4 +1,4 @@ - + diff --git a/src/browser/getDocuments.ts b/src/browser/getDocuments.ts index 4fc4b00..61f0433 100644 --- a/src/browser/getDocuments.ts +++ b/src/browser/getDocuments.ts @@ -52,7 +52,7 @@ export const getDocuments: EnvImplementations['getDocuments'] = async function g if (documentLimit && documents.length > documentLimit) { reader.cancel('Reached document limit') throw new Error( - `Error streaming dataset: Reached limit of ${documentLimit} documents. Try using the includeTypes option to reduce the amount of documents, or increase the limit.` + `Error streaming dataset: Reached limit of ${documentLimit} documents. Try using the includeTypes option to reduce the amount of documents, or increase the limit.`, ) } } while (!result.done) diff --git a/src/browser/index.ts b/src/browser/index.ts index 6f1a8d0..addaa17 100644 --- a/src/browser/index.ts +++ b/src/browser/index.ts @@ -12,13 +12,13 @@ export function groqStore(config: Config): GroqStore { if (config.token) { if (!config.EventSource) { throw new Error( - 'When the `token` option is used the `EventSource` option must also be provided.' + 'When the `token` option is used the `EventSource` option must also be provided.', ) } if (config.EventSource === window.EventSource) throw new Error( 'When the `token` option is used the `EventSource` option must also be provided. ' + - 'EventSource cannot be `window.EventSource`, as it does not support passing a token.' + 'EventSource cannot be `window.EventSource`, as it does not support passing a token.', ) } diff --git a/src/groqStore.ts b/src/groqStore.ts index 9e84401..19eb23e 100644 --- a/src/groqStore.ts +++ b/src/groqStore.ts @@ -21,7 +21,7 @@ export function groqStore(config: Config, envImplementations: EnvImplementations documents = docs executeThrottled() }, - envImplementations + envImplementations, ) } @@ -49,7 +49,7 @@ export function groqStore(config: Config, envImplementations: EnvImplementations function subscribe( groqQuery: string, params: Record, - callback: (error: Error | undefined, result?: R) => void + callback: (error: Error | undefined, result?: R) => void, ): Subscription { if (!config.listen) { throw new Error('Cannot use `subscribe()` without `listen: true`') diff --git a/src/listen.ts b/src/listen.ts index 4664a6c..c5dc928 100644 --- a/src/listen.ts +++ b/src/listen.ts @@ -17,20 +17,20 @@ declare module 'event-source-polyfill' { } const isNativeBrowserEventSource = ( - eventSource: EventSourceInstance + eventSource: EventSourceInstance, ): eventSource is InstanceType => typeof window !== 'undefined' && eventSource.addEventListener === window.EventSource.prototype.addEventListener const isPolyfillEventSource = ( - eventSource: EventSourceInstance + eventSource: EventSourceInstance, ): eventSource is InstanceType => !isNativeBrowserEventSource(eventSource) const addEventSourceListener = ( eventSource: EventSourceInstance, type: keyof SharedEventSourceEventMap, - listener: EventListener + listener: EventListener, ): void => { if (isPolyfillEventSource(eventSource)) { // Polyfilled event source does not accept option parameter @@ -75,7 +75,7 @@ export function listen( open: () => void error: (err: Error) => void next: (event: MutationEvent) => void - } + }, ): Subscription { const {projectId, dataset, token, includeTypes, requestTagPrefix} = config const headers = token ? {Authorization: `Bearer ${token}`} : undefined @@ -91,7 +91,7 @@ export function listen( params: {includeTypes}, options, } - : {query: '*', options} + : {query: '*', options}, ) const url = `https://${projectId}.api.sanity.io/v1/data/listen/${dataset}${searchParams}` const es = new EventSourceImpl(url, {withCredentials: true, headers}) @@ -112,7 +112,7 @@ export function listen( } handlers.error( - new Error(data.message || data.error || `Listener returned HTTP ${data.statusCode}`) + new Error(data.message || data.error || `Listener returned HTTP ${data.statusCode}`), ) }) @@ -122,8 +122,8 @@ export function listen( const errorMessage = isErrorLike(err) ? ` (${err.message})` : '' handlers.error( new Error( - `Error establishing listener - check that the project ID and dataset are correct${hintSuffix}${errorMessage}` - ) + `Error establishing listener - check that the project ID and dataset are correct${hintSuffix}${errorMessage}`, + ), ) }) diff --git a/src/node/getDocuments.ts b/src/node/getDocuments.ts index 2671d6f..e18f718 100644 --- a/src/node/getDocuments.ts +++ b/src/node/getDocuments.ts @@ -64,7 +64,7 @@ export const getDocuments: EnvImplementations['getDocuments'] = function getDocu if (documentLimit && documents.length > documentLimit) { reject( - new Error(`Error streaming dataset: Reached limit of ${documentLimit} documents`) + new Error(`Error streaming dataset: Reached limit of ${documentLimit} documents`), ) response.destroy() } diff --git a/src/patch.ts b/src/patch.ts index a676420..87f49a5 100644 --- a/src/patch.ts +++ b/src/patch.ts @@ -3,7 +3,7 @@ import {applyPatch} from 'mendoza' export function applyPatchWithoutRev( doc: SanityDocument | null, - patch: unknown[] + patch: unknown[], ): SanityDocument | null { const patchDoc = {...doc} as Omit delete patchDoc._rev diff --git a/src/syncingDataset.ts b/src/syncingDataset.ts index 421ff48..a144896 100644 --- a/src/syncingDataset.ts +++ b/src/syncingDataset.ts @@ -14,7 +14,7 @@ function noop() { export function getSyncingDataset( config: Config, onNotifyUpdate: (docs: SanityDocument[]) => void, - {getDocuments, EventSource}: EnvImplementations + {getDocuments, EventSource}: EnvImplementations, ): Subscription & {loaded: Promise} { const { projectId, @@ -154,7 +154,7 @@ export function getSyncingDataset( function applyBufferedMutations( documents: SanityDocument[], - mutations: MutationEvent[] + mutations: MutationEvent[], ): SanityDocument[] { // Group by document ID const groups = new Map() diff --git a/src/types.ts b/src/types.ts index 1bcf8df..b08567c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -37,7 +37,7 @@ export interface EnvImplementations { options: Pick< Config, 'projectId' | 'dataset' | 'token' | 'documentLimit' | 'includeTypes' | 'requestTagPrefix' - > + >, ) => Promise } @@ -91,7 +91,7 @@ export interface GroqStore { subscribe: ( groqQuery: string, params: Record, - callback: (err: Error | undefined, result?: R) => void + callback: (err: Error | undefined, result?: R) => void, ) => Subscription close: () => Promise } diff --git a/test/allowList.test.ts b/test/allowList.test.ts index e76706a..bc97f7b 100644 --- a/test/allowList.test.ts +++ b/test/allowList.test.ts @@ -21,5 +21,5 @@ describe( expect(await store.query(groq`count(*[_type == "product"])`)).toEqual(11) }) }, - {timeout: 30000} + {timeout: 30000}, ) diff --git a/test/getDocuments.test.ts b/test/getDocuments.test.ts index 58bca38..06105f5 100644 --- a/test/getDocuments.test.ts +++ b/test/getDocuments.test.ts @@ -22,7 +22,7 @@ describe('getDocuments', () => { expect(getDocuments).toBeCalledWith( expect.objectContaining({ token: 'my-token', - }) + }), ) }) }) diff --git a/test/limits.test.ts b/test/limits.test.ts index 49387cb..32750bc 100644 --- a/test/limits.test.ts +++ b/test/limits.test.ts @@ -31,5 +31,5 @@ describe( } }) }, - {timeout: 30000} + {timeout: 30000}, ) diff --git a/test/query.test.ts b/test/query.test.ts index e75f481..cb9ca29 100644 --- a/test/query.test.ts +++ b/test/query.test.ts @@ -30,10 +30,10 @@ describe( ]) expect(await store.query(groq`*[_type == "vendor"][].title | order(@ asc) [3]`)).toEqual( - 'Freia' + 'Freia', ) expect(new Set(await store.query(groq`array::unique(*._type)`))).toEqual( - new Set(['category', 'product', 'sanity.imageAsset', 'vendor']) + new Set(['category', 'product', 'sanity.imageAsset', 'vendor']), ) }) @@ -57,7 +57,7 @@ describe( ]) }) }, - {timeout: 30000} + {timeout: 30000}, ) describe('query without overlayDrafts', () => { diff --git a/test/subscribe.test.ts b/test/subscribe.test.ts index 45e1901..fece69c 100644 --- a/test/subscribe.test.ts +++ b/test/subscribe.test.ts @@ -192,7 +192,7 @@ describe.runIf(config.token)( default: throw new Error(`Encountered more updates than expected (${numUpdates})`) } - } + }, ) function runAssertions() { @@ -203,5 +203,5 @@ describe.runIf(config.token)( return waiter }) }, - {timeout: 15000} + {timeout: 15000}, ) diff --git a/types/simple-get.d.ts b/types/simple-get.d.ts index 5f1062a..54133f4 100644 --- a/types/simple-get.d.ts +++ b/types/simple-get.d.ts @@ -11,7 +11,7 @@ declare module 'simple-get' { function simpleGet( options: Options, - callback: (err: Error | undefined, res: IncomingMessage) => void + callback: (err: Error | undefined, res: IncomingMessage) => void, ): void export = simpleGet