1
0

chore(deps): update dev-dependencies (major) (#3741)

Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/3741
Co-authored-by: renovate <renovatebot@kolaente.de>
Co-committed-by: renovate <renovatebot@kolaente.de>
This commit is contained in:
renovate
2023-10-20 19:34:11 +00:00
committed by konrad
parent 01c2acdf34
commit b76acb15c7
14 changed files with 195 additions and 246 deletions

View File

@ -4,6 +4,7 @@ import {snakeCase} from 'snake-case'
/**
* Transforms field names to camel case.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function objectToCamelCase(object: Record<string, any>) {
// When calling recursively, this can be called without being and object or array in which case we just return the value
@ -11,6 +12,7 @@ export function objectToCamelCase(object: Record<string, any>) {
return object
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const parsedObject: Record<string, any> = {}
for (const m in object) {
parsedObject[camelCase(m)] = object[m]
@ -23,6 +25,7 @@ export function objectToCamelCase(object: Record<string, any>) {
// Call it again for arrays
if (Array.isArray(object[m])) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
parsedObject[camelCase(m)] = object[m].map((o: Record<string, any>) => objectToCamelCase(o))
// Because typeof [] === 'object' is true for arrays, we leave the loop here to prevent converting arrays to objects.
continue
@ -39,6 +42,7 @@ export function objectToCamelCase(object: Record<string, any>) {
/**
* Transforms field names to snake case - used before making an api request.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function objectToSnakeCase(object: Record<string, any>) {
// When calling recursively, this can be called without being and object or array in which case we just return the value
@ -46,6 +50,7 @@ export function objectToSnakeCase(object: Record<string, any>) {
return object
}
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const parsedObject: Record<string, any> = {}
for (const m in object) {
parsedObject[snakeCase(m)] = object[m]
@ -61,6 +66,7 @@ export function objectToSnakeCase(object: Record<string, any>) {
// Call it again for arrays
if (Array.isArray(object[m])) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
parsedObject[snakeCase(m)] = object[m].map((o: Record<string, any>) => objectToSnakeCase(o))
// Because typeof [] === 'object' is true for arrays, we leave the loop here to prevent converting arrays to objects.
continue

View File

@ -6,7 +6,11 @@ export function findById<T extends {id: string | number}>(array : T[], id : stri
return array.find(({id: currentId}) => currentId === id)
}
export function includesById(array: any[], id: string | number) {
interface ObjectWithId {
id: number
}
export function includesById(array: ObjectWithId[], id: string | number) {
return array.some(({id: currentId}) => currentId === id)
}