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:
parent
62263e5785
commit
903308ce3f
9 changed files with 17 additions and 11 deletions
|
|
@ -23,7 +23,9 @@ async function handleResponse(res: Response) {
|
||||||
// Redirect to login for unauthorized requests
|
// Redirect to login for unauthorized requests
|
||||||
try {
|
try {
|
||||||
goto('/admin/login')
|
goto('/admin/login')
|
||||||
} catch {}
|
} catch {
|
||||||
|
// Ignore navigation errors (e.g., if already on login page)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const contentType = res.headers.get('content-type') || ''
|
const contentType = res.headers.get('content-type') || ''
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,9 @@ export function loadDraft<T = unknown>(key: string): Draft<T> | null {
|
||||||
export function clearDraft(key: string) {
|
export function clearDraft(key: string) {
|
||||||
try {
|
try {
|
||||||
localStorage.removeItem(key)
|
localStorage.removeItem(key)
|
||||||
} catch {}
|
} catch {
|
||||||
|
// Ignore storage errors
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function timeAgo(ts: number): string {
|
export function timeAgo(ts: number): string {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
import type { NodeViewProps } from '@tiptap/core'
|
import type { NodeViewProps } from '@tiptap/core'
|
||||||
import type * as L from 'leaflet'
|
import type * as L from 'leaflet'
|
||||||
|
|
||||||
interface Props extends NodeViewProps {}
|
type Props = NodeViewProps
|
||||||
|
|
||||||
let { node }: Props = $props()
|
let { node }: Props = $props()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ export const UrlEmbed = Node.create<UrlEmbedOptions>({
|
||||||
if (text && !html) {
|
if (text && !html) {
|
||||||
// Simple URL regex check
|
// Simple URL regex check
|
||||||
const urlRegex =
|
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())) {
|
if (urlRegex.test(text.trim())) {
|
||||||
// It's a URL, let it paste as a link naturally (don't prevent default)
|
// It's a URL, let it paste as a link naturally (don't prevent default)
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@
|
||||||
case 'audio':
|
case 'audio':
|
||||||
editor.chain().focus().setAudio(embedUrl).run()
|
editor.chain().focus().setAudio(embedUrl).run()
|
||||||
break
|
break
|
||||||
case 'location':
|
case 'location': {
|
||||||
// For location, try to extract coordinates from Google Maps URL
|
// For location, try to extract coordinates from Google Maps URL
|
||||||
const coords = extractCoordinatesFromUrl(embedUrl)
|
const coords = extractCoordinatesFromUrl(embedUrl)
|
||||||
if (coords) {
|
if (coords) {
|
||||||
|
|
@ -212,7 +212,7 @@
|
||||||
|
|
||||||
function insertContent(media: Media) {
|
function insertContent(media: Media) {
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
case 'image':
|
case 'image': {
|
||||||
const displayWidth = media.width && media.width > 600 ? 600 : media.width
|
const displayWidth = media.width && media.width > 600 ? 600 : media.width
|
||||||
editor
|
editor
|
||||||
.chain()
|
.chain()
|
||||||
|
|
@ -236,6 +236,7 @@
|
||||||
])
|
])
|
||||||
.run()
|
.run()
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case 'video':
|
case 'video':
|
||||||
editor.chain().focus().setVideo(media.url).run()
|
editor.chain().focus().setVideo(media.url).run()
|
||||||
break
|
break
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import type L from 'leaflet'
|
import type L from 'leaflet'
|
||||||
|
|
||||||
interface Props extends NodeViewProps {}
|
type Props = NodeViewProps
|
||||||
let { node, selected }: Props = $props()
|
let { node, selected }: Props = $props()
|
||||||
|
|
||||||
let mapContainer: HTMLDivElement
|
let mapContainer: HTMLDivElement
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ export async function getPostBySlug(slug: string): Promise<Post | null> {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getExcerpt(content: string, type: 'note' | 'article'): string {
|
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
|
const maxLength = type === 'note' ? 280 : 160
|
||||||
|
|
||||||
if (plainText.length <= maxLength) return plainText
|
if (plainText.length <= maxLength) return plainText
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import type { JSONContent } from '@tiptap/core'
|
import type { JSONContent } from '@tiptap/core'
|
||||||
|
|
||||||
export interface EditorData extends JSONContent {}
|
export type EditorData = JSONContent
|
||||||
|
|
||||||
export interface EditorProps {
|
export interface EditorProps {
|
||||||
data?: EditorData
|
data?: EditorData
|
||||||
|
|
|
||||||
|
|
@ -315,11 +315,12 @@ function renderTiptapContent(doc: Record<string, unknown>): string {
|
||||||
case 'code':
|
case 'code':
|
||||||
text = `<code>${text}</code>`
|
text = `<code>${text}</code>`
|
||||||
break
|
break
|
||||||
case 'link':
|
case 'link': {
|
||||||
const href = mark.attrs?.href || '#'
|
const href = mark.attrs?.href || '#'
|
||||||
const target = mark.attrs?.target || '_blank'
|
const target = mark.attrs?.target || '_blank'
|
||||||
text = `<a href="${href}" target="${target}" rel="noopener noreferrer">${text}</a>`
|
text = `<a href="${href}" target="${target}" rel="noopener noreferrer">${text}</a>`
|
||||||
break
|
break
|
||||||
|
}
|
||||||
case 'highlight':
|
case 'highlight':
|
||||||
text = `<mark>${text}</mark>`
|
text = `<mark>${text}</mark>`
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue