Skip to content

Commit 21f6357

Browse files
author
Loïc Mangeonjean
committed
chore: format all files
1 parent 505bc60 commit 21f6357

File tree

5 files changed

+31
-24
lines changed

5 files changed

+31
-24
lines changed

commitlint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default {
2-
extends: ['@codingame/commitlint-config-codingame']
3-
};
2+
extends: ['@codingame/commitlint-config-codingame']
3+
}

src/MonacoEditor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ function MonacoEditor ({
125125
onEditorOpenRequest,
126126
onDidSave = defaultOnDidSave
127127
}: MonacoEditorProps, ref: ForwardedRef<monaco.editor.IStandaloneCodeEditor>): ReactElement {
128-
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>()
129-
const modelRef = useRef<monaco.editor.ITextModel>()
128+
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor>(undefined)
129+
const modelRef = useRef<monaco.editor.ITextModel>(undefined)
130130
const [modelReady, setModelReady] = useState(false)
131131
const preventTriggerChangeEventRef = useRef<boolean>(false)
132132

@@ -193,7 +193,6 @@ function MonacoEditor ({
193193
}
194194
}
195195
return undefined
196-
// eslint-disable-next-line react-hooks/exhaustive-deps
197196
}, [])
198197

199198
// Create/Update model

src/hooks.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import deepEqual from 'deep-equal'
33
import { getConfiguration, onConfigurationChanged, monaco } from '@codingame/monaco-editor-wrapper'
44
import { StandaloneServices, IThemeService } from 'vscode/services'
55

6-
function getCurrentThemeColor (color: string): string | undefined {
6+
function getCurrentThemeColor(color: string): string | undefined {
77
const themeService = StandaloneServices.get(IThemeService)
88
return themeService.getColorTheme().getColor(color)?.toString()
99
}
1010

11-
export function useThemeColor (color: string): string | undefined {
11+
export function useThemeColor(color: string): string | undefined {
1212
const [colorValue, setColorValue] = useState(getCurrentThemeColor(color))
1313
useEffect(() => {
1414
const disposable = StandaloneServices.get(IThemeService).onDidColorThemeChange(() => {
@@ -25,7 +25,9 @@ export function useThemeColor (color: string): string | undefined {
2525
return colorValue
2626
}
2727

28-
export function useUserConfiguration (programmingLanguageId?: string): Partial<monaco.editor.IEditorOptions> {
28+
export function useUserConfiguration(
29+
programmingLanguageId?: string
30+
): Partial<monaco.editor.IEditorOptions> {
2931
const [userConfiguration, setUserConfiguration] = useState(() => getConfiguration()!)
3032
useEffect(() => {
3133
const updateOptions = () => {
@@ -39,33 +41,36 @@ export function useUserConfiguration (programmingLanguageId?: string): Partial<m
3941
return userConfiguration
4042
}
4143

42-
export function useLastValueRef<T> (value: T): MutableRefObject<T> {
44+
export function useLastValueRef<T>(value: T): MutableRefObject<T> {
4345
const ref = useRef<T>(value)
4446
ref.current = value
4547
return ref
4648
}
4749

48-
export function useLastVersion<P extends unknown[], R> (func: (...args: P) => R): (...args: P) => R {
50+
export function useLastVersion<P extends unknown[], R>(func: (...args: P) => R): (...args: P) => R {
4951
const ref = useRef<(...args: P) => R>(func)
5052
useEffect(() => {
5153
ref.current = func
5254
}, [func])
5355
return useCallback((...args: P) => {
5456
return ref.current(...args)
55-
// eslint-disable-next-line react-hooks/exhaustive-deps
5657
}, [])
5758
}
5859

59-
export function usePrevious<T> (value: T): T | undefined {
60-
const ref = useRef<T>()
60+
export function usePrevious<T>(value: T): T | undefined {
61+
const ref = useRef<T>(undefined)
6162
useEffect(() => {
6263
ref.current = value
6364
}, [value])
6465
return ref.current
6566
}
6667

67-
export function useDeepMemo<T, D extends unknown[]> (memoFn: () => T, deps: D, isEqual: (a: D, b: D) => boolean = deepEqual): T {
68-
const ref = useRef<{ deps: D, value: T }>()
68+
export function useDeepMemo<T, D extends unknown[]>(
69+
memoFn: () => T,
70+
deps: D,
71+
isEqual: (a: D, b: D) => boolean = deepEqual
72+
): T {
73+
const ref = useRef<{ deps: D; value: T }>(undefined)
6974
if (ref.current == null || !isEqual(deps, ref.current.deps)) {
7075
ref.current = { deps, value: memoFn() }
7176
}

src/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
import { loadLanguage, monaco, updateKeybindings, updateUserConfiguration } from '@codingame/monaco-editor-wrapper'
2-
import { IEditorOptions, IResolvedTextEditorModel } from '@codingame/monaco-vscode-editor-service-override'
1+
import {
2+
loadLanguage,
3+
monaco,
4+
updateKeybindings,
5+
updateUserConfiguration
6+
} from '@codingame/monaco-editor-wrapper'
7+
import {
8+
IEditorOptions,
9+
IResolvedTextEditorModel
10+
} from '@codingame/monaco-vscode-editor-service-override'
311
import type { IReference } from 'vscode/monaco'
412
import { useThemeColor, useUserConfiguration } from './hooks.js'
513
import MonacoEditor, { MonacoEditorProps } from './MonacoEditor.js'
@@ -13,9 +21,4 @@ export {
1321
updateUserConfiguration,
1422
loadLanguage
1523
}
16-
export type {
17-
MonacoEditorProps,
18-
IReference,
19-
IEditorOptions,
20-
IResolvedTextEditorModel
21-
}
24+
export type { MonacoEditorProps, IReference, IEditorOptions, IResolvedTextEditorModel }

src/style.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export function addStyle (styleString: string): void {
1+
export function addStyle(styleString: string): void {
22
const style = document.createElement('style')
33
style.textContent = styleString
44
document.head.append(style)

0 commit comments

Comments
 (0)