Skip to content

Commit 2351552

Browse files
committed
Fix tests, linting, and formatting errors
1 parent 1fe6b36 commit 2351552

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

compiler/apps/playground/__tests__/e2e/page.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ test('editor should compile from hash successfully', async ({page}) => {
136136
path: 'test-results/01-compiles-from-hash.png',
137137
});
138138
const text =
139-
(await page.locator('.monaco-editor').nth(1).allInnerTexts()) ?? [];
139+
(await page.locator('.monaco-editor').nth(2).allInnerTexts()) ?? [];
140140
const output = await formatPrint(text);
141141

142142
expect(output).not.toEqual('');
@@ -162,7 +162,7 @@ test('reset button works', async ({page}) => {
162162
path: 'test-results/02-reset-button-works.png',
163163
});
164164
const text =
165-
(await page.locator('.monaco-editor').nth(1).allInnerTexts()) ?? [];
165+
(await page.locator('.monaco-editor').nth(2).allInnerTexts()) ?? [];
166166
const output = await formatPrint(text);
167167

168168
expect(output).not.toEqual('');
@@ -183,7 +183,7 @@ TEST_CASE_INPUTS.forEach((t, idx) =>
183183
});
184184

185185
const text =
186-
(await page.locator('.monaco-editor').nth(1).allInnerTexts()) ?? [];
186+
(await page.locator('.monaco-editor').nth(2).allInnerTexts()) ?? [];
187187
let output: string;
188188
if (t.noFormat) {
189189
output = text.join('');

compiler/apps/playground/components/Editor/ConfigEditor.tsx

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
*/
77

88
import MonacoEditor, {loader, type Monaco} from '@monaco-editor/react';
9-
import {parseConfigPragmaForTests, parsePluginOptions} from 'babel-plugin-react-compiler';
9+
import {
10+
parseConfigPragmaForTests,
11+
parsePluginOptions,
12+
} from 'babel-plugin-react-compiler';
1013
import type {editor} from 'monaco-editor';
1114
import * as monaco from 'monaco-editor';
1215
import {useState, useMemo} from 'react';
@@ -54,15 +57,22 @@ function isEqual(a: any, b: any): boolean {
5457
*/
5558
function getOverriddenValues(current: any, defaults: any): Record<string, any> {
5659
if (isEqual(current, defaults)) return {};
57-
if (current && defaults &&
58-
typeof current === 'object' && typeof defaults === 'object' &&
59-
!Array.isArray(current) && !Array.isArray(defaults)) {
60-
60+
if (
61+
current &&
62+
defaults &&
63+
typeof current === 'object' &&
64+
typeof defaults === 'object' &&
65+
!Array.isArray(current) &&
66+
!Array.isArray(defaults)
67+
) {
6168
const overrides: Record<string, any> = {};
6269

6370
for (const key in current) {
6471
const nested = getOverriddenValues(current[key], defaults[key]);
65-
if (Object.keys(nested).length > 0 || !isEqual(current[key], defaults[key])) {
72+
if (
73+
Object.keys(nested).length > 0 ||
74+
!isEqual(current[key], defaults[key])
75+
) {
6676
overrides[key] = Object.keys(nested).length > 0 ? nested : current[key];
6777
}
6878
}
@@ -88,17 +98,21 @@ function formatConfigAsJavaScript(config: any): string {
8898
if (value.length === 0) {
8999
return '[]';
90100
}
91-
const items = value.map(item => `${spaces} ${formatValue(item, indent + 1)}`).join(',\n');
101+
const items = value
102+
.map(item => `${spaces} ${formatValue(item, indent + 1)}`)
103+
.join(',\n');
92104
return `[\n${items}\n${spaces}]`;
93105
} else if (typeof value === 'object' && value !== null) {
94106
const keys = Object.keys(value);
95107
if (keys.length === 0) {
96108
return '{}';
97109
}
98-
const items = keys.map(key => {
99-
const formattedValue = formatValue(value[key], indent + 1);
100-
return `${spaces} ${key}: ${formattedValue}`;
101-
}).join(',\n');
110+
const items = keys
111+
.map(key => {
112+
const formattedValue = formatValue(value[key], indent + 1);
113+
return `${spaces} ${key}: ${formattedValue}`;
114+
})
115+
.join(',\n');
102116
return `{\n${items}\n${spaces}}`;
103117
} else {
104118
return String(value);
@@ -110,7 +124,7 @@ function formatConfigAsJavaScript(config: any): string {
110124
}
111125

112126
export default function ConfigEditor(): JSX.Element {
113-
const [monaco, setMonaco] = useState<Monaco | null>(null);
127+
const [, setMonaco] = useState<Monaco | null>(null);
114128
const store = useStore();
115129

116130
// Parse current config from source pragma and show only overridden values
@@ -125,7 +139,7 @@ export default function ConfigEditor(): JSX.Element {
125139
const overrides = getOverriddenValues(parsedConfig, DEFAULT_CONFIG);
126140

127141
return overrides;
128-
} catch (error) {
142+
} catch (_) {
129143
// If parsing fails, return empty object (no overrides)
130144
return {};
131145
}

0 commit comments

Comments
 (0)