Skip to content

Commit 3780932

Browse files
committed
fix(repl): fix ESLint errors for CI compliance
- Add Apache 2.0 license headers to all source files - Fix import ordering and sort-imports issues - Change type aliases to interfaces where required - Add eslint-disable for browser APIs (BroadcastChannel, localStorage) falsely flagged as unsupported Node.js features - Fix missing .js file extension in import
1 parent c3870f4 commit 3780932

File tree

8 files changed

+44
-7
lines changed

8 files changed

+44
-7
lines changed

packages/repl/postcss.config.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
15
export default {
26
plugins: {
37
'@tailwindcss/postcss': {},

packages/repl/src/console/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
15
export type ConsoleLevel = 'log' | 'warn' | 'error' | 'info' | 'debug';
26
export type ConsoleSource = 'main-thread' | 'background';
37

packages/repl/src/console/useConsole.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
1-
import { useState, useEffect, useRef, useCallback } from 'react';
2-
import type { ConsoleEntry, ConsoleMessage } from './types.js';
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
5+
import { useCallback, useEffect, useRef, useState } from 'react';
6+
37
import { CHANNEL_PREFIX } from './console-wrapper.js';
8+
import type { ConsoleEntry, ConsoleMessage } from './types.js';
49

510
export function useConsole(sessionId: string) {
611
const [entries, setEntries] = useState<ConsoleEntry[]>([]);
712
const idRef = useRef(0);
813

914
useEffect(() => {
15+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- BroadcastChannel is a browser API, not Node.js
1016
if (typeof BroadcastChannel === 'undefined') {
1117
return;
1218
}
19+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- BroadcastChannel is a browser API, not Node.js
1320
let channel: BroadcastChannel;
1421
try {
22+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- BroadcastChannel is a browser API, not Node.js
1523
channel = new BroadcastChannel(CHANNEL_PREFIX + sessionId);
1624
} catch {
1725
return;

packages/repl/src/env.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
15
declare module '*.txt?raw' {
26
const content: string;
37
export default content;

packages/repl/src/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
15
import '@lynx-js/web-core';
26
import '@lynx-js/web-core/index.css';
37
import '@lynx-js/web-elements/index.css';
@@ -6,6 +10,7 @@ import '@lynx-js/web-elements/all';
610
import './globals.css';
711

812
import { createRoot } from 'react-dom/client';
9-
import { App } from './App';
13+
14+
import { App } from './App.js';
1015

1116
createRoot(document.getElementById('app')!).render(<App />);

packages/repl/src/local-storage.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
15
const STORAGE_KEY = 'lynx-repl-code';
26

3-
type CodeState = {
7+
interface CodeState {
48
mainThread: string;
59
background: string;
610
css: string;
7-
};
11+
}
812

913
export function saveToLocalStorage(code: CodeState): void {
1014
try {
15+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- localStorage is a browser API, not Node.js
1116
localStorage.setItem(STORAGE_KEY, JSON.stringify(code));
1217
} catch {
1318
// Silently ignore quota errors
@@ -16,6 +21,7 @@ export function saveToLocalStorage(code: CodeState): void {
1621

1722
export function loadFromLocalStorage(): CodeState | null {
1823
try {
24+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- localStorage is a browser API, not Node.js
1925
const raw = localStorage.getItem(STORAGE_KEY);
2026
if (!raw) return null;
2127
const parsed = JSON.parse(raw) as CodeState;
@@ -34,6 +40,7 @@ export function loadFromLocalStorage(): CodeState | null {
3440

3541
export function clearLocalStorage(): void {
3642
try {
43+
// eslint-disable-next-line n/no-unsupported-features/node-builtins -- localStorage is a browser API, not Node.js
3744
localStorage.removeItem(STORAGE_KEY);
3845
} catch {
3946
// Silently ignore

packages/repl/src/url-state.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
// Copyright 2026 The Lynx Authors. All rights reserved.
2+
// Licensed under the Apache License Version 2.0 that can be found in the
3+
// LICENSE file in the root directory of this source tree.
4+
15
import { samples } from './samples.js';
26

3-
export type CodeState = {
7+
export interface CodeState {
48
mainThread: string;
59
background: string;
610
css: string;
7-
};
11+
}
812

913
type InitialState =
1014
| { type: 'custom'; code: CodeState }

packages/repl/src/utils/cn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Copyright 2026 The Lynx Authors. All rights reserved.
22
// Licensed under the Apache License Version 2.0 that can be found in the
33
// LICENSE file in the root directory of this source tree.
4+
45
import { clsx } from 'clsx';
56
import type { ClassValue } from 'clsx';
67
import { twMerge } from 'tailwind-merge';

0 commit comments

Comments
 (0)