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
This commit is contained in:
Jinwoo-H
2026-09-20 10:11:13 -04:00
parent 4376f50f71
commit a8f9af6e99
13 changed files with 7 additions and 22 deletions
@@ -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,
@@ -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 })
}
@@ -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)
@@ -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()
@@ -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 {
@@ -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()
@@ -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' })
@@ -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!)
@@ -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
@@ -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) {
@@ -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)
@@ -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()
+1 -1
View File
@@ -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 {}
}