Skip to content

Commit 406b689

Browse files
authored
Merge pull request #1638 from meilisearch/fix-style
Fix code style after configuration changes
2 parents 39a874f + 36c3d0b commit 406b689

File tree

9 files changed

+46
-40
lines changed

9 files changed

+46
-40
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"size": "node scripts/file-size ./dist/bundles/meilisearch.esm.min.js ./dist/bundles/meilisearch.umd.min.js",
5151
"style": "yarn fmt && yarn lint",
5252
"style:fix": "yarn fmt:fix && yarn lint:fix",
53-
"fmt": "prettier -c ./**/*.{js,ts,tsx}",
54-
"fmt:fix": "prettier -w ./**/*.{js,ts,tsx}",
53+
"fmt": "prettier -c ./**/*.{js,ts}",
54+
"fmt:fix": "prettier -w ./**/*.{js,ts}",
5555
"lint": "eslint --ext .js,.ts,.tsx .",
5656
"lint:fix": "eslint --ext .js,.ts,.tsx --fix .",
5757
"typingsheader": "node scripts/build.js"

scripts/build.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
/**
2-
* This file only purpose is to execute any build related tasks
3-
*/
1+
/** This file only purpose is to execute any build related tasks */
42

53
const { resolve, normalize } = require('path')
64
const { readFileSync, writeFileSync } = require('fs')
@@ -28,7 +26,6 @@ function writeDtsHeader() {
2826
}
2927

3028
/**
31-
*
3229
* @param {string} pkgName
3330
* @param {string} version
3431
* @param {string} author
@@ -49,7 +46,6 @@ function getDtsHeader(pkgName, version, author, repoUrl, tsVersion) {
4946
}
5047

5148
/**
52-
*
5349
* @param {string} path
5450
* @param {string | Blob} data
5551
*/

scripts/file-size.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ async function main() {
3232
}
3333

3434
/**
35-
*
3635
* @param {string} pkgName
3736
* @param {string[]} filesOutput
3837
*/
@@ -49,7 +48,6 @@ function getFormatedOutput(pkgName, filesOutput) {
4948
}
5049

5150
/**
52-
*
5351
* @param {number} size
5452
* @param {string} filename
5553
* @param {'br' | 'gz'} type
@@ -66,10 +64,9 @@ function formatSize(size, filename, type, raw) {
6664
}
6765

6866
/**
69-
*
7067
* @param {string} code
7168
* @param {string} filename
72-
* @param {boolean} [raw=false]
69+
* @param {boolean} [raw=false] Default is `false`
7370
*/
7471
async function getSizeInfo(code, filename, raw = false) {
7572
const isRaw = raw || code.length < 5000

src/http-requests.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@ function constructHostURL(host: string): string {
4040

4141
function cloneAndParseHeaders(headers: HeadersInit): Record<string, string> {
4242
if (Array.isArray(headers)) {
43-
return headers.reduce((acc, headerPair) => {
44-
acc[headerPair[0]] = headerPair[1]
45-
return acc
46-
}, {} as Record<string, string>)
43+
return headers.reduce(
44+
(acc, headerPair) => {
45+
acc[headerPair[0]] = headerPair[1]
46+
return acc
47+
},
48+
{} as Record<string, string>
49+
)
4750
} else if ('has' in headers) {
4851
const clonedHeaders: Record<string, string> = {}
4952
;(headers as Headers).forEach((value, key) => (clonedHeaders[key] = value))

src/indexes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class Index<T extends Record<string, any> = Record<string, any>> {
9292
*/
9393
async search<
9494
D extends Record<string, any> = T,
95-
S extends SearchParams = SearchParams
95+
S extends SearchParams = SearchParams,
9696
>(
9797
query?: string | null,
9898
options?: S,
@@ -118,7 +118,7 @@ class Index<T extends Record<string, any> = Record<string, any>> {
118118
*/
119119
async searchGet<
120120
D extends Record<string, any> = T,
121-
S extends SearchParams = SearchParams
121+
S extends SearchParams = SearchParams,
122122
>(
123123
query?: string | null,
124124
options?: S,

src/task.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ class TaskClient {
9797
while (Date.now() - startingTime < timeOutMs) {
9898
const response = await this.getTask(taskUid)
9999
if (
100-
!([
101-
TaskStatus.TASK_ENQUEUED,
102-
TaskStatus.TASK_PROCESSING,
103-
] as readonly string[]).includes(response.status)
100+
!(
101+
[
102+
TaskStatus.TASK_ENQUEUED,
103+
TaskStatus.TASK_PROCESSING,
104+
] as readonly string[]
105+
).includes(response.status)
104106
)
105107
return response
106108
await sleep(intervalMs)

src/types/types.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export const MatchingStrategies = {
6565
LAST: 'last',
6666
} as const
6767

68-
export type MatchingStrategies = typeof MatchingStrategies[keyof typeof MatchingStrategies]
68+
export type MatchingStrategies =
69+
(typeof MatchingStrategies)[keyof typeof MatchingStrategies]
6970

7071
export type Filter = string | Array<string | string[]>
7172

@@ -207,7 +208,7 @@ export type FacetStats = Record<string, FacetStat>
207208

208209
export type SearchResponse<
209210
T = Record<string, any>,
210-
S extends SearchParams | undefined = undefined
211+
S extends SearchParams | undefined = undefined,
211212
> = {
212213
hits: Hits<T>
213214
processingTimeMs: number
@@ -218,8 +219,8 @@ export type SearchResponse<
218219
} & (undefined extends S
219220
? Partial<FinitePagination & InfinitePagination>
220221
: true extends IsFinitePagination<NonNullable<S>>
221-
? FinitePagination
222-
: InfinitePagination)
222+
? FinitePagination
223+
: InfinitePagination)
223224

224225
type FinitePagination = {
225226
totalHits: number
@@ -241,8 +242,8 @@ type IsFinitePagination<S extends SearchParams> = Or<
241242
type Or<A extends boolean, B extends boolean> = true extends A
242243
? true
243244
: true extends B
244-
? true
245-
: false
245+
? true
246+
: false
246247

247248
type HasHitsPerPage<S extends SearchParams> = undefined extends S['hitsPerPage']
248249
? false
@@ -403,7 +404,7 @@ export const TaskStatus = {
403404
TASK_CANCELED: 'canceled',
404405
} as const
405406

406-
export type TaskStatus = typeof TaskStatus[keyof typeof TaskStatus]
407+
export type TaskStatus = (typeof TaskStatus)[keyof typeof TaskStatus]
407408

408409
export const TaskTypes = {
409410
DOCUMENTS_ADDITION_OR_UPDATE: 'documentAdditionOrUpdate',
@@ -419,7 +420,7 @@ export const TaskTypes = {
419420
TASK_DELETION: 'taskDeletion',
420421
} as const
421422

422-
export type TaskTypes = typeof TaskTypes[keyof typeof TaskTypes]
423+
export type TaskTypes = (typeof TaskTypes)[keyof typeof TaskTypes]
423424

424425
export type TasksQuery = {
425426
indexUids?: string[]
@@ -972,7 +973,8 @@ export const ErrorStatusCode = {
972973
INVALID_FACET_SEARCH_FACET_QUERY: 'invalid_facet_search_facet_query',
973974
}
974975

975-
export type ErrorStatusCode = typeof ErrorStatusCode[keyof typeof ErrorStatusCode]
976+
export type ErrorStatusCode =
977+
(typeof ErrorStatusCode)[keyof typeof ErrorStatusCode]
976978

977979
export type TokenIndexRules = {
978980
[field: string]: any

src/utils.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
/** Removes undefined entries from object */
22
function removeUndefinedFromObject(obj: Record<string, any>): object {
3-
return Object.entries(obj).reduce((acc, curEntry) => {
4-
const [key, val] = curEntry
5-
if (val !== undefined) acc[key] = val
6-
return acc
7-
}, {} as Record<string, any>)
3+
return Object.entries(obj).reduce(
4+
(acc, curEntry) => {
5+
const [key, val] = curEntry
6+
if (val !== undefined) acc[key] = val
7+
return acc
8+
},
9+
{} as Record<string, any>
10+
)
811
}
912

1013
async function sleep(ms: number): Promise<void> {
@@ -26,7 +29,8 @@ function addTrailingSlash(url: string): string {
2629
}
2730

2831
function validateUuid4(uuid: string): boolean {
29-
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
32+
const regexExp =
33+
/^[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
3034
return regexExp.test(uuid)
3135
}
3236

tests/utils/meilisearch-test-utils.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,16 @@ async function getKey(permission: string): Promise<string> {
3030
const { results: keys } = await masterClient.getKeys()
3131

3232
if (permission === 'Search') {
33-
const key = keys.find((key: any) => key.name === 'Default Search API Key')
34-
?.key
33+
const key = keys.find(
34+
(key: any) => key.name === 'Default Search API Key'
35+
)?.key
3536
return key || ''
3637
}
3738

3839
if (permission === 'Admin') {
39-
const key = keys.find((key: any) => key.name === 'Default Admin API Key')
40-
?.key
40+
const key = keys.find(
41+
(key: any) => key.name === 'Default Admin API Key'
42+
)?.key
4143
return key || ''
4244
}
4345
return MASTER_KEY

0 commit comments

Comments
 (0)