chore(lint): clear the semantic .tsx backlog

Hand fixes for the findings --fix cannot touch, mirroring the fixes
already applied on the fe-docs feature branch (same file, same shape)
so its eventual rebase resolves cleanly:

- restore the return the no-confusing-void-expression autofix ate in
  useAbsentSnapshot (typed S | undefined; hook call kept for hook-order
  stability, undefined returned explicitly);
- re-type DOM queries the no-unnecessary-type-assertion autofix broke:
  getByRole<HTMLButtonElement>(...) generics instead of the removed
  as-casts (the eslint program and the client tsconfig aggregate
  disagree about these casts; the generic form satisfies both);
- justified eslint-disable for the deliberate legacy paths: keyCode 229
  IME-composition detection, execCommand clipboard fallbacks, lib.dom
  clipboard optionality, and the any-typed Reflect.get/this probes in
  test fakes;
- drop the dead react/no-danger directive (eslint-plugin-react is not
  loaded, so the rule never applied) keeping its shiki rationale;
- delete the tautological 'Z' comparison and the renameTarget null
  check already implied by renameBlocked;
- css-module non-null assertions replaced by type widening
  (Button className, TAG_CLASS Record) per the established pattern;
- misc: max-len comment wraps, void generic drop in the deferred test
  helper, unused type imports, floating selectWorkspace promises voided,
  member-delimiter newlines in inline type literals.
This commit is contained in:
imccyu
2026-07-27 22:23:41 +08:00
parent 2adf44fb80
commit cdd4d59ea0
31 changed files with 134 additions and 68 deletions

View File

@@ -200,7 +200,8 @@ function standardKit(
scope: SlotScope,
info: SessionMaybeProvideInfo | undefined,
): {
kit: InjectedProps; actions: object | undefined
kit: InjectedProps
actions: object | undefined
} {
const kit: InjectedProps = {
useSessions: observableHook(host.sessions.list),
@@ -253,7 +254,9 @@ function standardKit(
* composition point, one per scope branch).
*/
function SessionEntry({ entry, ownerProps, info }: {
entry: StoredEntry; ownerProps: object; info: SessionProvideInfo
entry: StoredEntry
ownerProps: object
info: SessionProvideInfo
}) {
const host = useHost()
const Comp = entry.component as FC<InjectedProps>
@@ -280,7 +283,9 @@ function RootEntry({ entry, ownerProps }: { entry: StoredEntry; ownerProps: obje
}
function StrictSessionEntry({ slotKey, entry, ownerProps }: {
slotKey: string; entry: StoredEntry; ownerProps: object
slotKey: string
entry: StoredEntry
ownerProps: object
}) {
const info = useSessionMaybeProvideInfo()
if (info.sessionId === undefined) return null
@@ -292,7 +297,9 @@ function StrictSessionEntry({ slotKey, entry, ownerProps }: {
}
function SlotOutlet({ slotKey, ownerProps, opts }: {
slotKey: string; ownerProps: object; opts?: (RenderOpts & ChainRenderOpts) | undefined
slotKey: string
ownerProps: object
opts?: (RenderOpts & ChainRenderOpts) | undefined
}) {
const host = useHost()
// Version tick drives entries() re-read; the host batches per microtask.
@@ -335,7 +342,7 @@ function SlotOutlet({ slotKey, ownerProps, opts }: {
return guarded(entry)
}
if (spec.kind === 'keyed') {
const entry = entries.find(e => e.options?.key === opts?.entryKey)
const entry = entries.find(e => e.options.key === opts?.entryKey)
if (!entry) return <>{opts?.fallback ?? null}</>
return guarded(entry)
}
@@ -390,8 +397,8 @@ function SlotOutlet({ slotKey, ownerProps, opts }: {
// list: registration order refined by explicit order, optional id filter.
const withListOptions = entries.map(entry => ({
entry,
id: entry.options?.id,
order: entry.options?.order ?? 0,
id: entry.options.id,
order: entry.options.order ?? 0,
}))
let list = [...withListOptions].sort((a, b) => a.order - b.order)
if (opts?.only !== undefined) list = list.filter(item => item.id === opts.only)

View File

@@ -77,7 +77,10 @@ export function maybeObservableHook<T>(source: HostObservable<T> | undefined): M
}
function useAbsentSnapshot<S>(_selector: (snapshot: never) => S, _equal?: (a: S, b: S) => boolean): S | undefined {
// The uSES subscription must still run (hook-order stability); the absent
// source always snapshots undefined, returned explicitly.
observableHook(absentSource)(() => undefined)
return undefined
}
/**

View File

@@ -33,7 +33,10 @@ const entryOf = (partial: Omit<StoredEntry, 'options'> & { options?: StoredEntry
* but entry.store is typed to the full contract — the real defineStore lives
* in runtime, which web-react tests must not import (dependency direction).
*/
function miniStore<T extends object>(init: () => T, mutators: Record<string, (state: T, ...params: never[]) => T>): StoreHandle<T, ActionsDecl<T>> {
function miniStore<T extends object>(
init: () => T,
mutators: Record<string, (state: T, ...params: never[]) => T>,
): StoreHandle<T, ActionsDecl<T>> {
return {
spec: { init, actions: {} },
create: () => {

View File

@@ -3,10 +3,10 @@ import { describe, expect, it, vi } from 'vitest'
import { act, render } from '@testing-library/react'
import { useInvoke } from '@deepseek-ai/dsh-client-web-react'
function deferred<T>() {
let resolve!: (v: T) => void
function deferred() {
let resolve!: () => void
let reject!: (e: unknown) => void
const promise = new Promise<T>((res, rej) => { resolve = res; reject = rej })
const promise = new Promise<void>((res, rej) => { resolve = res; reject = rej })
return { promise, resolve, reject }
}
@@ -28,7 +28,7 @@ const newProbe = (): Probe => ({ invoke: () => {}, pending: false, renders: 0 })
describe('useInvoke', () => {
it('tracks pending across the action lifecycle', async () => {
const d = deferred<void>()
const d = deferred()
const probe = newProbe()
render(<Harness fn={() => d.promise} probe={probe} />)
expect(probe.pending).toBe(false)
@@ -39,8 +39,8 @@ describe('useInvoke', () => {
})
it('keeps pending true until the last concurrent call settles', async () => {
const d1 = deferred<void>()
const d2 = deferred<void>()
const d1 = deferred()
const d2 = deferred()
const queue = [d1, d2]
const probe = newProbe()
render(<Harness fn={() => queue.shift()!.promise} probe={probe} />)
@@ -68,7 +68,7 @@ describe('useInvoke', () => {
it('resets pending and logs when the action rejects', async () => {
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {})
const d = deferred<void>()
const d = deferred()
const probe = newProbe()
render(<Harness fn={() => d.promise} probe={probe} />)
act(() => { probe.invoke() })