lint: fix misc errors (no-case-declarations, empty interfaces, empty catch blocks) (12 fixes)

Co-Authored-By: Justin Edmund <justin@jedmund.com>
This commit is contained in:
Devin AI 2025-11-24 05:41:12 +00:00
parent 62263e5785
commit 903308ce3f
9 changed files with 17 additions and 11 deletions

View file

@ -23,7 +23,9 @@ async function handleResponse(res: Response) {
// Redirect to login for unauthorized requests
try {
goto('/admin/login')
} catch {}
} catch {
// Ignore navigation errors (e.g., if already on login page)
}
}
const contentType = res.headers.get('content-type') || ''

View file

@ -26,7 +26,9 @@ export function loadDraft<T = unknown>(key: string): Draft<T> | null {
export function clearDraft(key: string) {
try {
localStorage.removeItem(key)
} catch {}
} catch {
// Ignore storage errors
}
}
export function timeAgo(ts: number): string {

View file

@ -3,7 +3,7 @@
import type { NodeViewProps } from '@tiptap/core'
import type * as L from 'leaflet'
interface Props extends NodeViewProps {}
type Props = NodeViewProps
let { node }: Props = $props()

View file

@ -188,7 +188,7 @@ export const UrlEmbed = Node.create<UrlEmbedOptions>({
if (text && !html) {
// Simple URL regex check
const urlRegex =
/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$/
/^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)$/
if (urlRegex.test(text.trim())) {
// It's a URL, let it paste as a link naturally (don't prevent default)

View file

@ -155,7 +155,7 @@
case 'audio':
editor.chain().focus().setAudio(embedUrl).run()
break
case 'location':
case 'location': {
// For location, try to extract coordinates from Google Maps URL
const coords = extractCoordinatesFromUrl(embedUrl)
if (coords) {
@ -212,7 +212,7 @@
function insertContent(media: Media) {
switch (contentType) {
case 'image':
case 'image': {
const displayWidth = media.width && media.width > 600 ? 600 : media.width
editor
.chain()
@ -236,6 +236,7 @@
])
.run()
break
}
case 'video':
editor.chain().focus().setVideo(media.url).run()
break

View file

@ -4,7 +4,7 @@
import { onMount } from 'svelte'
import type L from 'leaflet'
interface Props extends NodeViewProps {}
type Props = NodeViewProps
let { node, selected }: Props = $props()
let mapContainer: HTMLDivElement

View file

@ -64,7 +64,7 @@ export async function getPostBySlug(slug: string): Promise<Post | null> {
}
function getExcerpt(content: string, type: 'note' | 'article'): string {
const plainText = content.replace(/[#*`\[\]]/g, '').trim()
const plainText = content.replace(/[#*`[\]]/g, '').trim()
const maxLength = type === 'note' ? 280 : 160
if (plainText.length <= maxLength) return plainText

View file

@ -1,6 +1,6 @@
import type { JSONContent } from '@tiptap/core'
export interface EditorData extends JSONContent {}
export type EditorData = JSONContent
export interface EditorProps {
data?: EditorData

View file

@ -315,11 +315,12 @@ function renderTiptapContent(doc: Record<string, unknown>): string {
case 'code':
text = `<code>${text}</code>`
break
case 'link':
case 'link': {
const href = mark.attrs?.href || '#'
const target = mark.attrs?.target || '_blank'
text = `<a href="${href}" target="${target}" rel="noopener noreferrer">${text}</a>`
break
}
case 'highlight':
text = `<mark>${text}</mark>`
break