style: lint

This commit is contained in:
Neko Ayaka
2026-03-23 02:16:10 +08:00
parent ac1de680d0
commit ce60323d8a
43 changed files with 58 additions and 68 deletions
@@ -165,7 +165,7 @@ function drawXY() {
})
ctx.stroke()
const head = trail.value[trail.value.length - 1]
const head = trail.value.at(-1)
if (head) {
ctx.beginPath()
ctx.arc(centerX + head.x * scale.value, centerY - head.y * scale.value, 5, 0, Math.PI * 2)
@@ -191,7 +191,7 @@ const tabs: Tab[] = [
const activeTab = computed({
get: () => {
// If current active tab is not in available tabs, reset to first tab
if (!tabs.find(tab => tab.id === activeTabId.value))
if (!tabs.some(tab => tab.id === activeTabId.value))
return tabs[0]?.id || ''
return activeTabId.value
},
@@ -165,7 +165,7 @@ const tabs = computed<Tab[]>(() => {
const activeTab = computed({
get: () => {
// If current active tab is not in available tabs, reset to first tab
if (!tabs.value.find(tab => tab.id === activeTabId.value))
if (!tabs.value.some(tab => tab.id === activeTabId.value))
return tabs.value[0]?.id || ''
return activeTabId.value
},
@@ -77,7 +77,7 @@ function removeKeyValue(index: number, headers: { key: string, value: string }[]
}
watch(headers, (headers) => {
if (headers.length > 0 && (headers[headers.length - 1].key !== '' || headers[headers.length - 1].value !== '')) {
if (headers.length > 0 && (headers.at(-1).key !== '' || headers.at(-1).value !== '')) {
headers.push({ key: '', value: '' })
}
if (!providers.value[providerId])
@@ -160,7 +160,7 @@ function normalizeHeaderRows(headers: Record<string, string>) {
if (rows.length === 0) {
rows.push({ key: '', value: '' })
}
else if (rows[rows.length - 1].key !== '' || rows[rows.length - 1].value !== '') {
else if (rows.at(-1).key !== '' || rows.at(-1).value !== '') {
rows.push({ key: '', value: '' })
}
return rows
@@ -178,7 +178,7 @@ watch(providerConfigEdit, (config) => {
watch(headerRows, (rows) => {
if (isSyncingHeaders.value)
return
const lastRow = rows[rows.length - 1]
const lastRow = rows.at(-1)
if (!lastRow || lastRow.key.trim().length > 0 || lastRow.value.trim().length > 0) {
headerRows.value = [...rows, { key: '', value: '' }]
return
@@ -137,10 +137,8 @@ export function createBeatSyncController(options: CreateBeatSyncControllerOption
currentZ = baseAngles.value.z
}
if (currentY == null)
currentY = baseAngles.value.y
if (currentZ == null)
currentZ = baseAngles.value.z
currentY ??= baseAngles.value.y
currentZ ??= baseAngles.value.z
while (segments.value.length) {
const segment = segments.value[0]
@@ -28,5 +28,5 @@ export function randomSaccadeInterval(): number {
return EYE_SACCADE_INT_P[i][1] + Math.random() * EYE_SACCADE_INT_STEP
}
}
return EYE_SACCADE_INT_P[EYE_SACCADE_INT_P.length - 1][1] + Math.random() * EYE_SACCADE_INT_STEP
return EYE_SACCADE_INT_P.at(-1)[1] + Math.random() * EYE_SACCADE_INT_STEP
}
@@ -10,7 +10,7 @@ const defaultCreateSettings = ZipLoader.createSettings
ZipLoader.createSettings = async (reader: JSZip) => {
const filePaths = Object.keys(reader.files)
if (!filePaths.find(file => isSettingsFile(file))) {
if (!filePaths.some(file => isSettingsFile(file))) {
return createFakeSettings(filePaths)
}
@@ -122,7 +122,7 @@ export function injectDiffuseIBL(mat: THREE.ShaderMaterial) {
}
// uniforms
const emptySH = Array.from({ length: 9 }, () => new THREE.Vector3())
const emptySH = Array.from({ length: 9 }).fill(new THREE.Vector3())
shader.uniforms.uNprEnvMode ||= { value: 0 }
shader.uniforms.uEnvIntensity ||= { value: 0.0 }
shader.uniforms.uSHCoeffs ||= { value: emptySH };
@@ -28,5 +28,5 @@ export function randomSaccadeInterval(): number {
return EYE_SACCADE_INT_P[i][1] + Math.random() * EYE_SACCADE_INT_STEP
}
}
return EYE_SACCADE_INT_P[EYE_SACCADE_INT_P.length - 1][1] + Math.random() * EYE_SACCADE_INT_STEP
return EYE_SACCADE_INT_P.at(-1)[1] + Math.random() * EYE_SACCADE_INT_STEP
}
@@ -35,7 +35,7 @@ function removeKeyValue(index: number, headers: { key: string, value: string }[]
}
watch(emptyHeaders, (headers) => {
if (headers.length > 0 && (headers[headers.length - 1].key !== '' || headers[headers.length - 1].value !== '')) {
if (headers.length > 0 && (headers.at(-1).key !== '' || headers.at(-1).value !== '')) {
emptyHeaders.value.push({ key: '', value: '' })
}
}, {
@@ -44,7 +44,7 @@ watch(emptyHeaders, (headers) => {
})
watch(singleHeader, (headers) => {
if (headers.length > 0 && (headers[headers.length - 1].key !== '' || headers[headers.length - 1].value !== '')) {
if (headers.length > 0 && (headers.at(-1).key !== '' || headers.at(-1).value !== '')) {
singleHeader.value.push({ key: '', value: '' })
}
}, {
@@ -53,7 +53,7 @@ watch(singleHeader, (headers) => {
})
watch(multipleHeaders, (headers) => {
if (headers.length > 0 && (headers[headers.length - 1].key !== '' || headers[headers.length - 1].value !== '')) {
if (headers.length > 0 && (headers.at(-1).key !== '' || headers.at(-1).value !== '')) {
multipleHeaders.value.push({ key: '', value: '' })
}
}, {
@@ -50,7 +50,7 @@ function getBarColor(_index: number, barLevel: number): string {
}
}
return thresholds[thresholds.length - 1]?.color || 'bg-green-500'
return thresholds.at(-1)?.color || 'bg-green-500'
}
</script>
@@ -166,7 +166,7 @@ function downsampleSeries(values: readonly number[], maxPoints: number) {
}
// Ensure the last value remains the most recent value (avoid averaging it away)
result[result.length - 1] = values[values.length - 1]
result[result.length - 1] = values.at(-1)
return result
}
@@ -28,7 +28,7 @@ watch(() => props.text, async (text) => {
if (!text)
return
if (typeof text === 'string') {
targets.value = [...segmenter.segment(text)].map(seg => seg.segment)
targets.value = Array.from(segmenter.segment(text), seg => seg.segment)
}
else {
abortController.value?.abort()
@@ -61,7 +61,7 @@ export function getSessionSummary(
combinedReasoning: allReasoning.join('\n\n'),
combinedSpeech: allSpeech.join('\n\n'),
createdAt: messages[0]?.createdAt,
lastMessageAt: messages[messages.length - 1]?.createdAt,
lastMessageAt: messages.at(-1)?.createdAt,
}
}
@@ -106,7 +106,7 @@ export function useScrollToHash(
// Retry if element not yet found
if (attempt < maxRetries) {
retryTimer = window.setTimeout(() => scrollToHash(hash, attempt + 1), retryDelay)
retryTimer = window.setTimeout(scrollToHash, retryDelay, hash, attempt + 1)
}
})
}
@@ -75,7 +75,7 @@ export const useCharacterOrchestratorStore = defineStore('character-orchestrator
}
function enqueueSparkNotify(event: WebSocketEventOf<'spark:notify'>, options?: { reason?: string, nextRunAt?: number, maxAttempts?: number }) {
if (!pendingNotifies.value.find(item => item.data.id === event.data.id)) {
if (!pendingNotifies.value.some(item => item.data.id === event.data.id)) {
pendingNotifies.value = [...pendingNotifies.value, event]
}
@@ -247,7 +247,7 @@ export const useMarkdownStressStore = defineStore('markdownStress', () => {
function buildForFlood() {
const line = 'for for for for for'
// 800 lines * 5 words = 4000 tokens
return Array.from({ length: 800 }, () => line).join('\n')
return Array.from({ length: 800 }).fill(line).join('\n')
}
function generateScenario(): DevtoolsChatScenario {
+1 -1
View File
@@ -1828,7 +1828,7 @@ export const useProvidersStore = defineStore('providers', () => {
const defaultOptions = metadata?.defaultOptions?.() || {}
return {
...defaultOptions,
...(Object.prototype.hasOwnProperty.call(defaultOptions, 'baseUrl') ? {} : { baseUrl: '' }),
...(Object.hasOwn(defaultOptions, 'baseUrl') ? {} : { baseUrl: '' }),
}
}