Skip to content

Commit 95ea24a

Browse files
committed
♻️ Refactor Preact JSX handling for improved consistency
Standardize JSX configuration across the project This change improves our Preact integration by: - Removing redundant JSX pragma comments from all UI components - Updating eslint config to ignore 'h' import variable - Simplifying PreactDevEngine to remove unneeded container references - Switching from jsxImportSource to jsxFactory in tsconfig.json - Fixing test cases to align with the new implementation These changes make the codebase more consistent and reduce boilerplate while maintaining the same functionality.
1 parent 366e51d commit 95ea24a

12 files changed

+11
-30
lines changed

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const eslintConfig = [
4444
"error",
4545
{
4646
argsIgnorePattern: "^_",
47+
varsIgnorePattern: "^h$",
4748
},
4849
],
4950
},

src/common/preact-engine.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export class PreactDevEngine {
2222
private controlValues: ControlValues = {};
2323

2424
// DOM elements
25-
private containerElement: HTMLElement | null = null;
2625
private canvas: HTMLCanvasElement | null = null;
2726
private fpsValue = 0;
2827
private frameCount = 0;
@@ -57,13 +56,10 @@ export class PreactDevEngine {
5756
/**
5857
* Initialize the development environment
5958
*/
60-
public async initialize(container: HTMLElement): Promise<void> {
59+
public async initialize(): Promise<void> {
6160
// Display startup banner
6261
printStartupBanner();
6362

64-
// Store reference to the container but don't overwrite the root element
65-
this.containerElement = container;
66-
6763
// Create canvas reference
6864
this.canvas = document.getElementById("exCanvas") as HTMLCanvasElement;
6965
if (!this.canvas) {

src/dev.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ async function initializeDevEnvironment() {
4343
const engine = new PreactDevEngine();
4444

4545
try {
46-
const container = document.body;
47-
await engine.initialize(container);
46+
await engine.initialize();
4847
console.log("✨ Engine initialized successfully");
4948

5049
// Display welcome notification

src/ui/App.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx h */
2-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
import { h, FunctionComponent } from 'preact';
42
import { useState, useEffect } from 'preact/hooks';
53
import { ControlDefinition, ControlValues } from '../common/definitions';

src/ui/ControlsPanel.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx h */
2-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
import { h, FunctionComponent } from 'preact';
42
import { ControlDefinition, ControlValues } from '../common/definitions';
53
import { useState, useRef, useEffect } from 'preact/hooks';

src/ui/EffectsPanel.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx h */
2-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
import { h, FunctionComponent } from 'preact';
42
import { useEffect, useState } from 'preact/hooks';
53

src/ui/Loader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx h */
2-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
import { h, FunctionComponent } from 'preact';
42

53
interface LoaderProps {

src/ui/Notification.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx h */
2-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
import { h, FunctionComponent } from 'preact';
42
import { useEffect, useState } from 'preact/hooks';
53

src/ui/SparklingName.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** @jsx h */
21
import { h, FunctionComponent } from 'preact';
32
import { useEffect, useState } from 'preact/hooks';
43
import './sparklingName.css';

src/ui/WelcomeModal.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jsx h */
2-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
31
import { h, FunctionComponent } from 'preact';
42
import { useState } from 'preact/hooks';
53
import { SparklingName } from './SparklingName';

0 commit comments

Comments
 (0)