Skip to content

Commit 7fb0c67

Browse files
committed
Formatting: Apply Biome to svelte, but do prettier as well
1 parent b298ae2 commit 7fb0c67

File tree

12 files changed

+78
-71
lines changed

12 files changed

+78
-71
lines changed

biome.jsonc

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,25 @@
77
},
88
"files": {
99
"ignoreUnknown": false,
10-
"ignore": [
11-
"./dist",
12-
"*.svelte",
13-
"src/test/commentTestSamples",
14-
"src/demo/src/assets"
15-
]
10+
"ignore": ["./dist", "src/test/commentTestSamples", "src/demo/src/assets"]
1611
},
12+
"overrides": [
13+
{
14+
"include": ["*.svelte"],
15+
"linter": {
16+
"rules": {
17+
"style": {
18+
// I want to keep variables typed explicitly in some cases, like Svelte exports.
19+
"noInferrableTypes": "off",
20+
// Disable some checks so biome doesn't crash.
21+
// https://biomejs.dev/internals/language-support/#html-super-languages-support
22+
"useConst": "off",
23+
"useImportType": "off"
24+
}
25+
}
26+
}
27+
}
28+
],
1729
"formatter": {
1830
"enabled": true,
1931
"indentStyle": "space"

src/components/CodeSegmentation.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script lang="ts">
2+
import { Graphviz } from "@hpcc-js/wasm-graphviz";
23
import Parser from "web-tree-sitter";
3-
import { newCFGBuilder, type Language } from "../control-flow/cfg";
4+
import { type Language, newCFGBuilder } from "../control-flow/cfg";
45
import {
6+
type CFG,
57
mergeNodeAttrs,
68
remapNodeTargets,
7-
type CFG,
89
} from "../control-flow/cfg-defs";
910
import { simplifyCFG, trimFor } from "../control-flow/graph-ops";
10-
import { Graphviz } from "@hpcc-js/wasm-graphviz";
1111
import {
12+
type Parsers,
1213
getFirstFunction,
1314
initialize as initializeUtils,
14-
type Parsers,
1515
} from "./utils";
1616
1717
let parsers: Parsers;
@@ -70,7 +70,7 @@
7070
let legend = [...nodeColors.entries()]
7171
.map(([name, color]) => withBackground(name, color))
7272
.join("\n");
73-
return result + "\n\n\n" + legend;
73+
return `${result}\n\n\n${legend}`;
7474
}
7575
7676
type Options = { simplify: boolean; trim: boolean };

src/components/ColorSchemeEditor.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script lang="ts">
2-
import ColorPicker from "svelte-awesome-color-picker";
32
import { createEventDispatcher } from "svelte";
3+
import ColorPicker from "svelte-awesome-color-picker";
44
import {
5+
type Color,
6+
type ColorList,
7+
deserializeColorList,
58
getLightColorList,
69
serializeColorList,
7-
deserializeColorList,
8-
type ColorList,
9-
type Color,
1010
} from "../control-flow/colors";
1111
const dispatch = createEventDispatcher();
1212

src/components/Demo.svelte

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<script lang="ts">
2-
import { go } from "@codemirror/lang-go";
32
import { cpp } from "@codemirror/lang-cpp";
4-
import { python } from "@codemirror/lang-python";
3+
import { go } from "@codemirror/lang-go";
54
import { javascript } from "@codemirror/lang-javascript";
6-
import Graph from "./Graph.svelte";
7-
import type { Language } from "../control-flow/cfg";
5+
import { python } from "@codemirror/lang-python";
6+
import type { LanguageSupport } from "@codemirror/language";
87
import * as LZString from "lz-string";
9-
import Editor from "./Editor.svelte";
8+
import type { Language } from "../control-flow/cfg";
9+
import { evolve } from "../control-flow/evolve.ts";
1010
import CodeSegmentation from "./CodeSegmentation.svelte";
1111
import ColorScheme from "./ColorSchemeEditor.svelte";
12-
import { getSystemColorList, toggleTheme, isDark } from "./lightdark.ts";
13-
import type { LanguageSupport } from "@codemirror/language";
14-
import { evolve } from "../control-flow/evolve.ts";
12+
import Editor from "./Editor.svelte";
13+
import Graph from "./Graph.svelte";
14+
import { getSystemColorList, isDark, toggleTheme } from "./lightdark.ts";
1515
1616
// ADD-LANGUAGES-HERE
1717
const defaultCodeSamples: { [language in Language]?: string } = {
@@ -112,39 +112,34 @@
112112
];
113113
114114
let selection =
115-
languages[parseInt(urlParams.get("language"))] ?? languages[0];
115+
languages[Number.parseInt(urlParams.get("language"))] ?? languages[0];
116116
117117
function share() {
118118
const compressedCode = LZString.compressToEncodedURIComponent(
119119
languageCode[selection.language],
120120
);
121121
const codeName = selection.language.toLowerCase();
122-
const language = languages.findIndex((lang) => lang == selection);
122+
const language = languages.findIndex((lang) => lang === selection);
123123
const query = `?language=${language}&${codeName}=${compressedCode}`;
124-
const newUrl =
125-
window.location.protocol +
126-
"//" +
127-
window.location.host +
128-
window.location.pathname +
129-
query;
124+
const newUrl = `${window.location.protocol}//${window.location.host}${window.location.pathname}${query}`;
130125
navigator.clipboard.writeText(newUrl);
131126
window.open(newUrl, "_blank").focus();
132127
}
133128
134129
let graph: Graph;
135130
136131
function downloadString(text: string, fileType: string, fileName: string) {
137-
var blob = new Blob([text], { type: fileType });
132+
const blob = new Blob([text], { type: fileType });
138133
139-
var a = document.createElement("a");
134+
const a = document.createElement("a");
140135
a.download = fileName;
141136
a.href = URL.createObjectURL(blob);
142137
a.dataset.downloadurl = [fileType, a.download, a.href].join(":");
143138
a.style.display = "none";
144139
document.body.appendChild(a);
145140
a.click();
146141
document.body.removeChild(a);
147-
setTimeout(function () {
142+
setTimeout(() => {
148143
URL.revokeObjectURL(a.href);
149144
}, 1500);
150145
}

src/components/Editor.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<script lang="ts">
22
import type { LanguageSupport } from "@codemirror/language";
3-
import { EditorView } from "@codemirror/view";
43
import type { Extension } from "@codemirror/state";
4+
import { oneDark } from "@codemirror/theme-one-dark";
5+
import { EditorView } from "@codemirror/view";
56
import { createEventDispatcher } from "svelte";
67
import CodeMirror from "svelte-codemirror-editor";
7-
import { oneDark } from "@codemirror/theme-one-dark";
88
import { isDark } from "./lightdark.ts";
99
export let code: string;
1010
export let lang: LanguageSupport;

src/components/Graph.svelte

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<script lang="ts">
2-
import Parser from "web-tree-sitter";
3-
import { type Language } from "../control-flow/cfg";
42
import { Graphviz } from "@hpcc-js/wasm-graphviz";
5-
import {
6-
getFirstFunction,
7-
initialize as initializeUtils,
8-
type Parsers,
9-
} from "./utils";
3+
import objectHash from "object-hash";
104
import { createEventDispatcher } from "svelte";
5+
import Parser from "web-tree-sitter";
6+
import { type Language } from "../control-flow/cfg";
117
import {
128
type ColorList,
139
getLightColorList,
1410
listToScheme,
1511
} from "../control-flow/colors";
16-
import { Renderer, type RenderOptions } from "./renderer.ts";
17-
import objectHash from "object-hash";
1812
import { memoizeFunction } from "./caching.ts";
13+
import { type RenderOptions, Renderer } from "./renderer.ts";
14+
import {
15+
type Parsers,
16+
getFirstFunction,
17+
initialize as initializeUtils,
18+
} from "./utils";
1919
2020
let parsers: Parsers;
2121
let graphviz: Graphviz;

src/components/TestGraph.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script lang="ts">
2-
import { processRecord } from "./utils";
3-
import { type TestFuncRecord } from "../test/commentTestUtils";
42
import * as LZString from "lz-string";
3+
import { type TestFuncRecord } from "../test/commentTestUtils";
54
import type { RenderOptions } from "./renderer.ts";
5+
import { processRecord } from "./utils";
66
77
let ast: string = "";
88
let dot: string = "";

src/components/TestViewer.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import type { TestFuncRecord } from "../test/commentTestUtils";
44
import TestGraph from "./TestGraph.svelte";
55
import {
6-
runTest,
76
type TestResults,
87
initialize as initializeUtils,
8+
runTest,
99
} from "./utils";
1010
1111
const testRecords = testRecordsJson as TestFuncRecord[];

src/components/WebviewRenderer.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script lang="ts">
2-
import Parser, { type SyntaxNode } from "web-tree-sitter";
3-
import { functionNodeTypes, type Language } from "../control-flow/cfg";
42
import { Graphviz } from "@hpcc-js/wasm-graphviz";
5-
import { initialize as initializeUtils, type Parsers } from "./utils";
3+
import objectHash from "object-hash";
64
import { createEventDispatcher } from "svelte";
5+
import Parser, { type SyntaxNode } from "web-tree-sitter";
6+
import { type Language, functionNodeTypes } from "../control-flow/cfg";
77
import { type ColorList, getLightColorList } from "../control-flow/colors";
8-
import { Renderer, type RenderOptions } from "./renderer.ts";
98
import { memoizeFunction } from "./caching.ts";
10-
import objectHash from "object-hash";
9+
import { type RenderOptions, Renderer } from "./renderer.ts";
10+
import { type Parsers, initialize as initializeUtils } from "./utils";
1111
1212
type CodeAndOffset = { code: string; offset: number; language: Language };
1313

src/demo/src/App.svelte

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script lang="ts">
2+
import { onDestroy } from "svelte";
23
import Demo from "../../components/Demo.svelte";
3-
import demoCodeGo from "./assets/demo.go?raw";
4+
import { isDark } from "../../components/lightdark";
5+
import type { Language } from "../../control-flow/cfg.ts";
46
import demoCodeC from "./assets/demo.c?raw";
5-
import demoCodePython from "./assets/demo.py?raw";
67
import demoCodeCpp from "./assets/demo.cpp?raw";
8+
import demoCodeGo from "./assets/demo.go?raw";
9+
import demoCodePython from "./assets/demo.py?raw";
710
import demoCodeTypeScript from "./assets/demo.ts?raw";
8-
import { isDark } from "../../components/lightdark";
9-
import { onDestroy } from "svelte";
10-
import type { Language } from "../../control-flow/cfg.ts";
1111
1212
document.body.dataset.theme = isDark ? "dark" : "light";
1313

0 commit comments

Comments
 (0)