Skip to content

chore(lint): clear all ESLint warnings across components + TS files#51

Merged
oxyc merged 1 commit into
mainfrom
chore/ts-untangle-ternaries
May 29, 2026
Merged

chore(lint): clear all ESLint warnings across components + TS files#51
oxyc merged 1 commit into
mainfrom
chore/ts-untangle-ternaries

Conversation

@oxyc

@oxyc oxyc commented May 29, 2026

Copy link
Copy Markdown
Member

Was 19 warnings, now 0. No behaviour change in any file — pure code restructuring + two well-justified eslint-disable comments for drag/resize handles.

no-nested-ternary (12 hits)

Extracted to named helper functions or rewritten as if/else chains:

File Fix
Composer.jsx renderActionButton(isRunning, hasText, handleCancel) reads as a state machine instead of a ternary stack
Messages.jsx BlockChip label resolution is now linear: liveName → cachedLabel → "block"
ToolCallFallback.jsx DIFF_ROW_CLASS + DIFF_ROW_PREFIX lookup tables with diffRowClass() / diffRowPrefix() accessors
conversations-dataview.jsx sort comparator uses if/else returns
mcp-servers-dataview.jsx three sites: renderListBody, originLabel, saveLabel helpers
editor-bridge.ts + use-runtime-adapter.ts the two carried over from PR #48 / #50 — handled in the same pass

no-unused-vars-before-return (4 hits)

Moved const declarations down past their potential early-return:

  • MicButton.jsxttsAvail moved to where it's actually used (the popover-visibility computation)
  • SidePanels.jsxdiffHr moved after the diffMin < 60 early-return
  • mcp-servers-dataview.jsxmsg moved into the status === "error" branch where it's read
  • editor-bridge.tslimit in queryDom() computed lazily on first iteration instead of before the querySelectorAll try-catch

jsx-a11y/no-static-element-interactions (2 hits)

Drag (Thread.jsx panel header) and resize (assistant-modal.jsx corner) handles on <div> with onMouseDown. Adding real keyboard equivalents is meaningful UX work — panel positioning needs arrow-key movement with discrete steps, focus management — not a one-line change. Documented as eslint-disable-next-line with the rationale that the panel HAS keyboard-reachable equivalents elsewhere (size/position controls in the header actions). .eslintrc.js already calls these out as "real concerns, but separate work".

no-alert (1 hit)

mcp-servers-dataview.jsx's remove() confirmation. The original disable comment was on the wrong line (covered if ( instead of window.confirm). Extracted the message into a const and placed the disable comment directly above the line that triggers the rule. Real custom-dialog UI for this remains a future pass.

Verification

  • npm run typecheck — clean
  • npm run build — succeeds
  • npm run test:unit — 17/17 pass
  • npm run lint:js0 warnings, 0 errors

🤖 Generated with Claude Code

Was 19 warnings, now 0. No behaviour change in any file — pure code
restructuring + two well-justified eslint-disable comments for drag/
resize handles.

## no-nested-ternary (12 hits)

Extracted to named helper functions or rewritten as if/else chains:

- `Composer.jsx` — `renderActionButton(isRunning, hasText, handleCancel)`
  reads as a state machine instead of a ternary stack inside JSX
- `Messages.jsx` — `BlockChip` label resolution is now linear:
  liveName → cachedLabel → "block"
- `ToolCallFallback.jsx` — `DIFF_ROW_CLASS` + `DIFF_ROW_PREFIX` lookup
  tables with `diffRowClass()` / `diffRowPrefix()` accessors
- `conversations-dataview.jsx` — sort comparator now uses
  if/else returns
- `mcp-servers-dataview.jsx` — three sites:
  • `renderListBody(loading, servers, fields, view)` for the
    loading/empty/dataview tri-state
  • `originLabel(origin)` map for `OriginBadge`
  • `saveLabel(saving, isEdit)` for the modal's primary button

## no-unused-vars-before-return (4 hits)

Moved `const` declarations down past their potential early-return:

- `MicButton.jsx` — `ttsAvail` was assigned at the top but the component
  returns null when speech recognition is unsupported; moved to where
  it's actually used (the popover-visibility computation)
- `SidePanels.jsx` — `diffHr` declared before the `diffMin < 60`
  early-return; moved after
- `mcp-servers-dataview.jsx` — `msg` declared before the
  `status === "success"` early-return path; moved into the
  `status === "error"` branch
- `editor-bridge.ts` — `limit` in `queryDom()` was computed before
  the `querySelectorAll` try-catch that may early-return; now computed
  lazily on first use inside the loop

## jsx-a11y/no-static-element-interactions (2 hits)

Drag and resize handles on `<div>` elements with `onMouseDown`. Adding
real keyboard equivalents is meaningful UX work (panel positioning
needs arrow-key movement with discrete steps, focus management, etc.)
not a one-line change. Documented as `eslint-disable-next-line` with
the rationale that the panel HAS keyboard-reachable equivalents
elsewhere (size/position controls in the header actions). `.eslintrc.js`
already calls these out as "real concerns, but separate work".

## no-alert (1 hit)

`mcp-servers-dataview.jsx`'s `remove()` confirmation. The original
disable comment was on the wrong line (covered `if (` instead of
`window.confirm`). Extracted the message into a `const`, then placed
the disable comment directly above the line that actually triggers
the rule. The .eslintrc.js still flags `no-alert` as a warning, so
custom-dialog UI for this remains a future pass.

## Verification

- `npm run typecheck` — clean
- `npm run build` — succeeds
- `npm run test:unit` — 17/17 pass
- `npm run lint:js` — 0 warnings, 0 errors

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oxyc oxyc merged commit f16bd83 into main May 29, 2026
3 checks passed
@oxyc oxyc deleted the chore/ts-untangle-ternaries branch May 29, 2026 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant