6
6
*/
7
7
8
8
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' ;
10
13
import type { editor } from 'monaco-editor' ;
11
14
import * as monaco from 'monaco-editor' ;
12
15
import { useState , useMemo } from 'react' ;
@@ -54,15 +57,22 @@ function isEqual(a: any, b: any): boolean {
54
57
*/
55
58
function getOverriddenValues ( current : any , defaults : any ) : Record < string , any > {
56
59
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
+ ) {
61
68
const overrides : Record < string , any > = { } ;
62
69
63
70
for ( const key in current ) {
64
71
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
+ ) {
66
76
overrides [ key ] = Object . keys ( nested ) . length > 0 ? nested : current [ key ] ;
67
77
}
68
78
}
@@ -88,17 +98,21 @@ function formatConfigAsJavaScript(config: any): string {
88
98
if ( value . length === 0 ) {
89
99
return '[]' ;
90
100
}
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' ) ;
92
104
return `[\n${ items } \n${ spaces } ]` ;
93
105
} else if ( typeof value === 'object' && value !== null ) {
94
106
const keys = Object . keys ( value ) ;
95
107
if ( keys . length === 0 ) {
96
108
return '{}' ;
97
109
}
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' ) ;
102
116
return `{\n${ items } \n${ spaces } }` ;
103
117
} else {
104
118
return String ( value ) ;
@@ -110,7 +124,7 @@ function formatConfigAsJavaScript(config: any): string {
110
124
}
111
125
112
126
export default function ConfigEditor ( ) : JSX . Element {
113
- const [ monaco , setMonaco ] = useState < Monaco | null > ( null ) ;
127
+ const [ , setMonaco ] = useState < Monaco | null > ( null ) ;
114
128
const store = useStore ( ) ;
115
129
116
130
// Parse current config from source pragma and show only overridden values
@@ -125,7 +139,7 @@ export default function ConfigEditor(): JSX.Element {
125
139
const overrides = getOverriddenValues ( parsedConfig , DEFAULT_CONFIG ) ;
126
140
127
141
return overrides ;
128
- } catch ( error ) {
142
+ } catch ( _ ) {
129
143
// If parsing fails, return empty object (no overrides)
130
144
return { } ;
131
145
}
0 commit comments