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
This commit is contained in:
SuperKali
2025-12-15 09:13:43 +01:00
parent e3328ada58
commit 7ace643ea4
8 changed files with 28 additions and 20 deletions

View File

@@ -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: [

View File

@@ -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"

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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]);

View File

@@ -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':

View File

@@ -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);

View File

@@ -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';