Skip to content

Runtime: Fix lint issues in compiled output#650

Merged
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom
PassiveLogic:kr/runtime-lint-fixes
Feb 18, 2026
Merged

Runtime: Fix lint issues in compiled output#650
kateinoigakukun merged 1 commit intoswiftwasm:mainfrom
PassiveLogic:kr/runtime-lint-fixes

Conversation

@krodak
Copy link
Member

@krodak krodak commented Feb 18, 2026

Overview

This is a proposal - totally fine to reject and close if these aren't worth maintaining.

The compiled runtime.mjs has 5 issues that trip rules from @eslint/js recommended config (no-fallthrough, no-useless-assignment, no-case-declarations). All three have been in ESLint's recommended set since v9+ (the first two since v0.x/v1.x, no-useless-assignment since v9). These are in the TypeScript source and compile through to the rollup output unchanged.

1. no-fallthrough in js-value.ts

The Boolean case in decode() has a nested switch that doesn't cover all values, then falls through to the Number case. This is intentional (an invalid boolean payload gets treated as a number), but there's no annotation marking it so.

case Kind.Boolean:
    switch (payload1) {
        case 0: return false;
        case 1: return true;
    }
// falls through
case Kind.Number:

2. no-useless-assignment in index.ts (2 instances)

swjs_call_function and swjs_call_function_with_this_no_catch initialize let result = undefined then immediately reassign. In swjs_call_function, the init is never read because the catch returns early. In the no-catch variant, it's a straight reassign on the next statement.

// before
let result = undefined;
result = func.apply(obj, args);

// after
const result = func.apply(obj, args);

3. no-case-declarations in index.ts (2 instances)

The two listenMessage callbacks have const declarations in unbraced default: cases. Wrapping with {} scopes the declaration to the case block.

// before
default:
    const unknownMessage: never = message;

// after
default: {
    const unknownMessage: never = message;
}

@kateinoigakukun kateinoigakukun merged commit b10bee6 into swiftwasm:main Feb 18, 2026
20 of 24 checks passed
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.

2 participants

Comments