From a8f9af6e99aedbfd2b6c355ab6e07cebf972e88e Mon Sep 17 00:00:00 2001 From: Jinwoo-H Date: Sun, 20 Sep 2026 10:11:13 -0400 Subject: [PATCH] style(mobile): keep only the lint directives that do something Seventeen of the disables were inert: `typescript/no-non-null-assertion` is not enabled here, and a directive naming two rules on one line is not parsed at all, so the one rule that did apply was being ignored too. The changed-code quality gate reports an inert directive as a finding. The two that matter are back, one rule per line: the guard-as-expression in the observer disposal, and the local the document declares and never reads. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb --- mobile/src/terminal/document/document-constants.ts | 6 ++++-- mobile/src/terminal/document/host-message-router.ts | 2 -- mobile/src/terminal/document/keyboard-avoidance-metrics.ts | 1 - mobile/src/terminal/document/mouse-click-drag.ts | 1 - mobile/src/terminal/document/osc-link-tap.ts | 2 -- mobile/src/terminal/document/selection-menu-buttons.ts | 2 -- mobile/src/terminal/document/selection-range.ts | 2 -- mobile/src/terminal/document/surface-touch-gestures.ts | 4 +--- mobile/src/terminal/document/tap-dispatch.ts | 1 - mobile/src/terminal/document/terminal-init.ts | 3 +-- mobile/src/terminal/document/viewport-transform.ts | 2 -- mobile/src/terminal/document/webgl-recovery.ts | 1 - mobile/src/terminal/document/write-queue.ts | 2 +- 13 files changed, 7 insertions(+), 22 deletions(-) diff --git a/mobile/src/terminal/document/document-constants.ts b/mobile/src/terminal/document/document-constants.ts index 730bccf519c..c5c67b29696 100644 --- a/mobile/src/terminal/document/document-constants.ts +++ b/mobile/src/terminal/document/document-constants.ts @@ -1,7 +1,9 @@ import { colors } from '../../theme/mobile-theme' import { TERMINAL_TEXT_SCALES } from '../../storage/preferences' -import { DEFAULT_TERMINAL_THEME } from '../terminal-webview-html/theme' -import { MOBILE_TERMINAL_CARET_OPTIONS } from '../terminal-webview-html/theme' +import { + DEFAULT_TERMINAL_THEME, + MOBILE_TERMINAL_CARET_OPTIONS +} from '../terminal-webview-html/theme' import { TERMINAL_FILE_URL_REGEX_SOURCE, TERMINAL_HTTP_URL_MAX_LENGTH, diff --git a/mobile/src/terminal/document/host-message-router.ts b/mobile/src/terminal/document/host-message-router.ts index 262b864b831..b03bca2cead 100644 --- a/mobile/src/terminal/document/host-message-router.ts +++ b/mobile/src/terminal/document/host-message-router.ts @@ -41,7 +41,6 @@ export function measureFitDimensions(containerHeightPx: unknown, retriesLeft?: n let cellWidth = 0 let cellHeight = 0 if (!notReady) { - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: notReady is exactly the absence check above. const core = scope.term!._core if (core && core._renderService && core._renderService.dimensions) { cellWidth = core._renderService.dimensions.css.cell.width @@ -180,7 +179,6 @@ export function handleMsg(msg: TerminalHostMessage) { const b = scope.term.buffer.active if (scope.selMode !== 'select') { scope.selMode = 'select' - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the overlay element. scope.selectionOverlay!.classList.add('active') notify({ type: 'set-select-mode', enabled: true }) } diff --git a/mobile/src/terminal/document/keyboard-avoidance-metrics.ts b/mobile/src/terminal/document/keyboard-avoidance-metrics.ts index 93cb9866d59..4c3520ca529 100644 --- a/mobile/src/terminal/document/keyboard-avoidance-metrics.ts +++ b/mobile/src/terminal/document/keyboard-avoidance-metrics.ts @@ -11,7 +11,6 @@ export function lineHasVisibleContent( if (!cell || !line.getCell) { return false } - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: only reached from computeContentBottomRow, past its `!scope.term` guard. const limit = Math.min(scope.term!.cols || 0, line.length || 0) for (let x = 0; x < limit; x++) { const current = line.getCell(x, cell) diff --git a/mobile/src/terminal/document/mouse-click-drag.ts b/mobile/src/terminal/document/mouse-click-drag.ts index 1dd0d855c7a..aed11e99f5f 100644 --- a/mobile/src/terminal/document/mouse-click-drag.ts +++ b/mobile/src/terminal/document/mouse-click-drag.ts @@ -123,7 +123,6 @@ export function beginMouseDrag(gesture: TerminalMouseGesture) { gesture.mode = 'selecting' scope.selMode = 'select' scope.sel = { anchor: anchor, focus: anchor, activeHandle: 'end' } - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the overlay element is in the document shell. scope.selectionOverlay!.classList.add('active') notify({ type: 'set-select-mode', enabled: true }) applyXtermSelection() diff --git a/mobile/src/terminal/document/osc-link-tap.ts b/mobile/src/terminal/document/osc-link-tap.ts index 2c618563594..762c4596459 100644 --- a/mobile/src/terminal/document/osc-link-tap.ts +++ b/mobile/src/terminal/document/osc-link-tap.ts @@ -35,7 +35,6 @@ export function oscLinkAtViewportPoint(clientX: number, clientY: number) { if (!cell) { return null } - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: guarded by the catch, as every internals read here is. const line = scope.term!.buffer.active.getLine(cell.row) if (!line) { return null @@ -214,7 +213,6 @@ export function initialOscLinkTextAtRow(link: TerminalInitialOscLink, row: numbe export function oscLinkIdAtCell(line: TerminalDocumentLine, col: number) { try { - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: guarded by the catch, as every internals read here is. const bufCell = line.getCell!(col) return bufCell && bufCell.extended && bufCell.extended.urlId ? bufCell.extended.urlId : 0 } catch { diff --git a/mobile/src/terminal/document/selection-menu-buttons.ts b/mobile/src/terminal/document/selection-menu-buttons.ts index 3b37f4297f8..9601cdb3bdf 100644 --- a/mobile/src/terminal/document/selection-menu-buttons.ts +++ b/mobile/src/terminal/document/selection-menu-buttons.ts @@ -3,7 +3,6 @@ import { notify } from './host-notify' import { cancelSelect } from './selection-range' import { repositionOverlay } from './selection-overlay' -// oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the menu buttons. scope.btnCopy!.addEventListener('click', function (e) { e.preventDefault() e.stopPropagation() @@ -18,7 +17,6 @@ scope.btnCopy!.addEventListener('click', function (e) { } }) -// oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the menu buttons. scope.btnSelAll!.addEventListener('click', function (e) { e.preventDefault() e.stopPropagation() diff --git a/mobile/src/terminal/document/selection-range.ts b/mobile/src/terminal/document/selection-range.ts index 17abd554c3c..0c7e77efdf4 100644 --- a/mobile/src/terminal/document/selection-range.ts +++ b/mobile/src/terminal/document/selection-range.ts @@ -101,7 +101,6 @@ export function cancelSelect() { scope.term.refresh(0, scope.term.rows - 1) } catch {} } - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the overlay element. scope.selectionOverlay!.classList.remove('active') notify({ type: 'set-select-mode', enabled: false }) } @@ -109,7 +108,6 @@ export function cancelSelect() { export function enterSelect(col: number, absRow: number) { scope.selMode = 'select' seedWordSelection(col, absRow) - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the overlay element. scope.selectionOverlay!.classList.add('active') notify({ type: 'set-select-mode', enabled: true }) notify({ type: 'haptic', kind: 'selection' }) diff --git a/mobile/src/terminal/document/surface-touch-gestures.ts b/mobile/src/terminal/document/surface-touch-gestures.ts index 1963ab1259b..072186a14db 100644 --- a/mobile/src/terminal/document/surface-touch-gestures.ts +++ b/mobile/src/terminal/document/surface-touch-gestures.ts @@ -1,5 +1,5 @@ import { scope } from './document-scope' -import { getCellHeight } from './fit-scale' +import { clampPan, getCellHeight } from './fit-scale' import { notify } from './host-notify' import { attachSurfaceMouseClickDragHandler } from './mouse-click-drag' import { routeScrollLines, shouldRouteScrollToTerminalInput } from './mouse-input-encoding' @@ -10,7 +10,6 @@ import { } from './normal-buffer-smooth-scroll' import { dispatcherShouldBlockSurface } from './tap-dispatch' import { applyTextScale, snapToTextScalePreset } from './text-scaling' -import { clampPan } from './fit-scale' import { getTotalScale, updateTransform } from './viewport-transform' import { attachSurfaceWheelHandler } from './wheel-scroll' @@ -274,5 +273,4 @@ export function attachSurfaceEventHandlers(targetSurface: TerminalGestureSurface ) } -// oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the surface element. attachSurfaceEventHandlers(scope.surface!) diff --git a/mobile/src/terminal/document/tap-dispatch.ts b/mobile/src/terminal/document/tap-dispatch.ts index 35c16a54fb1..8e0b07c4bbd 100644 --- a/mobile/src/terminal/document/tap-dispatch.ts +++ b/mobile/src/terminal/document/tap-dispatch.ts @@ -112,7 +112,6 @@ document.addEventListener( if (onHandle && scope.selMode === 'select') { // start handle drag const handleName = target === scope.handleStart ? 'start' : 'end' - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: a handle only exists while a selection does. scope.sel!.activeHandle = handleName dispatch.mode = 'select-drag' dispatch.touchId = t.identifier diff --git a/mobile/src/terminal/document/terminal-init.ts b/mobile/src/terminal/document/terminal-init.ts index 1453c391453..83762e33024 100644 --- a/mobile/src/terminal/document/terminal-init.ts +++ b/mobile/src/terminal/document/terminal-init.ts @@ -91,7 +91,7 @@ export function init( scope.initialOscLinkRowOffset = 0 scope.initialOscLinkEvictionReady = false const surfaceSwap = beginTerminalSurfaceSwap() - // oxlint-disable-next-line no-unused-vars -- the document declares it here; removing it is a different program. + // oxlint-disable-next-line no-unused-vars -- the document declares it here; removing it is a different program const nextSurface = surfaceSwap.nextSurface applyTerminalTheme(nextTheme) @@ -119,7 +119,6 @@ export function init( }) const nextTerm = scope.term scope.pendingTerm = nextTerm - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the surface swap just mounted one. scope.term.open(scope.surface!) attachWebglAddon(true) if (window.Unicode11Addon && window.Unicode11Addon.Unicode11Addon) { diff --git a/mobile/src/terminal/document/viewport-transform.ts b/mobile/src/terminal/document/viewport-transform.ts index 6d131602b2a..8631a5c4290 100644 --- a/mobile/src/terminal/document/viewport-transform.ts +++ b/mobile/src/terminal/document/viewport-transform.ts @@ -94,7 +94,6 @@ export function getTotalScale() { } export function updateTransform() { - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the document shell ships the surface element. scope.surface!.style.transform = 'translate(' + scope.panX + 'px,' + scope.panY + 'px) scale(' + getTotalScale() + ')' updateScrollIndicator(false) @@ -137,7 +136,6 @@ export function updateScrollIndicator(reveal: boolean) { clearTimeout(scope.scrollIndicatorHideTimer) } scope.scrollIndicatorHideTimer = setTimeout(function () { - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: the guard above returned when it was absent. scrollIndicator!.classList.remove('visible') scope.scrollIndicatorHideTimer = null }, 550) diff --git a/mobile/src/terminal/document/webgl-recovery.ts b/mobile/src/terminal/document/webgl-recovery.ts index fd6ed70c582..d0c18cf5247 100644 --- a/mobile/src/terminal/document/webgl-recovery.ts +++ b/mobile/src/terminal/document/webgl-recovery.ts @@ -44,7 +44,6 @@ export function attachWebglAddon(allowRecovery: boolean) { flog('webgl-context-loss', { retry: allowRecovery }) scope.webglAddon = null try { - // oxlint-disable-next-line typescript/no-non-null-assertion -- SAFETY: this listener is registered on the addon, so it cannot run before the assignment above. addon!.dispose() } catch {} refreshTerminalSurface() diff --git a/mobile/src/terminal/document/write-queue.ts b/mobile/src/terminal/document/write-queue.ts index 310d903f69c..24a40f8ed6e 100644 --- a/mobile/src/terminal/document/write-queue.ts +++ b/mobile/src/terminal/document/write-queue.ts @@ -72,7 +72,7 @@ export function disposeTermObservers() { scope.termObserverDisposables = [] for (let i = 0; i < disposables.length; i++) { try { - // oxlint-disable-next-line no-unused-expressions, typescript/no-non-null-assertion -- SAFETY: the guard is the call's own condition, and it proves the method is there. + // oxlint-disable-next-line no-unused-expressions -- the guard is the call's own condition; the document's text is pinned token for token disposables[i] && disposables[i].dispose && disposables[i].dispose!() } catch {} }