diff --git a/eslint.config.js b/eslint.config.js
index 6e7779c..94b1802 100644
--- a/eslint.config.js
+++ b/eslint.config.js
@@ -6,7 +6,7 @@ import react from "eslint-plugin-react";
export default tseslint.config(
eslint.configs.recommended,
- // ...tseslint.configs.recommendedTypeChecked,
+ ...tseslint.configs.recommendedTypeChecked,
{
languageOptions: {
parserOptions: {
@@ -53,7 +53,13 @@ export default tseslint.config(
}
],
"comma-spacing": "off",
- "@typescript-eslint/comma-spacing": "error"
+ "@typescript-eslint/comma-spacing": "error",
+ "@typescript-eslint/no-unused-vars": [
+ "error",
+ {
+ "argsIgnorePattern": "^_"
+ }
+ ]
},
}
);
\ No newline at end of file
diff --git a/package-lock.json b/package-lock.json
index 657d519..d4015c7 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -36,6 +36,7 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@eslint/js": "^9.2.0",
+ "@types/react-syntax-highlighter": "^15.5.13",
"@types/webpack-env": "^1.18.4",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
@@ -4623,6 +4624,15 @@
"@types/react": "*"
}
},
+ "node_modules/@types/react-syntax-highlighter": {
+ "version": "15.5.13",
+ "resolved": "https://registry.npmjs.org/@types/react-syntax-highlighter/-/react-syntax-highlighter-15.5.13.tgz",
+ "integrity": "sha512-uLGJ87j6Sz8UaBAooU0T6lWJ0dBmjZgN1PZTrj05TNql2/XpC6+4HhMT5syIdFUUt+FASfCeLLv4kBygNU+8qA==",
+ "dev": true,
+ "dependencies": {
+ "@types/react": "*"
+ }
+ },
"node_modules/@types/resolve": {
"version": "1.17.1",
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz",
diff --git a/package.json b/package.json
index 69cab35..1f8c1e6 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@eslint/js": "^9.2.0",
+ "@types/react-syntax-highlighter": "^15.5.13",
"@types/webpack-env": "^1.18.4",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
diff --git a/src/App.tsx b/src/App.tsx
index c1c98ad..3a1c720 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,11 +8,8 @@ import { SettingsManagerProvider } from "./hooks/settings/settingsManagerContext
import { ModalsView } from "./components/modals/ModalsView";
import { FC, useEffect } from "react";
import { ZIndexManagerProvider } from "./hooks/z-index/zIndexManagerContext";
-import { TrackingManager } from "./features/tracking/trackingManager";
import { ModalsManagerProvider } from "./hooks/modals/modalsManagerContext";
-TrackingManager.initialize();
-
const App: FC = () => {
useEffect(() => {
const onContextMenu = (event: Event) => {
diff --git a/src/components/actions/Actions.tsx b/src/components/actions/Actions.tsx
index c6d7f91..59e8f62 100644
--- a/src/components/actions/Actions.tsx
+++ b/src/components/actions/Actions.tsx
@@ -1,4 +1,4 @@
-import { Children, cloneElement, isValidElement, ReactElement, ReactNode } from "react";
+import { Children, cloneElement, isValidElement, ReactElement, ReactNode, Ref } from "react";
import { useShortcuts } from "../../hooks/_utils/keyboard";
import styles from "./Actions.module.css";
import { useScreenBounds } from "../../hooks/_utils/screen";
@@ -11,17 +11,17 @@ export const STYLES = {
export interface ActionProps {
actionId?: string;
label?: string;
- icon?: string|object;
+ icon?: string | object;
shortcut?: string[];
- onTrigger?: (event: Event, triggerParams: any, ...args: any[]) => void;
+ onTrigger?: (event: Event, triggerParams: unknown, ...args: unknown[]) => void;
children?: ReactNode;
}
export interface ActionsProps {
className?: string;
- onAnyTrigger?: (event: Event, triggerParams: any, ...args: any[]) => void;
+ onAnyTrigger?: (event: Event, triggerParams: unknown, ...args: unknown[]) => void;
children?: ReactNode;
- triggerParams?: any;
+ triggerParams?: unknown;
avoidTaskbar?: boolean;
}
@@ -44,7 +44,7 @@ export function Actions({ children, className, onAnyTrigger, triggerParams, avoi
const options = {};
const shortcuts = {};
- const iterateOverChildren = (children: ReactNode) => {
+ const iterateOverChildren = (children: ReactNode): ReactNode => {
let actionId = 0;
const newChildren = Children.map(children, (child) => {
if (!isValidElement(child))
@@ -52,7 +52,7 @@ export function Actions({ children, className, onAnyTrigger, triggerParams, avoi
actionId++;
- const { label, shortcut, onTrigger } = child.props;
+ const { label, shortcut, onTrigger } = child.props as ActionProps;
if (label != null && onTrigger != null) {
options[actionId] = onTrigger;
@@ -61,19 +61,18 @@ export function Actions({ children, className, onAnyTrigger, triggerParams, avoi
}
if (isListener) {
- iterateOverChildren(child.props.children);
- return;
+ return iterateOverChildren((child.props as ActionProps).children);
}
return cloneElement(child, {
...child.props,
actionId,
- children: iterateOverChildren(child.props.children),
+ children: iterateOverChildren((child.props as ActionProps).children),
onTrigger: (event, ...args) => {
onAnyTrigger?.(event, triggerParams, ...args);
onTrigger?.(event, triggerParams, ...args);
}
- });
+ } as ActionProps);
});
return newChildren;
@@ -82,7 +81,7 @@ export function Actions({ children, className, onAnyTrigger, triggerParams, avoi
useShortcuts({ options, shortcuts, useCategories: false });
if (isListener)
- return iterateOverChildren(children);
+ return iterateOverChildren(children) as ReactElement;
const classNames = [styles.Container];
if (className != null)
@@ -94,7 +93,7 @@ export function Actions({ children, className, onAnyTrigger, triggerParams, avoi
if (!initiated)
classNames.push(styles.Uninitiated);
- return
+ return
} className={classNames.join(" ")}>
{iterateOverChildren(children)}
;
}
\ No newline at end of file
diff --git a/src/components/apps/_utils/web-view/WebView.tsx b/src/components/apps/_utils/web-view/WebView.tsx
index cea90a3..899c356 100644
--- a/src/components/apps/_utils/web-view/WebView.tsx
+++ b/src/components/apps/_utils/web-view/WebView.tsx
@@ -4,6 +4,7 @@ import { WindowProps } from "../../../windows/WindowView";
interface WebViewProps extends WindowProps {
source: string;
+ title: string;
}
export const WebView: FC
= forwardRef(({ source, focus, ...props }: WebViewProps, ref) => {
diff --git a/src/components/apps/browser/Browser.tsx b/src/components/apps/browser/Browser.tsx
index afd6dfc..0e0bd2c 100644
--- a/src/components/apps/browser/Browser.tsx
+++ b/src/components/apps/browser/Browser.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from "react";
+import { ChangeEventHandler, KeyboardEventHandler, useEffect, useRef, useState } from "react";
import styles from "./Browser.module.css";
import { WebView } from "../_utils/web-view/WebView";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@@ -15,10 +15,10 @@ interface BrowserProps extends WindowProps {
export function Browser({ startUrl, focus }: BrowserProps) {
const initialUrl = startUrl ?? HOME_URL;
- const [url, setUrl] = useState(initialUrl);
+ const [url, setUrl] = useState(initialUrl);
const [input, setInput] = useState(initialUrl);
const { history, pushState, stateIndex, undo, redo, undoAvailable, redoAvailable } = useHistory(initialUrl);
- const ref = useRef(null);
+ const ref = useRef(null);
useEffect(() => {
if (history.length === 0)
@@ -34,7 +34,7 @@ export function Browser({ startUrl, focus }: BrowserProps) {
ref.current.contentWindow.location.href = url;
};
- const updateUrl = (newUrl) => {
+ const updateUrl = (newUrl: string) => {
if (url === newUrl) {
return reload();
}
@@ -44,12 +44,12 @@ export function Browser({ startUrl, focus }: BrowserProps) {
pushState(newUrl);
};
- const onInputChange = (event) => {
- setInput(event.target.value);
+ const onInputChange = (event: Event) => {
+ setInput((event.target as HTMLInputElement).value);
};
- const onKeyDown = (event) => {
- const value = event.target.value;
+ const onKeyDown = (event: KeyboardEvent) => {
+ const value = (event.target as HTMLInputElement).value;
if (event.key === "Enter" && value !== "") {
if (isValidUrl(value)) {
@@ -67,7 +67,7 @@ export function Browser({ startUrl, focus }: BrowserProps) {
title="Back"
tabIndex={0}
className={styles["Icon-button"]}
- onClick={undo}
+ onClick={() => { undo(); }}
disabled={!undoAvailable}
>
@@ -76,7 +76,7 @@ export function Browser({ startUrl, focus }: BrowserProps) {
title="Forward"
tabIndex={0}
className={styles["Icon-button"]}
- onClick={redo}
+ onClick={() => { redo(); }}
disabled={!redoAvailable}
>
@@ -103,8 +103,8 @@ export function Browser({ startUrl, focus }: BrowserProps) {
aria-label="Search bar"
className={styles["Search-bar"]}
tabIndex={0}
- onChange={onInputChange}
- onKeyDown={onKeyDown}
+ onChange={onInputChange as unknown as ChangeEventHandler}
+ onKeyDown={onKeyDown as unknown as KeyboardEventHandler}
/>
diff --git a/src/components/apps/calculator/Calculator.tsx b/src/components/apps/calculator/Calculator.tsx
index 11a2c62..b056bcc 100644
--- a/src/components/apps/calculator/Calculator.tsx
+++ b/src/components/apps/calculator/Calculator.tsx
@@ -5,9 +5,9 @@ import { WindowProps } from "../../windows/WindowView";
export function Calculator({ active }: WindowProps) {
const [input, setInput] = useState("0");
- const [firstNumber, setFirstNumber] = useState(null);
- const [secondNumber, setSecondNumber] = useState(null);
- const [operation, setOperation] = useState(null);
+ const [firstNumber, setFirstNumber] = useState
(null);
+ const [secondNumber, setSecondNumber] = useState(null);
+ const [operation, setOperation] = useState(null);
const [isIntermediate, setIsIntermediate] = useState(false);
const reset = useCallback(() => {
@@ -17,11 +17,11 @@ export function Calculator({ active }: WindowProps) {
setOperation(null);
}, []);
- const addInput = useCallback((string) => {
+ const addInput = useCallback((string: string) => {
let hasReset = false;
if (secondNumber != null) {
if (isIntermediate) {
- setFirstNumber(input);
+ setFirstNumber(parseFloat(input));
setSecondNumber(null);
setInput(null);
} else {
@@ -54,12 +54,10 @@ export function Calculator({ active }: WindowProps) {
}, [input, isIntermediate, reset, secondNumber]);
const calculate = useCallback((intermediate = false) => {
- if (firstNumber == null) {
+ if (firstNumber != null) {
+ setSecondNumber(parseFloat(input));
- } else {
- setSecondNumber(input);
-
- const a = parseFloat(firstNumber);
+ const a = firstNumber;
const b = parseFloat(input);
let result = 0;
@@ -84,11 +82,11 @@ export function Calculator({ active }: WindowProps) {
setIsIntermediate(intermediate);
}, [firstNumber, input, operation]);
- const changeOperation = useCallback((operation) => {
+ const changeOperation = useCallback((operation: string) => {
if (firstNumber != null && secondNumber == null) {
calculate(true);
} else {
- setFirstNumber(input);
+ setFirstNumber(parseFloat(input));
setSecondNumber(null);
setInput(null);
}
@@ -97,7 +95,7 @@ export function Calculator({ active }: WindowProps) {
}, [calculate, firstNumber, input, secondNumber]);
useEffect(() => {
- const onKeyDown = (event) => {
+ const onKeyDown = (event: KeyboardEvent) => {
if (!active)
return;
diff --git a/src/components/apps/file-explorer/FileExplorer.tsx b/src/components/apps/file-explorer/FileExplorer.tsx
index 3a430bc..b980c3d 100644
--- a/src/components/apps/file-explorer/FileExplorer.tsx
+++ b/src/components/apps/file-explorer/FileExplorer.tsx
@@ -1,4 +1,4 @@
-import { FC, useCallback, useEffect, useState } from "react";
+import { ChangeEventHandler, FC, KeyboardEventHandler, useCallback, useEffect, useState } from "react";
import { useVirtualRoot } from "../../../hooks/virtual-drive/virtualRootContext";
import styles from "./FileExplorer.module.css";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
@@ -40,10 +40,10 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
const virtualRoot = useVirtualRoot();
const [currentDirectory, setCurrentDirectory] = useState(virtualRoot.navigate(startPath ?? "~") as VirtualFolder);
- const [path, setPath] = useState(currentDirectory?.path ?? "");
+ const [path, setPath] = useState(currentDirectory?.path ?? "");
const windowsManager = useWindowsManager();
const [showHidden] = useState(true);
- const { history, stateIndex, pushState, undo, redo, undoAvailable, redoAvailable } = useHistory(currentDirectory.path);
+ const { history, stateIndex, pushState, undo, redo, undoAvailable, redoAvailable } = useHistory(currentDirectory.path);
const { openWindowedModal } = useWindowedModal();
const { onContextMenu: onContextMenuFile } = useContextMenu({ Actions: (props) =>
@@ -56,29 +56,29 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
}
file.open(windowsManager);
}}/>
- {
+ {
file.delete();
}}/>
- {
+ {
openWindowedModal({
title: `${file.id} ${TITLE_SEPARATOR} Properties`,
iconUrl: file.getIconUrl(),
size: new Vector2(400, 500),
- Modal: (props) =>
+ Modal: (props: object) =>
});
}}/>
});
const { onContextMenu: onContextMenuFolder } = useContextMenu({ Actions: (props) =>
- {
+ {
changeDirectory(folder.linkedPath ?? folder.name);
}}/>
- {
+ {
windowsManager.open(APPS.TERMINAL, { startPath: folder.path });
}}/>
- {
+ {
folder.delete();
}}/>
@@ -91,7 +91,7 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
// }
// });
- const changeDirectory = useCallback((path, absolute = false) => {
+ const changeDirectory = useCallback((path: string, absolute = false) => {
if (path == null)
return;
@@ -119,12 +119,12 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
}
}, [history, stateIndex, virtualRoot]);
- const onPathChange = (event) => {
- setPath(event.target.value);
+ const onPathChange = (event: Event) => {
+ setPath((event.target as HTMLInputElement).value);
};
- const onKeyDown = (event) => {
- let value = event.target.value;
+ const onKeyDown = (event: KeyboardEvent) => {
+ let value = (event.target as HTMLInputElement).value;
if (event.key === "Enter") {
if (value === "")
@@ -160,7 +160,7 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
title="Back"
tabIndex={0}
className={styles["Icon-button"]}
- onClick={undo}
+ onClick={() => { undo(); }}
disabled={!undoAvailable}
>
@@ -169,7 +169,7 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
title="Forward"
tabIndex={0}
className={styles["Icon-button"]}
- onClick={redo}
+ onClick={() => { redo(); }}
disabled={!redoAvailable}
>
@@ -215,8 +215,8 @@ export function FileExplorer({ startPath, selectorMode, Footer, onSelectionChang
aria-label="Path"
className={styles["Path-input"]}
tabIndex={0}
- onChange={onPathChange}
- onKeyDown={onKeyDown}
+ onChange={onPathChange as unknown as ChangeEventHandler}
+ onKeyDown={onKeyDown as unknown as KeyboardEventHandler}
placeholder="Enter a path..."
/>