From 7ace643ea48dbbf9ae8a05be7f57dc9c61b92768 Mon Sep 17 00:00:00 2001 From: SuperKali Date: Mon, 15 Dec 2025 09:13:43 +0100 Subject: [PATCH] Fix ESLint errors and use static liblzma linking - Add src-tauri/target to ESLint ignore list - Fix React hooks lint warnings with eslint-disable comments - Replace xz2 with liblzma using static feature to fix macOS code signature mismatch when using ad-hoc signing --- eslint.config.js | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/decompress.rs | 2 +- src/components/BoardModal.tsx | 7 +++-- src/components/DeviceModal.tsx | 4 ++- .../FlashProgress/FlashStageIcon.tsx | 1 + src/components/FlashProgress/index.tsx | 29 ++++++++++--------- src/components/ManufacturerModal.tsx | 1 + 8 files changed, 28 insertions(+), 20 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index 5e6b472..34d5d99 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -6,7 +6,7 @@ import tseslint from 'typescript-eslint' import { defineConfig, globalIgnores } from 'eslint/config' export default defineConfig([ - globalIgnores(['dist']), + globalIgnores(['dist', 'src-tauri/target']), { files: ['**/*.{ts,tsx}'], extends: [ diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index de2cd59..10a8b6b 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -18,7 +18,7 @@ serde_json = "1" tokio = { version = "1", features = ["full"] } reqwest = { version = "0.12", default-features = false, features = ["json", "stream", "rustls-tls"] } futures-util = "0.3" -xz2 = "0.1" +liblzma = { version = "0.4", features = ["static"] } sha2 = "0.10" hex = "0.4" dirs = "5" diff --git a/src-tauri/src/decompress.rs b/src-tauri/src/decompress.rs index f0c9401..4250e9b 100644 --- a/src-tauri/src/decompress.rs +++ b/src-tauri/src/decompress.rs @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf}; use std::process::Command; use std::sync::atomic::Ordering; use std::sync::Arc; -use xz2::bufread::XzDecoder; +use liblzma::read::XzDecoder; use crate::config; use crate::download::DownloadState; diff --git a/src/components/BoardModal.tsx b/src/components/BoardModal.tsx index e454d2d..622567e 100644 --- a/src/components/BoardModal.tsx +++ b/src/components/BoardModal.tsx @@ -31,20 +31,23 @@ export function BoardModal({ isOpen, onClose, onSelect, manufacturer }: BoardMod ); useEffect(() => { + // eslint-disable-next-line react-hooks/set-state-in-effect -- Reset state when manufacturer changes setSearch(''); setImagesReady(false); }, [manufacturer]); // Pre-load images for current manufacturer useEffect(() => { - if (!isOpen || !manufacturer || !boards) return; + const manufacturerId = manufacturer?.id; + if (!isOpen || !manufacturerId || !boards) return; const manufacturerBoards = boards.filter((board) => { const mfr = getManufacturer(board.slug, board.name); - return mfr === manufacturer.id; + return mfr === manufacturerId; }); if (manufacturerBoards.length === 0) { + // eslint-disable-next-line react-hooks/set-state-in-effect -- Early return case setImagesReady(true); return; } diff --git a/src/components/DeviceModal.tsx b/src/components/DeviceModal.tsx index ccba863..3d608a7 100644 --- a/src/components/DeviceModal.tsx +++ b/src/components/DeviceModal.tsx @@ -145,8 +145,10 @@ export function DeviceModal({ isOpen, onClose, onSelect }: DeviceModalProps) { // Update devices only when they actually change useEffect(() => { - if (rawDevices && devicesChanged(prevDevicesRef.current, rawDevices)) { + if (!rawDevices) return; + if (devicesChanged(prevDevicesRef.current, rawDevices)) { prevDevicesRef.current = rawDevices; + // eslint-disable-next-line react-hooks/set-state-in-effect -- Sync external data to state setDevices(sortDevices(rawDevices)); } }, [rawDevices]); diff --git a/src/components/FlashProgress/FlashStageIcon.tsx b/src/components/FlashProgress/FlashStageIcon.tsx index c82c17c..6d1e745 100644 --- a/src/components/FlashProgress/FlashStageIcon.tsx +++ b/src/components/FlashProgress/FlashStageIcon.tsx @@ -41,6 +41,7 @@ export function FlashStageIcon({ stage, size = 32 }: FlashStageIconProps) { } } +// eslint-disable-next-line react-refresh/only-export-components export function getStageKey(stage: FlashStage): string { switch (stage) { case 'authorizing': diff --git a/src/components/FlashProgress/index.tsx b/src/components/FlashProgress/index.tsx index 38be854..7457802 100644 --- a/src/components/FlashProgress/index.tsx +++ b/src/components/FlashProgress/index.tsx @@ -58,20 +58,6 @@ export function FlashProgress({ } } - useEffect(() => { - if (hasStartedRef.current) return; - hasStartedRef.current = true; - - loadBoardImage(); - handleAuthorization(); - - return () => { - if (intervalRef.current) { - clearInterval(intervalRef.current); - } - }; - }, []); - async function loadBoardImage() { try { const url = await getBoardImageUrl(board.slug); @@ -107,6 +93,21 @@ export function FlashProgress({ } } + useEffect(() => { + if (hasStartedRef.current) return; + hasStartedRef.current = true; + + loadBoardImage(); + handleAuthorization(); + + return () => { + if (intervalRef.current) { + clearInterval(intervalRef.current); + } + }; + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); + async function handleCustomImage(customPath: string) { try { const needsDecompress = await checkNeedsDecompression(customPath); diff --git a/src/components/ManufacturerModal.tsx b/src/components/ManufacturerModal.tsx index 5107a5e..1226d4f 100644 --- a/src/components/ManufacturerModal.tsx +++ b/src/components/ManufacturerModal.tsx @@ -169,4 +169,5 @@ export function ManufacturerModal({ isOpen, onClose, onSelect }: ManufacturerMod } // Re-export from config for backward compatibility +// eslint-disable-next-line react-refresh/only-export-components export { MANUFACTURERS, getManufacturer } from '../config';