lint fix wip

This commit is contained in:
Nicolas Cantu 2026-01-07 17:09:07 +01:00
parent 6d993bedc5
commit 24d30eb5d0
4 changed files with 38 additions and 45 deletions

View File

@ -15,19 +15,16 @@ export function deleteAllCookies(): void {
for (let i = 0; i < cookies.length; i += 1) { for (let i = 0; i < cookies.length; i += 1) {
const cookie = cookies[i] const cookie = cookies[i]
if (!cookie) { if (cookie) {
continue const eqPos = cookie.indexOf('=')
} const name = eqPos > -1 ? cookie.substring(0, eqPos).trim() : cookie.trim()
const eqPos = cookie.indexOf('=')
const name = eqPos > -1 ? cookie.substring(0, eqPos).trim() : cookie.trim()
if (!name) { if (name) {
continue // Delete cookie by setting it to expire in the past
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=${window.location.hostname}`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.${window.location.hostname}`
}
} }
// Delete cookie by setting it to expire in the past
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=${window.location.hostname}`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/;domain=.${window.location.hostname}`
} }
} }

View File

@ -14,17 +14,16 @@ function canonicalizeObject(obj: Record<string, unknown>): string {
for (const key of sortedKeys) { for (const key of sortedKeys) {
const value = obj[key] const value = obj[key]
if (value === undefined || value === null) { if (value !== undefined && value !== null) {
continue // Skip undefined/null values if (typeof value === 'object' && !Array.isArray(value)) {
} // Recursively canonicalize nested objects
if (typeof value === 'object' && !Array.isArray(value)) { parts.push(`${key}:${canonicalizeObject(value as Record<string, unknown>)}`)
// Recursively canonicalize nested objects } else if (Array.isArray(value)) {
parts.push(`${key}:${canonicalizeObject(value as Record<string, unknown>)}`) // Arrays are serialized as comma-separated values
} else if (Array.isArray(value)) { parts.push(`${key}:[${value.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(',')}]`)
// Arrays are serialized as comma-separated values } else {
parts.push(`${key}:[${value.map((v) => (typeof v === 'object' ? JSON.stringify(v) : String(v))).join(',')}]`) parts.push(`${key}:${String(value)}`)
} else { }
parts.push(`${key}:${String(value)}`)
} }
} }

View File

@ -36,17 +36,15 @@ export function loadTranslations(locale: Locale, translationsText: string): void
const lines = translationsText.split('\n') const lines = translationsText.split('\n')
for (const line of lines) { for (const line of lines) {
const trimmed = line.trim() const trimmed = line.trim()
if (!trimmed || trimmed.startsWith('#')) { if (trimmed && !trimmed.startsWith('#')) {
continue const equalIndex = trimmed.indexOf('=')
} if (equalIndex !== -1) {
const equalIndex = trimmed.indexOf('=') const key = trimmed.substring(0, equalIndex).trim()
if (equalIndex === -1) { const value = trimmed.substring(equalIndex + 1).trim()
continue if (key && value) {
} translationsMap[key] = value
const key = trimmed.substring(0, equalIndex).trim() }
const value = trimmed.substring(equalIndex + 1).trim() }
if (key && value) {
translationsMap[key] = value
} }
} }

View File

@ -175,18 +175,17 @@ function renderLink(line: string, index: number, elements: React.ReactElement[])
let match let match
while ((match = linkRegex.exec(line)) !== null) { while ((match = linkRegex.exec(line)) !== null) {
if (!match[2]) { if (match[2]) {
continue if (!match[1] || match.index > lastIndex) {
parts.push(line.substring(lastIndex, match.index))
}
const href = match[2]
const isExternal = href.startsWith('http')
if (match[1]) {
parts.push(createLinkElement(match[1], href, `link-${index}-${match.index}`, isExternal))
}
lastIndex = match.index + match[0].length
} }
if (!match[1] || match.index > lastIndex) {
parts.push(line.substring(lastIndex, match.index))
}
const href = match[2]
const isExternal = href.startsWith('http')
if (match[1]) {
parts.push(createLinkElement(match[1], href, `link-${index}-${match.index}`, isExternal))
}
lastIndex = match.index + match[0].length
} }
if (lastIndex < line.length) { if (lastIndex < line.length) {