lint: enforce exhaustive switches

This commit is contained in:
Peter Steinberger
2026-04-23 06:02:01 +01:00
parent 4aa35d85fa
commit e3caacd530
9 changed files with 40 additions and 0 deletions

View File

@@ -65,6 +65,10 @@
"typescript/no-unnecessary-type-parameters": "error",
"typescript/no-unsafe-type-assertion": "off",
"typescript/no-useless-default-assignment": "error",
"typescript/switch-exhaustiveness-check": [
"error",
{ "considerDefaultExhaustiveForUnions": true }
],
"typescript/prefer-return-this-type": "error",
"typescript/prefer-find": "error",
"typescript/prefer-function-type": "error",

View File

@@ -648,6 +648,11 @@ export function createDiagnosticsOtelService(): OpenClawPluginService {
case "diagnostic.heartbeat":
recordHeartbeat(evt);
return;
case "tool.loop":
case "diagnostic.memory.sample":
case "diagnostic.memory.pressure":
case "payload.large":
return;
}
} catch (err) {
ctx.logger.error(

View File

@@ -267,6 +267,8 @@ function scoreClaimMatch(params: {
case "unknown":
score -= 4;
break;
case undefined:
break;
}
score += isClaimContestedStatus(params.status) ? -6 : 4;
return score;

View File

@@ -229,6 +229,10 @@ export function processEvent(ctx: EventContext, event: NormalizedEvent): void {
transitionState(call, "listening");
break;
case "call.silence":
case "call.dtmf":
break;
case "call.ended":
finalizeCall({
ctx,

View File

@@ -233,6 +233,10 @@ export class MediaStreamHandler {
session = null;
}
break;
case "clear":
case "mark":
break;
}
} catch (error) {
console.error("[MediaStream] Error processing message:", error);

View File

@@ -192,6 +192,8 @@ export function resolveGoogleGemini3ThinkingLevel(params: {
case "max":
case "xhigh":
return "HIGH";
case undefined:
break;
}
if (typeof params.thinkingBudget === "number") {
return params.thinkingBudget <= 2048 ? "LOW" : "HIGH";
@@ -214,6 +216,8 @@ export function resolveGoogleGemini3ThinkingLevel(params: {
case "max":
case "xhigh":
return "HIGH";
case undefined:
break;
}
if (typeof params.thinkingBudget !== "number") {
return undefined;

View File

@@ -132,6 +132,15 @@ describe("oxlint config", () => {
]);
});
it("enables exhaustive switch linting", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;
expect(config.rules?.["typescript/switch-exhaustiveness-check"]).toEqual([
"error",
{ considerDefaultExhaustiveForUnions: true },
]);
});
it("enables clean zero-baseline lint rules", () => {
const config = readJson(".oxlintrc.json") as OxlintConfig;

View File

@@ -1158,6 +1158,10 @@ export function renderApp(state: AppViewState) {
void loadToolsCatalog(state, agentId);
void refreshVisibleToolsEffectiveForCurrentSession(state);
return;
case "overview":
case "channels":
case "cron":
return;
}
};
const refreshAgentsPanelSupplementalData = (panel: AppViewState["agentsPanel"]) => {

View File

@@ -323,6 +323,10 @@ async function refreshAgentsTab(host: SettingsHost, app: SettingsAppHost) {
case "cron":
void loadCron(host);
return;
case "overview":
case "tools":
case undefined:
return;
}
}