Fix linting warnings in terminal and URL highlighter

- Replace non-null assertions with proper null checks in terminal.ts
- Add defensive null checks in all queued operations
- Fix non-null assertion in url-highlighter.ts regex match
- Remove all forbidden non-null assertion warnings for our files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Mario Zechner 2025-06-18 02:16:06 +02:00
parent 2e599d4679
commit 21d0f710f1
2 changed files with 21 additions and 9 deletions

View file

@ -53,9 +53,11 @@ export class Terminal extends LitElement {
// Process all queued operations in order // Process all queued operations in order
while (this.operationQueue.length > 0) { while (this.operationQueue.length > 0) {
const operation = this.operationQueue.shift()!; const operation = this.operationQueue.shift();
if (operation) {
operation(); operation();
} }
}
const queueEnd = performance.now(); const queueEnd = performance.now();
console.log( console.log(
@ -608,8 +610,10 @@ export class Terminal extends LitElement {
if (!this.terminal) return; if (!this.terminal) return;
this.queueOperation(() => { this.queueOperation(() => {
if (!this.terminal) return;
const writeStart = performance.now(); const writeStart = performance.now();
this.terminal!.write(data, () => { this.terminal.write(data, () => {
const writeEnd = performance.now(); const writeEnd = performance.now();
console.log( console.log(
@ -626,7 +630,9 @@ export class Terminal extends LitElement {
if (!this.terminal) return; if (!this.terminal) return;
this.queueOperation(() => { this.queueOperation(() => {
this.terminal!.clear(); if (!this.terminal) return;
this.terminal.clear();
this.viewportY = 0; this.viewportY = 0;
}); });
} }
@ -643,7 +649,9 @@ export class Terminal extends LitElement {
if (!this.terminal) return; if (!this.terminal) return;
this.queueOperation(() => { this.queueOperation(() => {
this.terminal!.resize(cols, rows); if (!this.terminal) return;
this.terminal.resize(cols, rows);
this.fitTerminal(); this.fitTerminal();
this.requestUpdate(); this.requestUpdate();
}); });
@ -663,7 +671,9 @@ export class Terminal extends LitElement {
return; return;
} }
const buffer = this.terminal!.buffer.active; if (!this.terminal) return;
const buffer = this.terminal.buffer.active;
const maxScroll = Math.max(0, buffer.length - this.actualRows); const maxScroll = Math.max(0, buffer.length - this.actualRows);
this.viewportY = maxScroll; this.viewportY = maxScroll;
}); });
@ -677,7 +687,9 @@ export class Terminal extends LitElement {
if (!this.terminal) return; if (!this.terminal) return;
this.queueOperation(() => { this.queueOperation(() => {
const buffer = this.terminal!.buffer.active; if (!this.terminal) return;
const buffer = this.terminal.buffer.active;
const maxScroll = Math.max(0, buffer.length - this.actualRows); const maxScroll = Math.max(0, buffer.length - this.actualRows);
this.viewportY = Math.max(0, Math.min(maxScroll, position)); this.viewportY = Math.max(0, Math.min(maxScroll, position));
}); });

View file

@ -20,8 +20,8 @@ export class UrlHighlighter {
// Look for http(s):// in this line // Look for http(s):// in this line
const httpMatch = lineText.match(/(https?:\/\/)/); const httpMatch = lineText.match(/(https?:\/\/)/);
if (httpMatch) { if (httpMatch && httpMatch.index !== undefined) {
const urlStart = httpMatch.index!; const urlStart = httpMatch.index;
let fullUrl = ''; let fullUrl = '';
let endLine = i; let endLine = i;