Skip to content

[Story] Modernize outdated language idioms in TypeScript, browser JavaScript and Python #56

Done

Description

@aMonteSl

As a developer reading or extending the code,
I want pieces written with outdated idioms rewritten in the current idiomatic form of their language,
so that the code base reads consistently, uses the language's safer constructs, and new contributors do not copy old patterns.

Context

Requested by the maintainer on 2026-11-25 as an extension of epic #26. The code base grew over several years, so some files still use patterns that newer language features replace.

Scope

  1. Inventory first (docs/cleanup/modernization.md): for each idiom, the count, the files and the modern replacement, measured with a script so the number can be re-run.
    • TS:
      • require() where a static import works (the eight load-bearing lazy require() in ModularTreeDataProvider stay);
      • promise chains and callback APIs where async/await or fs.promises apply;
      • var;
      • namespace;
      • string concatenation where template literals belong;
      • index loops where for…of or array methods fit;
      • optional-chaining or nullish candidates;
      • avoidable any and casts.
    • Browser JS under templates/:
      • var;
      • prototype-based classes;
      • IIFE module patterns where the load order allows;
      • arguments;
      • manual DOM loops.
    • Python:
  2. The rewrite:
    • one commit per idiom per area;
    • behaviour-neutral, each change covered by existing tests or a characterization test landed first;
    • where it can catch a regression, an ESLint or ruff rule stops the old idiom from coming back.

Out of scope

  • Anything the cleanup skill marks load-bearing.
  • The XR field-schema contract.
  • Formatter-style churn: no blanket reformatting.

Acceptance criteria

Activity

  1. added
    tfm
    user-story
    on Nov 25, 2026
  2. self-assigned this
    on Nov 25, 2026
  3. added 3 commits that reference this issue on Nov 25, 2026
  4. aMonteSl commented on Nov 25, 2026

    @aMonteSl
    CollaboratorAuthor

    Part A (Python and standalone browser runtimes) merged into v1.2.1 via #62, with CI green on Linux, Windows and macOS.

    • Python: old-style typing generics 310 → 12 (the rest are contract or test-pinned), and ruff now enforces the modern idioms with target-version = "py37".
    • Standalone runtimes: var 289 → 0, with no-var across all linted template scripts. The 9 multi-part runtimes (2,014 var) are deferred to 1.3.0, as recorded in docs/cleanup/modernization.md.
    • Found for 1.3.0: the backend Python tests need Python 3.10+, while backend/src targets 3.7.

    The TypeScript part follows next.


    Generated by Claude Code

  5. added a commit that references this issue on Nov 25, 2026
  6. aMonteSl commented on Nov 25, 2026

    @aMonteSl
    CollaboratorAuthor

    Done. Part B (TypeScript) is merged into v1.2.1 via #64, with CI green on Linux, Windows and macOS. Part A (Python and browser runtimes) merged earlier via #62.

    TypeScript, per row of docs/cleanup/modernization.md §5:

    • Idioms already at zero are now locked by lint rules.
    • Inline require() of Node built-ins: 7 → 0.
    • substr: 1 → 0.
    • a && a.b: 10 → 0.
    • Template literals: 8 concatenations → 0. The generated SSE script is byte-identical.
    • any: 130 → 84. These commits change types only, and the production bundle stays identical. Four folders now have no-explicit-any as an error.
    • ?? for object-typed defaults: 48 converted. The || on external JSON, storage and settings is kept on purpose.
    • .then() → await: no site qualifies.
    • ESLint warning budget: 204 → 158. Every idiom is locked by its lint rule, and suppressions stay at 0.

    Deferred to 1.3.0:

    • var in the 9 multi-part browser runtimes (2,014);
    • string concatenation in templates;
    • fs.promises;
    • the remaining 84 any.

    Details are in §6 and §7 of modernization.md and in the session logs 56a-modernize-py-js.md and 56b-modernize-ts.md.


    Generated by Claude Code

  7. added
    area: extension
    area: python-backend
    area: xr-scene
    stream: cleanup-refactor
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: extensionarea: python-backendarea: xr-scenestream: cleanup-refactortfmuser-story

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions