Skip to content

The swiss army knife of lossless video/audio editing

Adapt to @mifi/lint-config's switch to import-x and @eslint-react

Claudee5722862b0d5
diff --git a/.oxlintrc.json b/.oxlintrc.json
index a6d89094..5b49bd0a 100644
--- a/.oxlintrc.json
+++ b/.oxlintrc.json
@@ -23,7 +23,6 @@
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/interactive-supports-focus": "off",
"jsx-a11y/control-has-associated-label": "off",
- "react-js/no-unused-prop-types": "off",
"eslint-js/func-call-spacing": "off",
// TODO stage 2 rules from @mifi/lint-config with many findings here (count in parentheses), turned off until fixed
"unicorn-js/consistent-boolean-name": "off", // (95)
@@ -66,6 +65,8 @@
"typescript/require-await": "off", // (19)
"typescript/no-misused-promises": "off", // (121)
"typescript/no-unnecessary-boolean-literal-compare": "off", // (7)
+ "@eslint-react/use-state": "off", // (87)
+ "@eslint-react/no-forward-ref": "off", // (7)
// TODO remove the type assertions (58), then use the shared config's assertionStyle: never
"@typescript-eslint/consistent-type-assertions": [
"error",
@@ -107,7 +108,8 @@
"files": [
"script/**",
"website/**",
- "electron.vite.config.ts"
+ "electron.vite.config.ts",
+ "vitest.config.ts"
],
"rules": {
"import-js/no-extraneous-dependencies": [
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 2024639a..d5fb5123 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -249,6 +249,7 @@ function App() {
}
}, [detectedFileFormat, outFormatLocked, setFileFormat, setOutFormatLocked]);
+ // eslint-disable-next-line @eslint-react/naming-convention-ref-name -- TODO fix (new rule in @mifi/lint-config)
const previousPlaybackVolume = useRef(playbackVolume);
const toggleMuted = useCallback(() => {
setPlaybackVolume((volume) => {
@@ -2533,9 +2534,9 @@ function App() {
return (
<Theme appearance={darkMode ? 'dark' : 'light'} accentColor="cyan">
<MotionConfig reducedMotion={reducedMotion}>
- <AppContext.Provider value={appContext}>
- <SegColorsContext.Provider value={segColorsContext}>
- <UserSettingsContext.Provider value={userSettingsContext}>
+ <AppContext value={appContext}>
+ <SegColorsContext value={segColorsContext}>
+ <UserSettingsContext value={userSettingsContext}>
<div className={rootClass} style={rootStyle} id="app-root">
<TopMenu
filePath={filePath}
@@ -2877,9 +2878,9 @@ function App() {
</div>
<SwalContainer darkMode={darkMode} style={baseColorStyle} />
- </UserSettingsContext.Provider>
- </SegColorsContext.Provider>
- </AppContext.Provider>
+ </UserSettingsContext>
+ </SegColorsContext>
+ </AppContext>
</MotionConfig>
</Theme>
);
diff --git a/src/renderer/src/ErrorBoundary.tsx b/src/renderer/src/ErrorBoundary.tsx
index de7df5d6..c2a7ecf9 100644
--- a/src/renderer/src/ErrorBoundary.tsx
+++ b/src/renderer/src/ErrorBoundary.tsx
@@ -36,7 +36,6 @@ class ErrorBoundary extends Component<{ children: ReactNode }> {
);
}
- // eslint-disable-next-line react-js/destructuring-assignment
return this.props.children;
}
}
diff --git a/src/renderer/src/NoFileLoaded.tsx b/src/renderer/src/NoFileLoaded.tsx
index 361552dc..ff58e732 100644
--- a/src/renderer/src/NoFileLoaded.tsx
+++ b/src/renderer/src/NoFileLoaded.tsx
@@ -86,6 +86,7 @@ function NoFileLoaded({ mifiLink, currentCutSeg, onClick, darkMode, keyBindingBy
{mifiLink && typeof mifiLink === 'object' && 'loadUrl' in mifiLink && typeof mifiLink.loadUrl === 'string' && mifiLink.loadUrl ? (
<div style={{ position: 'relative', margin: '.3em', width: '24em', height: '8em' }}>
+ {/* eslint-disable-next-line @eslint-react/dom-no-missing-iframe-sandbox -- TODO fix (new rule in @mifi/lint-config) */}
<iframe src={`${mifiLink.loadUrl}#dark=${darkMode ? 'true' : 'false'}`} title="iframe" style={{ background: 'rgba(0,0,0,0)', border: 'none', pointerEvents: 'none', width: '100%', height: '100%', position: 'absolute', colorScheme: 'initial' }} />
{/* eslint-disable-next-line jsx-a11y/interactive-supports-focus */}
<div style={{ width: '100%', height: '100%', position: 'absolute', cursor: 'pointer' }} title={t('Open link in browser')} role="button" onClick={(e) => { e.stopPropagation(); if ('targetUrl' in mifiLink && typeof mifiLink.targetUrl === 'string') mainApi.openExternal(mifiLink.targetUrl); }} />
diff --git a/src/renderer/src/Timeline.tsx b/src/renderer/src/Timeline.tsx
index 3db4d40e..de4c8fab 100644
--- a/src/renderer/src/Timeline.tsx
+++ b/src/renderer/src/Timeline.tsx
@@ -161,6 +161,7 @@ function Timeline({
const timelineScrollerRef = useRef<HTMLDivElement>(null);
const timelineScrollerSkipEventRef = useRef<boolean>(false);
+ // eslint-disable-next-line @eslint-react/naming-convention-ref-name -- TODO fix (new rule in @mifi/lint-config)
const timelineScrollerSkipEventDebounce = useRef<() => void>(undefined);
const timelineWrapperRef = useRef<HTMLDivElement>(null);
diff --git a/src/renderer/src/components/GenericDialog.tsx b/src/renderer/src/components/GenericDialog.tsx
index 1250e33e..372496d2 100644
--- a/src/renderer/src/components/GenericDialog.tsx
+++ b/src/renderer/src/components/GenericDialog.tsx
@@ -1,5 +1,5 @@
import type { SubmitEventHandler, MouseEventHandler, ReactNode } from 'react';
-import React, { useCallback, useContext, useMemo, useRef, useState } from 'react';
+import React, { use, useCallback, useMemo, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import invariant from 'tiny-invariant';
import { FaCheckCircle, FaInfoCircle } from 'react-icons/fa';
@@ -30,7 +30,7 @@ interface GenericDialogContextValue {
const GenericDialogContext = React.createContext<GenericDialogContextValue | undefined>(undefined);
export function useGenericDialogContext() {
- const context = useContext(GenericDialogContext);
+ const context = use(GenericDialogContext);
invariant(context);
return context;
}
@@ -48,9 +48,9 @@ export default function GenericDialog({ dialog, onOpenChange }: {
<Dialog.Portal>
<Dialog.Overlay />
- <GenericDialogContext.Provider value={context}>
+ <GenericDialogContext value={context}>
{dialog != null && !dialog.isAlert && dialog.render()}
- </GenericDialogContext.Provider>
+ </GenericDialogContext>
</Dialog.Portal>
</Dialog.Root>
@@ -59,9 +59,9 @@ export default function GenericDialog({ dialog, onOpenChange }: {
<AlertDialog.Portal>
<AlertDialog.Overlay />
- <GenericDialogContext.Provider value={context}>
+ <GenericDialogContext value={context}>
{dialog != null && dialog.isAlert && dialog.render()}
- </GenericDialogContext.Provider>
+ </GenericDialogContext>
</AlertDialog.Portal>
</AlertDialog.Root>
</>
diff --git a/src/renderer/src/components/TagEditor.tsx b/src/renderer/src/components/TagEditor.tsx
index 86f8b9c8..fc080a3f 100644
--- a/src/renderer/src/components/TagEditor.tsx
+++ b/src/renderer/src/components/TagEditor.tsx
@@ -37,6 +37,7 @@ export const cancelTagEditOnEscape = (editingTag: string | undefined, setEditing
setEditingTag(undefined);
};
+// eslint-disable-next-line @eslint-react/no-unstable-default-props -- TODO fix (new rule in @mifi/lint-config)
function TagEditor({ existingTags = emptyObject, customTags = emptyObject, editingTag, setEditingTag, onTagsChange, onTagReset, addTagTitle, tagInfo, keySuggestions, canDeleteExisting, onApplyToAll, applyToAllTitle, copyFromSources = [] }: {
existingTags?: SegmentTags,
customTags?: SegmentTags | undefined,
diff --git a/src/renderer/src/contexts.ts b/src/renderer/src/contexts.ts
index fc774fac..92312946 100644
--- a/src/renderer/src/contexts.ts
+++ b/src/renderer/src/contexts.ts
@@ -1,4 +1,4 @@
-import React, { useContext } from 'react';
+import React, { use } from 'react';
import type { ColorInstance } from 'color';
import invariant from 'tiny-invariant';
@@ -43,13 +43,13 @@ export const SegColorsContext = React.createContext<SegColorsContextType | undef
export const AppContext = React.createContext<AppContextType | undefined>(undefined);
export function useAppContext() {
- const context = useContext(AppContext);
+ const context = use(AppContext);
invariant(context != null);
return context;
}
export const useSegColors = () => {
- const context = useContext(SegColorsContext);
+ const context = use(SegColorsContext);
invariant(context != null);
return context;
};
diff --git a/src/renderer/src/hooks/useKeyframes.ts b/src/renderer/src/hooks/useKeyframes.ts
index 1c9d1004..9b5cb5ce 100644
--- a/src/renderer/src/hooks/useKeyframes.ts
+++ b/src/renderer/src/hooks/useKeyframes.ts
@@ -28,6 +28,7 @@ function useKeyframes({ keyframesEnabled, filePath, commandedTime, videoStream,
}) {
const { t } = useTranslation();
+ // eslint-disable-next-line @eslint-react/naming-convention-ref-name -- TODO fix (new rule in @mifi/lint-config)
const readingKeyframesPromise = useRef<Promise<unknown>>(undefined);
const [neighbouringKeyFramesMap, setNeighbouringKeyFrames] = useState<Record<string, Frame>>({});
diff --git a/src/renderer/src/hooks/useSegmentsAutoSave.ts b/src/renderer/src/hooks/useSegmentsAutoSave.ts
index bb139ab5..6fa3f509 100644
--- a/src/renderer/src/hooks/useSegmentsAutoSave.ts
+++ b/src/renderer/src/hooks/useSegmentsAutoSave.ts
@@ -32,6 +32,7 @@ export default ({ autoSaveProjectFile, storeProjectInWorkingDir, filePath, custo
// NOTE: Could lose a save if user closes too fast, but not a big issue I think
const [debouncedSaveOperation] = useDebounce(currentSaveOperation, isDev ? 2000 : 500);
+ // eslint-disable-next-line @eslint-react/naming-convention-ref-name -- TODO fix (new rule in @mifi/lint-config)
const lastSaveOperation = useRef<typeof debouncedSaveOperation>(undefined);
useEffect(() => {
diff --git a/src/renderer/src/hooks/useUserSettings.ts b/src/renderer/src/hooks/useUserSettings.ts
index e626fce3..f4588604 100644
--- a/src/renderer/src/hooks/useUserSettings.ts
+++ b/src/renderer/src/hooks/useUserSettings.ts
@@ -1,11 +1,11 @@
-import { useContext } from 'react';
+import { use } from 'react';
import invariant from 'tiny-invariant';
import { UserSettingsContext } from '../contexts';
export default () => {
- const context = useContext(UserSettingsContext);
+ const context = use(UserSettingsContext);
invariant(context != null);
return context;
};
diff --git a/src/renderer/src/hooks/useWaveform.ts b/src/renderer/src/hooks/useWaveform.ts
index aa60cec5..4fd71498 100644
--- a/src/renderer/src/hooks/useWaveform.ts
+++ b/src/renderer/src/hooks/useWaveform.ts
@@ -107,6 +107,7 @@ export default ({ filePath, relevantTime, fileDuration, waveformEnabled, audioSt
}
// could be problematic if we spawn ffmpeg processes too often, so throttle it
+ // eslint-disable-next-line @eslint-react/web-api-no-leaked-timeout -- TODO fix (new rule in @mifi/lint-config)
await new Promise((r) => setTimeout(r, 100));
}
})();
diff --git a/src/renderer/src/hooks/useWhatChanged.ts b/src/renderer/src/hooks/useWhatChanged.ts
index 7abde41a..06ac97a3 100644
--- a/src/renderer/src/hooks/useWhatChanged.ts
+++ b/src/renderer/src/hooks/useWhatChanged.ts
@@ -3,6 +3,7 @@ import React from 'react';
// https://stackoverflow.com/questions/64997362/how-do-i-see-what-props-have-changed-in-react
export default function useWhatChanged(props: Record<string, unknown>) {
// cache the last set of props
+ // eslint-disable-next-line @eslint-react/naming-convention-ref-name -- TODO fix (new rule in @mifi/lint-config)
const prev = React.useRef(props);
React.useEffect(() => {
diff --git a/website/src/components/Home.tsx b/website/src/components/Home.tsx
index 9ea425b6..f5bd77ee 100644
--- a/website/src/components/Home.tsx
+++ b/website/src/components/Home.tsx
@@ -7,9 +7,13 @@ import { Combine, Film, Layers, ListOrdered, RefreshCw, ScanSearch, Scissors, Sq
import type { IconNode as ReactIconNode } from 'lucide-react';
import { CodeXml, Icon, Languages, Monitor, Pause, Play, Star } from 'lucide-react';
+// eslint-disable-next-line import-js/no-relative-packages -- the website uses assets from the app repo
import macAppStoreBadge from '../../../mac-app-store-badge.svg?url';
+// eslint-disable-next-line import-js/no-relative-packages -- the website uses assets from the app repo
import msStoreBadge from '../../../ms-store-badge.svg?url';
+// eslint-disable-next-line import-js/no-relative-packages -- the website uses assets from the app repo
import snapStoreBadge from '../../../snap-store-black.svg?url';
+// eslint-disable-next-line import-js/no-relative-packages -- the website uses assets from the app repo
import logo from '../../../src/renderer/src/icon.svg?url';
import type { Video } from '../images.ts';
@@ -329,7 +333,6 @@ export default function Home({ stars, release }: { stars: number, release: Relea
<div className="social-links">
{socialLinks.map(({ label, href, icon }) => (
// rel=me: see links.ts
- // eslint-disable-next-line react-js/no-invalid-html-attribute
<a key={label} href={href} rel={label === 'Mastodon' ? 'me' : undefined} title={label} aria-label={label}>
<svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" fill="currentColor">
{socialIconPaths[icon].map((d) => <path key={d} d={d} />)}