Skip to content

Commit 49e199f

Browse files
committed
Update ESLint config to ignore public directory and adjust rules
- Add `public/**` to ignore patterns - Disable `@typescript-eslint/no-empty-object-type` rule - Configure `@typescript-eslint/ban-ts-comment` to allow with description - Add `caughtErrorsIgnorePattern` to unused vars rule - Fix caught errors variable naming in multiple files - Apply Prettier formatting to affected files
1 parent d607938 commit 49e199f

6 files changed

Lines changed: 94 additions & 96 deletions

File tree

eslint.config.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default [
1111

1212
{
1313
name: 'app/files-to-ignore',
14-
ignores: ['**/dist/**', '**/node_modules/**', '**/dist-ssr/**', '**/coverage/**'],
14+
ignores: ['**/dist/**', '**/node_modules/**', '**/dist-ssr/**', '**/coverage/**', 'public/**'],
1515
},
1616

1717
...pluginVue.configs['flat/recommended'],
@@ -30,11 +30,20 @@ export default [
3030
'vue/multi-word-component-names': 'off',
3131
'vue/require-default-prop': 'off',
3232
'@typescript-eslint/no-explicit-any': 'warn',
33+
'@typescript-eslint/no-empty-object-type': 'off',
34+
'@typescript-eslint/ban-ts-comment': [
35+
'error',
36+
{
37+
'ts-ignore': 'allow-with-description',
38+
'ts-expect-error': 'allow-with-description',
39+
},
40+
],
3341
'@typescript-eslint/no-unused-vars': [
3442
'error',
3543
{
3644
argsIgnorePattern: '^_',
3745
varsIgnorePattern: '^_',
46+
caughtErrorsIgnorePattern: '^_',
3847
},
3948
],
4049
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',

src/components/chat/composables/useMessageUrl.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import { mediaAPI } from '@/api/media'
66
const PROXY_BASE = 'https://spmc.sponeur.com/proxy'
77
const ALLOWED_DOMAINS = [
88
'vweixinf.tc.qq.com',
9-
'mmbiz.qpic.cn'
10-
// 'wxapp.tc.qq.com'
9+
'mmbiz.qpic.cn',
10+
// 'wxapp.tc.qq.com'
1111
]
1212

1313
function convertToProxyUrl(url: string): string {
14-
if (window.location.host.indexOf('xlight')=== -1) return url
14+
if (window.location.host.indexOf('xlight') === -1) return url
1515
if (!url || !url.startsWith('http://')) return url
1616

1717
try {
1818
const urlObj = new URL(url)
1919
if (ALLOWED_DOMAINS.includes(urlObj.hostname)) {
2020
return `${PROXY_BASE}/${urlObj.hostname}${urlObj.pathname}${urlObj.search}`
2121
}
22-
} catch (e) {
22+
} catch (_e) {
2323
console.error('Invalid URL:', url)
2424
}
2525
return url
@@ -124,7 +124,9 @@ export function useMessageUrl(message: Message) {
124124
const shoppingMiniProgramTitle = computed(() => message.contents?.title || '购物小程序')
125125
const shoppingMiniProgramUrl = computed(() => message.contents?.url || '')
126126
const shoppingMiniProgramDesc = computed(() => message.contents?.desc || '')
127-
const shoppingMiniProgramThumb = computed(() => message.contents?.thumbUrl || message.contents?.thumburl || '')
127+
const shoppingMiniProgramThumb = computed(
128+
() => message.contents?.thumbUrl || message.contents?.thumburl || ''
129+
)
128130

129131
// 小视频相关
130132
const shortVideoTitle = computed(() => message.contents?.title || '小视频')
@@ -164,6 +166,6 @@ export function useMessageUrl(message: Message) {
164166
locationLabel,
165167
locationX,
166168
locationY,
167-
locationCityname
169+
locationCityname,
168170
}
169171
}

src/components/common/Time.vue

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script setup lang="ts">
22
import { computed } from 'vue'
3-
import {
4-
formatRelativeTime,
5-
formatMessageTime,
3+
import {
4+
formatRelativeTime,
5+
formatMessageTime,
66
formatSessionTime,
77
formatFullDate,
88
formatDate,
99
formatDateTime,
10-
formatTime
10+
formatTime,
1111
} from '@/utils/date'
1212
1313
interface Props {
@@ -22,20 +22,21 @@ interface Props {
2222
const props = withDefaults(defineProps<Props>(), {
2323
format: 'auto',
2424
tooltip: true,
25-
tooltipFormat: 'full'
25+
tooltipFormat: 'full',
2626
})
2727
2828
// 格式化时间
2929
const formattedTime = computed(() => {
3030
if (!props.time) return ''
31-
31+
3232
try {
3333
// 统一转换为 Date 对象
34-
const date = typeof props.time === 'number'
35-
? new Date(props.time < 10000000000 ? props.time * 1000 : props.time)
36-
: typeof props.time === 'string'
37-
? new Date(props.time)
38-
: props.time
34+
const date =
35+
typeof props.time === 'number'
36+
? new Date(props.time < 10000000000 ? props.time * 1000 : props.time)
37+
: typeof props.time === 'string'
38+
? new Date(props.time)
39+
: props.time
3940
4041
switch (props.format) {
4142
case 'relative':
@@ -67,14 +68,15 @@ const formattedTime = computed(() => {
6768
// Tooltip 内容
6869
const tooltipContent = computed(() => {
6970
if (!props.tooltip || !props.time) return ''
70-
71+
7172
try {
7273
// 统一转换为 Date 对象
73-
const date = typeof props.time === 'number'
74-
? new Date(props.time < 10000000000 ? props.time * 1000 : props.time)
75-
: typeof props.time === 'string'
76-
? new Date(props.time)
77-
: props.time
74+
const date =
75+
typeof props.time === 'number'
76+
? new Date(props.time < 10000000000 ? props.time * 1000 : props.time)
77+
: typeof props.time === 'string'
78+
? new Date(props.time)
79+
: props.time
7880
7981
switch (props.tooltipFormat) {
8082
case 'full':
@@ -86,7 +88,7 @@ const tooltipContent = computed(() => {
8688
default:
8789
return formatFullDate(date)
8890
}
89-
} catch (error) {
91+
} catch (_error) {
9092
return ''
9193
}
9294
})
@@ -95,22 +97,18 @@ const tooltipContent = computed(() => {
9597
const displayText = computed(() => {
9698
const text = formattedTime.value
9799
if (!text) return ''
98-
100+
99101
let result = text
100102
if (props.prefix) result = props.prefix + result
101103
if (props.suffix) result = result + props.suffix
102-
104+
103105
return result
104106
})
105107
</script>
106108

107109
<template>
108110
<span class="time-display">
109-
<el-tooltip
110-
v-if="tooltip && tooltipContent"
111-
:content="tooltipContent"
112-
placement="top"
113-
>
111+
<el-tooltip v-if="tooltip && tooltipContent" :content="tooltipContent" placement="top">
114112
<span class="time-text">
115113
<slot :time="formattedTime">{{ displayText }}</slot>
116114
</span>
@@ -124,11 +122,11 @@ const displayText = computed(() => {
124122
<style lang="scss" scoped>
125123
.time-display {
126124
display: inline-block;
127-
125+
128126
.time-text {
129127
font-size: inherit;
130128
color: inherit;
131129
white-space: nowrap;
132130
}
133131
}
134-
</style>
132+
</style>

src/stores/onboarding.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const useOnboardingStore = defineStore('onboarding', () => {
104104
// 5. 验证 JSON 格式
105105
try {
106106
await response.json()
107-
} catch (e) {
107+
} catch (_e) {
108108
const errorMsg = '响应格式错误:无法解析 JSON'
109109
apiTestStatus.value = 'error'
110110
apiTestError.value = errorMsg
@@ -227,4 +227,4 @@ export const useOnboardingStore = defineStore('onboarding', () => {
227227
loadExistingConfig,
228228
shouldShowOnboarding,
229229
}
230-
})
230+
})

src/utils/serviceWorker.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,9 @@ export class ServiceWorkerManager {
9595

9696
console.log('[SW Manager] Registering Service Worker:', this.config.scriptUrl)
9797

98-
this.registration = await navigator.serviceWorker.register(
99-
this.config.scriptUrl,
100-
{ scope: this.config.scope }
101-
)
98+
this.registration = await navigator.serviceWorker.register(this.config.scriptUrl, {
99+
scope: this.config.scope,
100+
})
102101

103102
console.log('[SW Manager] Service Worker registered successfully')
104103
this.state = ServiceWorkerState.REGISTERED
@@ -192,7 +191,7 @@ export class ServiceWorkerManager {
192191
})
193192

194193
// 监听来自 Service Worker 的消息
195-
navigator.serviceWorker.addEventListener('message', (event) => {
194+
navigator.serviceWorker.addEventListener('message', event => {
196195
console.log('[SW Manager] Message from SW:', event.data)
197196
this.emit('message', event.data)
198197
})
@@ -258,7 +257,7 @@ export class ServiceWorkerManager {
258257
return new Promise((resolve, reject) => {
259258
const messageChannel = new MessageChannel()
260259

261-
messageChannel.port1.onmessage = (event) => {
260+
messageChannel.port1.onmessage = event => {
262261
if (event.data.success) {
263262
resolve(event.data)
264263
} else {
@@ -339,10 +338,7 @@ export class ServiceWorkerManager {
339338
/**
340339
* 显示通知(通过 Service Worker)
341340
*/
342-
async showNotification(
343-
title: string,
344-
options?: NotificationOptions
345-
): Promise<void> {
341+
async showNotification(title: string, options?: NotificationOptions): Promise<void> {
346342
if (!this.registration) {
347343
throw new Error('Service Worker not registered')
348344
}
@@ -401,9 +397,9 @@ export class ServiceWorkerManager {
401397
throw new Error('Service Worker not registered')
402398
}
403399

404-
// @ts-ignore - Background Sync API 可能不被所有 TypeScript 版本识别
400+
// @ts-ignore -- Background Sync API 可能不被所有 TypeScript 版本识别
405401
if ('sync' in this.registration) {
406-
// @ts-ignore
402+
// @ts-ignore -- sync API 类型定义缺失
407403
await this.registration.sync.register(tag)
408404
console.log('[SW Manager] Background sync registered:', tag)
409405
} else {
@@ -419,9 +415,9 @@ export class ServiceWorkerManager {
419415
throw new Error('Service Worker not registered')
420416
}
421417

422-
// @ts-ignore - Periodic Sync API 可能不被所有 TypeScript 版本识别
418+
// @ts-ignore -- Periodic Sync API 可能不被所有 TypeScript 版本识别
423419
if ('periodicSync' in this.registration) {
424-
// @ts-ignore
420+
// @ts-ignore -- periodicSync API 类型定义缺失
425421
await this.registration.periodicSync.register(tag, { minInterval })
426422
console.log('[SW Manager] Periodic sync registered:', tag)
427423
} else {
@@ -463,10 +459,8 @@ export class ServiceWorkerManager {
463459
* 工具方法:将 Base64 字符串转换为 Uint8Array
464460
*/
465461
private urlBase64ToUint8Array(base64String: string): Uint8Array {
466-
const padding = '='.repeat((4 - base64String.length % 4) % 4)
467-
const base64 = (base64String + padding)
468-
.replace(/-/g, '+')
469-
.replace(/_/g, '/')
462+
const padding = '='.repeat((4 - (base64String.length % 4)) % 4)
463+
const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/')
470464

471465
const rawData = window.atob(base64)
472466
const outputArray = new Uint8Array(rawData.length)
@@ -530,14 +524,18 @@ export function getActiveServiceWorker(): ServiceWorker | null {
530524
* 等待 Service Worker 激活
531525
*/
532526
export function waitForServiceWorkerActivation(): Promise<void> {
533-
return new Promise((resolve) => {
527+
return new Promise(resolve => {
534528
if (navigator.serviceWorker.controller) {
535529
resolve()
536530
return
537531
}
538532

539-
navigator.serviceWorker.addEventListener('controllerchange', () => {
540-
resolve()
541-
}, { once: true })
533+
navigator.serviceWorker.addEventListener(
534+
'controllerchange',
535+
() => {
536+
resolve()
537+
},
538+
{ once: true }
539+
)
542540
})
543541
}

0 commit comments

Comments
 (0)