Skip to content

Commit 767be19

Browse files
committed
fix a lot of eslint issues, much more expansive eslint config
1 parent 235c70e commit 767be19

7 files changed

Lines changed: 99 additions & 37 deletions

File tree

emain/preload-webview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright 2025, Command Line Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
const { ipcRenderer } = require("electron");
4+
import { ipcRenderer } from "electron";
55

66
document.addEventListener("contextmenu", (event) => {
77
console.log("contextmenu event", event);

eslint.config.js

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,79 @@
33
import eslint from "@eslint/js";
44
import eslintConfigPrettier from "eslint-config-prettier";
55
import globals from "globals";
6+
import path from "node:path";
7+
import { fileURLToPath } from "node:url";
68
import tseslint from "typescript-eslint";
79

10+
const tsconfigRootDir = path.dirname(fileURLToPath(new URL(import.meta.url)));
11+
812
export default [
13+
{
14+
ignores: [
15+
"**/node_modules/**",
16+
"**/dist/**",
17+
"**/build/**",
18+
"**/make/**",
19+
"tsunami/frontend/scaffold/**",
20+
"docs/.docusaurus/**",
21+
],
22+
},
23+
24+
{
25+
files: ["frontend/**/*.{ts,tsx}", "emain/**/*.{ts,tsx}"],
26+
languageOptions: {
27+
parserOptions: {
28+
tsconfigRootDir,
29+
project: "./tsconfig.json",
30+
},
31+
},
32+
},
33+
34+
{
35+
files: ["docs/**/*.{ts,tsx}"],
36+
languageOptions: {
37+
parserOptions: { tsconfigRootDir, project: "./docs/tsconfig.json" },
38+
},
39+
},
40+
941
eslint.configs.recommended,
1042
...tseslint.configs.recommended,
1143

1244
{
13-
files: ["emain/emain.ts", "electron.vite.config.ts"],
45+
rules: {
46+
"@typescript-eslint/no-explicit-any": "off",
47+
},
48+
},
49+
50+
{
51+
files: ["emain/emain.ts", "electron.vite.config.ts", "**/*.cjs", "eslint.config.js"],
1452
languageOptions: {
1553
globals: {
1654
...globals.node,
1755
},
1856
},
1957
},
2058

59+
{
60+
files: ["**/*.js", "**/*.cjs"],
61+
rules: {
62+
"@typescript-eslint/no-require-imports": "off",
63+
},
64+
},
65+
66+
{
67+
rules: {
68+
"@typescript-eslint/no-unused-vars": "warn",
69+
"prefer-const": "warn",
70+
},
71+
},
72+
73+
{
74+
files: ["frontend/app/store/services.ts"], // or your generated dir
75+
rules: {
76+
"prefer-rest-params": "off",
77+
},
78+
},
79+
2180
eslintConfigPrettier,
2281
];

frontend/app/monaco/monaco-react.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,7 @@ type CodeEditorProps = {
2222
options: MonacoTypes.editor.IEditorOptions;
2323
};
2424

25-
export function MonacoCodeEditor({
26-
text,
27-
readonly,
28-
language,
29-
onChange,
30-
onMount,
31-
path,
32-
options,
33-
}: CodeEditorProps) {
25+
export function MonacoCodeEditor({ text, readonly, language, onChange, onMount, path, options }: CodeEditorProps) {
3426
const divRef = useRef<HTMLDivElement>(null);
3527
const editorRef = useRef<MonacoTypes.editor.IStandaloneCodeEditor | null>(null);
3628
const onUnmountRef = useRef<(() => void) | null>(null);
@@ -70,7 +62,6 @@ export function MonacoCodeEditor({
7062
editorRef.current = null;
7163
};
7264
// mount/unmount only
73-
// eslint-disable-next-line react-hooks/exhaustive-deps
7465
}, []);
7566

7667
useEffect(() => {
@@ -160,7 +151,6 @@ export function MonacoDiffViewer({ original, modified, language, path, options }
160151
modifiedModel.dispose();
161152
diffRef.current = null;
162153
};
163-
// eslint-disable-next-line react-hooks/exhaustive-deps
164154
}, []);
165155

166156
useEffect(() => {

frontend/app/view/term/osc-handlers.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
// Copyright 2026, Command Line Inc.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
import type { BlockNodeModel } from "@/app/block/blocktypes";
54
import { RpcApi } from "@/app/store/wshclientapi";
65
import { TabRpcClient } from "@/app/store/wshrpcutil";
7-
import {
8-
getApi,
9-
getBlockMetaKeyAtom,
10-
getBlockTermDurableAtom,
11-
globalStore,
12-
recordTEvent,
13-
WOS,
14-
} from "@/store/global";
6+
import { getApi, getBlockMetaKeyAtom, getBlockTermDurableAtom, globalStore, recordTEvent, WOS } from "@/store/global";
157
import * as services from "@/store/services";
168
import { base64ToString, fireAndForget, isSshConnName, isWslConnName } from "@/util/util";
179
import debug from "debug";
@@ -27,12 +19,22 @@ const Osc52MaxRawLength = 128 * 1024; // includes selector + base64 + whitespace
2719
export type ShellIntegrationStatus = "ready" | "running-command";
2820

2921
type Osc16162Command =
30-
| { command: "A"; data: {} }
22+
| { command: "A"; data: Record<string, never> }
3123
| { command: "C"; data: { cmd64?: string } }
32-
| { command: "M"; data: { shell?: string; shellversion?: string; uname?: string; integration?: boolean; omz?: boolean; comp?: string } }
24+
| {
25+
command: "M";
26+
data: {
27+
shell?: string;
28+
shellversion?: string;
29+
uname?: string;
30+
integration?: boolean;
31+
omz?: boolean;
32+
comp?: string;
33+
};
34+
}
3335
| { command: "D"; data: { exitcode?: number } }
3436
| { command: "I"; data: { inputempty?: boolean } }
35-
| { command: "R"; data: {} };
37+
| { command: "R"; data: Record<string, never> };
3638

3739
function checkCommandForTelemetry(decodedCmd: string) {
3840
if (!decodedCmd) {
@@ -271,7 +273,7 @@ export function handleOsc16162Command(data: string, blockId: string, loaded: boo
271273
const cmd: Osc16162Command = { command: commandStr, data: parsedData } as Osc16162Command;
272274
const rtInfo: ObjRTInfo = {};
273275
switch (cmd.command) {
274-
case "A":
276+
case "A": {
275277
rtInfo["shell:state"] = "ready";
276278
globalStore.set(termWrap.shellIntegrationStatusAtom, "ready");
277279
const marker = terminal.registerMarker(0);
@@ -286,6 +288,7 @@ export function handleOsc16162Command(data: string, blockId: string, loaded: boo
286288
});
287289
}
288290
break;
291+
}
289292
case "C":
290293
handleShellIntegrationCommandStart(termWrap, blockId, cmd, rtInfo);
291294
break;

frontend/types/gotypes.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ declare global {
416416
};
417417

418418
// wshrpc.CommandJobStartStreamData
419-
type CommandJobStartStreamData = {
420-
};
419+
type CommandJobStartStreamData = object;
421420

422421
// wshrpc.CommandListAllAppFilesData
423422
type CommandListAllAppFilesData = {

frontend/util/ijson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
type PathType = (string | number)[];
88

9-
var simplePathStrRe = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
9+
const simplePathStrRe = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
1010

1111
function formatPath(path: PathType): string {
1212
if (path.length == 0) {

pkg/tsgen/tsgen.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,11 @@ func generateTSTypeInternal(rtype reflect.Type, tsTypesMap map[reflect.Type]stri
190190
}
191191
var isWaveObj bool
192192
if !embedded {
193-
buf.WriteString(fmt.Sprintf("// %s\n", rtype.String()))
194193
if rtype.Implements(waveObjRType) || reflect.PointerTo(rtype).Implements(waveObjRType) {
195194
isWaveObj = true
196-
buf.WriteString(fmt.Sprintf("type %s = WaveObj & {\n", tsTypeName))
197-
} else {
198-
buf.WriteString(fmt.Sprintf("type %s = {\n", tsTypeName))
199195
}
200196
}
197+
var fieldsBuf bytes.Buffer
201198
var subTypes []reflect.Type
202199
for i := 0; i < rtype.NumField(); i++ {
203200
field := rtype.Field(i)
@@ -206,7 +203,7 @@ func generateTSTypeInternal(rtype reflect.Type, tsTypesMap map[reflect.Type]stri
206203
}
207204
if field.Anonymous {
208205
embeddedBuf, embeddedTypes := generateTSTypeInternal(field.Type, tsTypesMap, true)
209-
buf.WriteString(embeddedBuf)
206+
fieldsBuf.WriteString(embeddedBuf)
210207
subTypes = append(subTypes, embeddedTypes...)
211208
continue
212209
}
@@ -226,7 +223,7 @@ func generateTSTypeInternal(rtype reflect.Type, tsTypesMap map[reflect.Type]stri
226223
if tsTypeTag == "-" {
227224
continue
228225
}
229-
buf.WriteString(fmt.Sprintf(" %s%s: %s;\n", fieldName, optMarker, tsTypeTag))
226+
fieldsBuf.WriteString(fmt.Sprintf(" %s%s: %s;\n", fieldName, optMarker, tsTypeTag))
230227
continue
231228
}
232229
tsType, fieldSubTypes := TypeToTSType(field.Type, tsTypesMap)
@@ -237,10 +234,24 @@ func generateTSTypeInternal(rtype reflect.Type, tsTypesMap map[reflect.Type]stri
237234
if tsType == "UIContext" {
238235
optMarker = "?"
239236
}
240-
buf.WriteString(fmt.Sprintf(" %s%s: %s;\n", fieldName, optMarker, tsType))
237+
fieldsBuf.WriteString(fmt.Sprintf(" %s%s: %s;\n", fieldName, optMarker, tsType))
241238
}
242239
if !embedded {
243-
buf.WriteString("};\n")
240+
buf.WriteString(fmt.Sprintf("// %s\n", rtype.String()))
241+
if fieldsBuf.Len() == 0 && !isWaveObj {
242+
// empty struct - use "object" instead of "{}" to satisfy linter
243+
buf.WriteString(fmt.Sprintf("type %s = object;\n", tsTypeName))
244+
} else if isWaveObj {
245+
buf.WriteString(fmt.Sprintf("type %s = WaveObj & {\n", tsTypeName))
246+
buf.Write(fieldsBuf.Bytes())
247+
buf.WriteString("};\n")
248+
} else {
249+
buf.WriteString(fmt.Sprintf("type %s = {\n", tsTypeName))
250+
buf.Write(fieldsBuf.Bytes())
251+
buf.WriteString("};\n")
252+
}
253+
} else {
254+
buf.Write(fieldsBuf.Bytes())
244255
}
245256
return buf.String(), subTypes
246257
}

0 commit comments

Comments
 (0)