Skip to content

Runtime: Enforce prettier formatting, simplify find-global.ts#644

Merged
kateinoigakukun merged 2 commits intoswiftwasm:mainfrom
PassiveLogic:kr/prettier-ci-and-find-global-cleanup
Feb 18, 2026
Merged

Runtime: Enforce prettier formatting, simplify find-global.ts#644
kateinoigakukun merged 2 commits intoswiftwasm:mainfrom
PassiveLogic:kr/prettier-ci-and-find-global-cleanup

Conversation

@krodak
Copy link
Member

@krodak krodak commented Feb 17, 2026

Overview

The project has prettier installed with a .prettierrc and a format script, but it isn't enforced in CI - so the Runtime source has drifted out of format over time. Swift formatting is already enforced via the format CI job; this does the same for the TypeScript side.

Two changes:

1. Simplify find-global.ts

find-global.ts has a cascade of fallbacks (globalThis -> window -> global -> self) that hasn't been touched since 2022. globalThis is available in all environments the project targets (Node 12+, all modern browsers), so the window/global/self fallbacks are dead code.

Before:

export let globalVariable: any;
if (typeof globalThis !== "undefined") {
    globalVariable = globalThis;
} else if (typeof window !== "undefined") {
    globalVariable = window;
} else if (typeof global !== "undefined") {
    globalVariable = global;
} else if (typeof self !== "undefined") {
    globalVariable = self;
}

After:

export const globalVariable: any = globalThis;

2. Apply prettier formatting, add CI check

Runs npm run format (which already existed) to bring files into compliance, then adds a prettier CI job that runs npx prettier --check Runtime/src - same pattern as the existing Swift format CI job.

Split into two commits so the formatting noise is separate from the code change.

@krodak krodak self-assigned this Feb 17, 2026
@kateinoigakukun kateinoigakukun merged commit 95a2a49 into swiftwasm:main Feb 18, 2026
12 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