style: fix lint across client packages
eslint --fix autofixes plus manual repairs: max-len line splits (fake-api handlers, notifier/slots JSDoc, spec signatures), charAt over non-null-asserted indexing in slash detect/menu cores, Array.from for code-point capping, typeof assertions for unbound-method in specs, generic getByRole for the send-button cast, effect disposer void-wrap in command register, and dropped unused type imports.
This commit is contained in:
@@ -211,7 +211,10 @@ export class SlashController {
|
||||
return undefined
|
||||
}
|
||||
|
||||
/** Drop the menu group of a disposed source (root registry change notification). */
|
||||
/**
|
||||
* Drop the menu group of a disposed source (root registry change notification).
|
||||
* @param source - the source whose registration was disposed.
|
||||
*/
|
||||
sourceRemoved(source: SlashSource): void {
|
||||
const state = this.menu.getSnapshot()
|
||||
if (state.open && state.hit !== null && state.hit.trigger === source.trigger) {
|
||||
|
||||
@@ -52,7 +52,7 @@ export function apply(ctx: ClientContext): void {
|
||||
inject: (sessionId): MenuViewInjected => {
|
||||
// Session-scoped slot: resolve this session's controller (the slot
|
||||
// frame hands ids, not ctx — the registered id→ctx interchange).
|
||||
const actx = sessions.scope(sessionId as Parameters<typeof sessions.scope>[0])
|
||||
const actx = sessions.scope(sessionId)
|
||||
if (actx === undefined) throw new Error(`ui-slash: session "${String(sessionId)}" resolved no scope`)
|
||||
const controller = slash.sessionOf(actx)
|
||||
return {
|
||||
|
||||
@@ -18,12 +18,12 @@ const WHITESPACE = /\s/u
|
||||
*/
|
||||
function boundaryOk(draft: string, index: number, char: TriggerChar): boolean {
|
||||
if (index === 0) return true
|
||||
const prev = draft[index - 1]!
|
||||
const prev = draft.charAt(index - 1)
|
||||
if (WHITESPACE.test(prev)) return true
|
||||
if (WORD_CHAR.test(prev)) return false
|
||||
if (char === '/') {
|
||||
if (prev === '/') return false
|
||||
if (prev === ':' && index >= 2 && !WHITESPACE.test(draft[index - 2]!)) return false
|
||||
if (prev === ':' && index >= 2 && !WHITESPACE.test(draft.charAt(index - 2))) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -47,7 +47,7 @@ function boundaryOk(draft: string, index: number, char: TriggerChar): boolean {
|
||||
export const detectTrigger: DetectTrigger = (draft, caret, guard) => {
|
||||
if (guard.tier === 'frozen') return null
|
||||
for (let i = caret - 1; i >= 0; i--) {
|
||||
const ch = draft[i]!
|
||||
const ch = draft.charAt(i)
|
||||
if (WHITESPACE.test(ch)) return null
|
||||
if (ch !== '/' && ch !== '@') continue
|
||||
if (guard.tier === 'claimed' && ch === '/') continue
|
||||
|
||||
@@ -110,15 +110,13 @@ export const menuReduce: MenuReduce = (state, ev) => {
|
||||
if (!state.open) return state
|
||||
const pos = positions(state.groups)
|
||||
if (pos.length === 0) return state
|
||||
const at = state.highlight
|
||||
? pos.findIndex(p => p.source === state.highlight!.source && p.index === state.highlight!.index)
|
||||
: -1
|
||||
const next = at < 0
|
||||
? (ev.dir === 1 ? pos[0]! : pos[pos.length - 1]!)
|
||||
: pos[(at + ev.dir + pos.length) % pos.length]!
|
||||
if (state.highlight && next.source === state.highlight.source && next.index === state.highlight.index) {
|
||||
return state
|
||||
}
|
||||
const hl = state.highlight
|
||||
const at = hl ? pos.findIndex(p => p.source === hl.source && p.index === hl.index) : -1
|
||||
const next = pos[at < 0
|
||||
? (ev.dir === 1 ? 0 : pos.length - 1)
|
||||
: (at + ev.dir + pos.length) % pos.length]
|
||||
if (next === undefined) return state
|
||||
if (hl && next.source === hl.source && next.index === hl.index) return state
|
||||
return { ...state, highlight: next }
|
||||
}
|
||||
case 'close':
|
||||
|
||||
Reference in New Issue
Block a user