Skip to content

Commit b441005

Browse files
authored
chore: fmt (#66)
* chore: fmt * chore: migrate to oxfmt and oxlint * chore: bump version
1 parent 169d85a commit b441005

29 files changed

Lines changed: 363 additions & 498 deletions

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,13 @@ Bundle:
3232

3333
`bun run build`
3434

35-
**NOTE**: The following tasks use Deno as it excels at these and Bun does not
36-
currently provide such functionality:
37-
3835
Format:
3936

40-
`deno fmt`
37+
`bunx oxfmt`
4138

4239
Lint:
4340

44-
`deno lint src/ tests/`
41+
`bunx oxlint index.ts src/ tests/`
4542

4643
## Functional Tests
4744

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en" data-theme="light">
33
<head>
44
<meta charset="UTF-8" />

package.json

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,33 @@
11
{
22
"name": "@mpeggroup/mpeg-sdl-editor",
3+
"version": "1.4.2",
34
"description": "ISO/IEC 14496-34 Syntactic Description Language (MPEG SDL) web based editor",
4-
"homepage": "https://github.com/MPEGGroup/mpeg-sdl-editor#readme",
5-
"repository": {
6-
"type": "git",
7-
"url": "git+https://github.com/MPEGGroup/mpeg-sdl-editor.git"
8-
},
9-
"license": "MIT",
105
"keywords": [
116
"bun",
7+
"editor",
128
"mpeg",
13-
"sdl",
149
"parser",
15-
"editor"
10+
"sdl"
1611
],
17-
"type": "module",
18-
"version": "1.4.2",
19-
"scripts": {
20-
"build": "bun build.ts"
12+
"homepage": "https://github.com/MPEGGroup/mpeg-sdl-editor#readme",
13+
"license": "MIT",
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/MPEGGroup/mpeg-sdl-editor.git"
2117
},
18+
"type": "module",
2219
"publishConfig": {
2320
"access": "public"
2421
},
25-
"devDependencies": {
26-
"@happy-dom/global-registrator": "20.9.0",
27-
"@testing-library/dom": "10.4.1",
28-
"@testing-library/react": "16.3.2",
29-
"@types/bun": "1.3.14",
30-
"bun-plugin-tailwind": "0.1.2",
31-
"happy-dom": "20.9.0"
32-
},
33-
"peerDependencies": {
34-
"typescript": "6.0.3",
35-
"@types/react": "19.2.15",
36-
"@types/react-dom": "19.2.3"
22+
"scripts": {
23+
"build": "bun build.ts"
3724
},
3825
"dependencies": {
3926
"@codemirror/language": "6.12.1",
4027
"@codemirror/lint": "6.9.2",
4128
"@lezer/common": "1.5.0",
4229
"@lezer/highlight": "1.2.3",
43-
"@mpeggroup/mpeg-sdl-parser": "4.1.2",
30+
"@mpeggroup/mpeg-sdl-parser": "4.1.4",
4431
"@types/wicg-file-system-access": "2023.10.7",
4532
"@uiw/codemirror-theme-vscode": "4.25.10",
4633
"@uiw/react-codemirror": "4.25.10",
@@ -49,6 +36,19 @@
4936
"react-dom": "19.2.6",
5037
"tailwindcss": "4.3.0"
5138
},
39+
"devDependencies": {
40+
"@happy-dom/global-registrator": "20.9.0",
41+
"@testing-library/dom": "10.4.1",
42+
"@testing-library/react": "16.3.2",
43+
"@types/bun": "1.3.14",
44+
"bun-plugin-tailwind": "0.1.2",
45+
"happy-dom": "20.9.0"
46+
},
47+
"peerDependencies": {
48+
"@types/react": "19.2.15",
49+
"@types/react-dom": "19.2.3",
50+
"typescript": "6.0.3"
51+
},
5252
"overrides": {
5353
"@codemirror/language": "6.12.1",
5454
"@codemirror/lint": "6.9.2",

src/App.tsx

Lines changed: 29 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
import {
2-
SemanticError,
3-
SemanticWarning,
4-
SyntaxError,
5-
} from "@mpeggroup/mpeg-sdl-parser";
1+
import { SemanticError, SemanticWarning, SyntaxError } from "@mpeggroup/mpeg-sdl-parser";
62
import { Editor } from "./components/Editor.tsx";
73
import type { EditorRef } from "./components/Editor.tsx";
84
import { Navbar } from "./components/Navbar.tsx";
@@ -36,12 +32,9 @@ function getInitialCodeFromHash(): string | null {
3632
}
3733

3834
export function App() {
39-
const defaultCode =
40-
"// Start typing your SDL here... <Ctrl+Space> for completions\n";
35+
const defaultCode = "// Start typing your SDL here... <Ctrl+Space> for completions\n";
4136

42-
const [code, setCodeInternal] = useState<string>(
43-
() => getInitialCodeFromHash() ?? defaultCode,
44-
);
37+
const [code, setCodeInternal] = useState<string>(() => getInitialCodeFromHash() ?? defaultCode);
4538

4639
const setCode = useCallback((newCode: string) => {
4740
setCodeInternal(newCode);
@@ -62,34 +55,29 @@ export function App() {
6255
const isMobile = useMobileDetection();
6356
const [isSettingsShown, setSettingsShown] = useState(false);
6457
const { rulerWidth, setRulerWidth } = useRulerWidth();
65-
const { autoDisplayCompletions, setAutoDisplayCompletions } =
66-
useAutoDisplayCompletions();
58+
const { autoDisplayCompletions, setAutoDisplayCompletions } = useAutoDisplayCompletions();
6759
const { enableLinting, setEnableLinting } = useEnableLinting();
6860
const { showSyntaxErrors, setShowSyntaxErrors } = useShowSyntaxErrors();
6961
const { showSemanticErrors, setShowSemanticErrors } = useShowSemanticErrors();
70-
const { showSemanticWarnings, setShowSemanticWarnings } =
71-
useShowSemanticWarnings();
72-
const [cursorPosition, setCursorPosition] = useState<
73-
{ line: number; col: number }
74-
>({ line: 1, col: 1 });
62+
const { showSemanticWarnings, setShowSemanticWarnings } = useShowSemanticWarnings();
63+
const [cursorPosition, setCursorPosition] = useState<{ line: number; col: number }>({
64+
line: 1,
65+
col: 1,
66+
});
7567
const editorRef = useRef<EditorRef>(null);
7668

77-
const onCursorChange = useCallback(
78-
(position: { line: number; col: number }) => {
79-
setCursorPosition((prev) => {
80-
// Only update if position actually changed
81-
if (prev.line !== position.line || prev.col !== position.col) {
82-
return position;
83-
}
84-
return prev;
85-
});
86-
},
87-
[],
88-
);
69+
const onCursorChange = useCallback((position: { line: number; col: number }) => {
70+
setCursorPosition((prev) => {
71+
// Only update if position actually changed
72+
if (prev.line !== position.line || prev.col !== position.col) {
73+
return position;
74+
}
75+
return prev;
76+
});
77+
}, []);
8978
const handleShare = useCallback(async () => {
9079
const encoded = btoa(code);
91-
const url =
92-
`${globalThis.location.origin}${globalThis.location.pathname}#c=${encoded}`;
80+
const url = `${globalThis.location.origin}${globalThis.location.pathname}#c=${encoded}`;
9381
try {
9482
await navigator.clipboard.writeText(url);
9583
showToast("URL copied!");
@@ -98,11 +86,7 @@ export function App() {
9886
}
9987
}, [code, showToast]);
10088

101-
const {
102-
handleSave,
103-
handleLoad,
104-
handleCopy,
105-
} = useFileOperations({
89+
const { handleSave, handleLoad, handleCopy } = useFileOperations({
10690
code,
10791
setCode,
10892
showToast,
@@ -113,9 +97,7 @@ export function App() {
11397
const characterCount = useMemo(() => code.length, [code]);
11498
const [syntaxErrors, setSyntaxErrors] = useState<SyntaxError[]>([]);
11599
const [semanticErrors, setSemanticErrors] = useState<SemanticError[]>([]);
116-
const [semanticWarnings, setSemanticWarnings] = useState<SemanticWarning[]>(
117-
[],
118-
);
100+
const [semanticWarnings, setSemanticWarnings] = useState<SemanticWarning[]>([]);
119101

120102
const onSyntaxErrorChange = useCallback((newErrors: SyntaxError[]) => {
121103
setSyntaxErrors(newErrors);
@@ -125,24 +107,15 @@ export function App() {
125107
setSemanticErrors(newErrors);
126108
}, []);
127109

128-
const onSemanticWarningChange = useCallback(
129-
(newErrors: SemanticWarning[]) => {
130-
setSemanticWarnings(newErrors);
131-
},
132-
[],
133-
);
110+
const onSemanticWarningChange = useCallback((newErrors: SemanticWarning[]) => {
111+
setSemanticWarnings(newErrors);
112+
}, []);
134113

135-
const syntaxErrorCount = useMemo(() => syntaxErrors.length, [
136-
syntaxErrors,
137-
]);
114+
const syntaxErrorCount = useMemo(() => syntaxErrors.length, [syntaxErrors]);
138115

139-
const semanticErrorCount = useMemo(() => semanticErrors.length, [
140-
semanticErrors,
141-
]);
116+
const semanticErrorCount = useMemo(() => semanticErrors.length, [semanticErrors]);
142117

143-
const semanticWarningCount = useMemo(() => semanticWarnings.length, [
144-
semanticWarnings,
145-
]);
118+
const semanticWarningCount = useMemo(() => semanticWarnings.length, [semanticWarnings]);
146119

147120
const { handlePrettify } = usePrettier({
148121
code,
@@ -251,8 +224,8 @@ export function App() {
251224
toastState.type === "success"
252225
? "alert-success"
253226
: toastState.type === "warning"
254-
? "alert-warning"
255-
: "alert-error"
227+
? "alert-warning"
228+
: "alert-error"
256229
}`}
257230
>
258231
<span>{toastState.message}</span>

src/codemirror/ruler.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const baseTheme = EditorView.baseTheme({
77
});
88

99
const rulerWidth = Facet.define<number, number>({
10-
combine: (values) => values.length ? Math.min(...values) : 10,
10+
combine: (values) => (values.length ? Math.min(...values) : 10),
1111
});
1212

1313
const showRuler = ViewPlugin.fromClass(
@@ -38,9 +38,7 @@ const showRuler = ViewPlugin.fromClass(
3838
const defaultCharacterWidth = view.defaultCharacterWidth;
3939
const gutterWidth = view.contentDOM.getBoundingClientRect().x;
4040

41-
this.rulerDiv.style.left = `${
42-
gutterWidth + (column * defaultCharacterWidth) + 6
43-
}px`;
41+
this.rulerDiv.style.left = `${gutterWidth + column * defaultCharacterWidth + 6}px`;
4442
}
4543

4644
destroy() {
@@ -50,9 +48,5 @@ const showRuler = ViewPlugin.fromClass(
5048
);
5149

5250
export function ruler(column: number): Extension {
53-
return [
54-
baseTheme,
55-
rulerWidth.of(column),
56-
showRuler,
57-
];
51+
return [baseTheme, rulerWidth.of(column), showRuler];
5852
}

src/components/DesktopPanels.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,15 @@ export function DesktopPanels({
4444
? "bg-primary-content h-16"
4545
: "group-hover:bg-base-content/50 group-hover:h-16"
4646
}`}
47-
>
48-
</div>
47+
></div>
4948
</div>
5049
</div>
5150
)}
5251

5352
{/* Right panel - only show when not collapsed */}
5453

5554
{isSettingsShown && (
56-
<div
57-
className="flex flex-col"
58-
style={{ width: `${Math.max(100 - splitPercentage, 5)}%` }}
59-
>
55+
<div className="flex flex-col" style={{ width: `${Math.max(100 - splitPercentage, 5)}%` }}>
6056
{rightChild}
6157
</div>
6258
)}

0 commit comments

Comments
 (0)