diff --git a/package.json b/package.json index 3b57a4291..f1380120e 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "size": "node scripts/file-size ./dist/bundles/meilisearch.esm.min.js ./dist/bundles/meilisearch.umd.min.js", "style": "yarn fmt && yarn lint", "style:fix": "yarn fmt:fix && yarn lint:fix", - "fmt": "prettier -c ./**/*.{js,ts,tsx}", - "fmt:fix": "prettier -w ./**/*.{js,ts,tsx}", + "fmt": "prettier -c ./**/*.{js,ts}", + "fmt:fix": "prettier -w ./**/*.{js,ts}", "lint": "eslint --ext .js,.ts,.tsx .", "lint:fix": "eslint --ext .js,.ts,.tsx --fix .", "typingsheader": "node scripts/build.js" diff --git a/scripts/build.js b/scripts/build.js index ae50a4b8e..2f9f78948 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,6 +1,4 @@ -/** - * This file only purpose is to execute any build related tasks - */ +/** This file only purpose is to execute any build related tasks */ const { resolve, normalize } = require('path') const { readFileSync, writeFileSync } = require('fs') @@ -28,7 +26,6 @@ function writeDtsHeader() { } /** - * * @param {string} pkgName * @param {string} version * @param {string} author @@ -49,7 +46,6 @@ function getDtsHeader(pkgName, version, author, repoUrl, tsVersion) { } /** - * * @param {string} path * @param {string | Blob} data */ diff --git a/scripts/file-size.js b/scripts/file-size.js index 31329458c..219e1b764 100644 --- a/scripts/file-size.js +++ b/scripts/file-size.js @@ -32,7 +32,6 @@ async function main() { } /** - * * @param {string} pkgName * @param {string[]} filesOutput */ @@ -49,7 +48,6 @@ function getFormatedOutput(pkgName, filesOutput) { } /** - * * @param {number} size * @param {string} filename * @param {'br' | 'gz'} type @@ -66,10 +64,9 @@ function formatSize(size, filename, type, raw) { } /** - * * @param {string} code * @param {string} filename - * @param {boolean} [raw=false] + * @param {boolean} [raw=false] Default is `false` */ async function getSizeInfo(code, filename, raw = false) { const isRaw = raw || code.length < 5000 diff --git a/src/http-requests.ts b/src/http-requests.ts index 25fd97852..df91d38e1 100644 --- a/src/http-requests.ts +++ b/src/http-requests.ts @@ -40,10 +40,13 @@ function constructHostURL(host: string): string { function cloneAndParseHeaders(headers: HeadersInit): Record { if (Array.isArray(headers)) { - return headers.reduce((acc, headerPair) => { - acc[headerPair[0]] = headerPair[1] - return acc - }, {} as Record) + return headers.reduce( + (acc, headerPair) => { + acc[headerPair[0]] = headerPair[1] + return acc + }, + {} as Record + ) } else if ('has' in headers) { const clonedHeaders: Record = {} ;(headers as Headers).forEach((value, key) => (clonedHeaders[key] = value)) diff --git a/src/indexes.ts b/src/indexes.ts index 493655b64..c26cf97dc 100644 --- a/src/indexes.ts +++ b/src/indexes.ts @@ -92,7 +92,7 @@ class Index = Record> { */ async search< D extends Record = T, - S extends SearchParams = SearchParams + S extends SearchParams = SearchParams, >( query?: string | null, options?: S, @@ -118,7 +118,7 @@ class Index = Record> { */ async searchGet< D extends Record = T, - S extends SearchParams = SearchParams + S extends SearchParams = SearchParams, >( query?: string | null, options?: S, diff --git a/src/task.ts b/src/task.ts index 0d9834484..eda9a0c89 100644 --- a/src/task.ts +++ b/src/task.ts @@ -97,10 +97,12 @@ class TaskClient { while (Date.now() - startingTime < timeOutMs) { const response = await this.getTask(taskUid) if ( - !([ - TaskStatus.TASK_ENQUEUED, - TaskStatus.TASK_PROCESSING, - ] as readonly string[]).includes(response.status) + !( + [ + TaskStatus.TASK_ENQUEUED, + TaskStatus.TASK_PROCESSING, + ] as readonly string[] + ).includes(response.status) ) return response await sleep(intervalMs) diff --git a/src/types/types.ts b/src/types/types.ts index 49d044579..1e0e5fc03 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -65,7 +65,8 @@ export const MatchingStrategies = { LAST: 'last', } as const -export type MatchingStrategies = typeof MatchingStrategies[keyof typeof MatchingStrategies] +export type MatchingStrategies = + (typeof MatchingStrategies)[keyof typeof MatchingStrategies] export type Filter = string | Array @@ -207,7 +208,7 @@ export type FacetStats = Record export type SearchResponse< T = Record, - S extends SearchParams | undefined = undefined + S extends SearchParams | undefined = undefined, > = { hits: Hits processingTimeMs: number @@ -218,8 +219,8 @@ export type SearchResponse< } & (undefined extends S ? Partial : true extends IsFinitePagination> - ? FinitePagination - : InfinitePagination) + ? FinitePagination + : InfinitePagination) type FinitePagination = { totalHits: number @@ -241,8 +242,8 @@ type IsFinitePagination = Or< type Or = true extends A ? true : true extends B - ? true - : false + ? true + : false type HasHitsPerPage = undefined extends S['hitsPerPage'] ? false @@ -403,7 +404,7 @@ export const TaskStatus = { TASK_CANCELED: 'canceled', } as const -export type TaskStatus = typeof TaskStatus[keyof typeof TaskStatus] +export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus] export const TaskTypes = { DOCUMENTS_ADDITION_OR_UPDATE: 'documentAdditionOrUpdate', @@ -419,7 +420,7 @@ export const TaskTypes = { TASK_DELETION: 'taskDeletion', } as const -export type TaskTypes = typeof TaskTypes[keyof typeof TaskTypes] +export type TaskTypes = (typeof TaskTypes)[keyof typeof TaskTypes] export type TasksQuery = { indexUids?: string[] @@ -972,7 +973,8 @@ export const ErrorStatusCode = { INVALID_FACET_SEARCH_FACET_QUERY: 'invalid_facet_search_facet_query', } -export type ErrorStatusCode = typeof ErrorStatusCode[keyof typeof ErrorStatusCode] +export type ErrorStatusCode = + (typeof ErrorStatusCode)[keyof typeof ErrorStatusCode] export type TokenIndexRules = { [field: string]: any diff --git a/src/utils.ts b/src/utils.ts index d12bfe7e3..9daecda67 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,10 +1,13 @@ /** Removes undefined entries from object */ function removeUndefinedFromObject(obj: Record): object { - return Object.entries(obj).reduce((acc, curEntry) => { - const [key, val] = curEntry - if (val !== undefined) acc[key] = val - return acc - }, {} as Record) + return Object.entries(obj).reduce( + (acc, curEntry) => { + const [key, val] = curEntry + if (val !== undefined) acc[key] = val + return acc + }, + {} as Record + ) } async function sleep(ms: number): Promise { @@ -26,7 +29,8 @@ function addTrailingSlash(url: string): string { } function validateUuid4(uuid: string): boolean { - const regexExp = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi + const regexExp = + /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/gi return regexExp.test(uuid) } diff --git a/tests/utils/meilisearch-test-utils.ts b/tests/utils/meilisearch-test-utils.ts index 8e26b0b01..bbe8b6aed 100644 --- a/tests/utils/meilisearch-test-utils.ts +++ b/tests/utils/meilisearch-test-utils.ts @@ -30,14 +30,16 @@ async function getKey(permission: string): Promise { const { results: keys } = await masterClient.getKeys() if (permission === 'Search') { - const key = keys.find((key: any) => key.name === 'Default Search API Key') - ?.key + const key = keys.find( + (key: any) => key.name === 'Default Search API Key' + )?.key return key || '' } if (permission === 'Admin') { - const key = keys.find((key: any) => key.name === 'Default Admin API Key') - ?.key + const key = keys.find( + (key: any) => key.name === 'Default Admin API Key' + )?.key return key || '' } return MASTER_KEY