Skip to content

The swiss army knife of lossless video/audio editing

Migrate from ESLint to oxlint (@mifi/lint-config)

Claude30eeca297845
diff --git a/.eslintignore b/.eslintignore
deleted file mode 100644
index a0566b96..00000000
--- a/.eslintignore
+++ /dev/null
@@ -1,7 +0,0 @@
-/dist
-/out
-/main-ts-dist
-/common-ts-dist
-/website/dist
-/website/.wrangler
-/website/.astro
diff --git a/.eslintrc.cjs b/.eslintrc.cjs
deleted file mode 100644
index d1a0208b..00000000
--- a/.eslintrc.cjs
+++ /dev/null
@@ -1,46 +0,0 @@
-module.exports = {
- extends: ['mifi'],
- rules: {
- 'jsx-a11y/click-events-have-key-events': 0,
- 'jsx-a11y/interactive-supports-focus': 0,
- 'jsx-a11y/control-has-associated-label': 0,
- 'react/no-unused-prop-types': 0,
- 'func-call-spacing': 0,
- },
-
- overrides: [
- {
- files: ['./src/renderer/**/*.{js,cjs,mjs,jsx,ts,tsx,mts}'],
- env: {
- node: false,
- browser: true,
- },
- rules: {
- 'no-console': 0,
- 'import/no-extraneous-dependencies': 0,
- 'unicorn/prefer-global-this': 0,
- },
- },
- {
- files: ['./src/preload/**/*.{js,cjs,jsx,ts,tsx}'],
- env: {
- browser: true,
- },
- rules: {
- 'no-console': 0,
- 'import/no-extraneous-dependencies': 0,
- 'unicorn/prefer-global-this': 0,
- },
- },
- {
- files: ['./script/**/*.{js,cjs,mjs,jsx,ts,tsx,mts}', './website/**/*.{js,cjs,mjs,jsx,ts,tsx,mts}', 'electron.vite.config.ts'],
- rules: {
- 'import/no-extraneous-dependencies': ['error', {
- devDependencies: true,
- optionalDependencies: false,
- }],
- 'no-console': 0,
- },
- },
- ],
-};
diff --git a/.oxlintrc.json b/.oxlintrc.json
new file mode 100644
index 00000000..e954b1ea
--- /dev/null
+++ b/.oxlintrc.json
@@ -0,0 +1,95 @@
+{
+ "$schema": "./node_modules/oxlint/configuration_schema.json",
+ "extends": [
+ "./node_modules/@mifi/lint-config/oxlintrc.json"
+ ],
+ "ignorePatterns": [
+ ".yarn",
+ "dist",
+ "out",
+ "main-ts-dist",
+ "common-ts-dist",
+ "website/dist",
+ "website/.wrangler",
+ "website/.astro",
+ "**/*.astro"
+ ],
+ "settings": {
+ "react": {
+ "version": "19"
+ }
+ },
+ "rules": {
+ "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"
+ },
+ "overrides": [
+ {
+ "files": [
+ "src/renderer/**"
+ ],
+ "env": {
+ "node": false,
+ "browser": true
+ },
+ "rules": {
+ "no-console": "off",
+ "import-js/no-extraneous-dependencies": "off",
+ "unicorn/prefer-global-this": "off"
+ }
+ },
+ {
+ "files": [
+ "src/preload/**"
+ ],
+ "env": {
+ "browser": true
+ },
+ "rules": {
+ "no-console": "off",
+ "import-js/no-extraneous-dependencies": "off",
+ "unicorn/prefer-global-this": "off"
+ }
+ },
+ {
+ "files": [
+ "script/**",
+ "website/**",
+ "electron.vite.config.ts"
+ ],
+ "rules": {
+ "import-js/no-extraneous-dependencies": [
+ "error",
+ {
+ "devDependencies": true,
+ "optionalDependencies": false
+ }
+ ],
+ "no-console": "off"
+ }
+ },
+ {
+ "files": [
+ "src/renderer/src/util/rate-calculator.ts",
+ "src/renderer/src/util/rate-calculator.test.ts",
+ "src/main/pathToFileURL.test.ts"
+ ],
+ "rules": {
+ "unicorn/filename-case": "off"
+ }
+ },
+ {
+ "files": [
+ "src/renderer/src/App.tsx"
+ ],
+ "rules": {
+ "react-hooks/refs": "off",
+ "react-hooks/immutability": "off",
+ "react-hooks/preserve-manual-memoization": "off"
+ }
+ }
+ ]
+}
diff --git a/i18next.config.base.ts b/i18next.config.base.ts
index df188d71..10fa96e8 100644
--- a/i18next.config.base.ts
+++ b/i18next.config.base.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import type { defineConfig } from 'i18next-cli';
const configBase: Omit<Parameters<typeof defineConfig>[0], 'locales'> = {
diff --git a/i18next.config.scan.ts b/i18next.config.scan.ts
index 03a0c65a..4dcc7e50 100644
--- a/i18next.config.scan.ts
+++ b/i18next.config.scan.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { defineConfig } from 'i18next-cli';
import configBase from './i18next.config.base.js';
diff --git a/i18next.config.ts b/i18next.config.ts
index a2a689d1..a65367a9 100644
--- a/i18next.config.ts
+++ b/i18next.config.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { defineConfig } from 'i18next-cli';
import type { SupportedLanguage } from './src/common/i18n.js';
diff --git a/package.json b/package.json
index 1b2e02ee..232c6f37 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
"build": "yarn generate-icon && electron-vite build",
"tsc": "tsc --build",
"test": "vitest",
- "lint": "eslint --ext .js,.ts,.jsx,.tsx,.mjs,.mts .",
+ "lint": "oxlint --type-aware --deny-warnings --ignore-pattern 'website/**' && oxlint --deny-warnings website",
"check": "yarn tsc && yarn lint && yarn test run && yarn build && yarn check-licenses && yarn scan-i18n && yarn dedupe --check && yarn generate-docs",
"pack-mac": "yarn build && electron-builder --mac dmg",
"pack-mas-dev": "yarn build && electron-builder --mac mas-dev -c.mas.provisioningProfile=LosslessCut_Dev.provisionprofile -c.mas.identity='Mikael Finstad (JH4PH8B3C8)'",
@@ -54,6 +54,7 @@
"@dnd-kit/modifiers": "^9.0.0",
"@dnd-kit/sortable": "^10.0.0",
"@fontsource/open-sans": "^5.2.7",
+ "@mifi/lint-config": "^1.0.0",
"@radix-ui/colors": "^3.0.0",
"@radix-ui/react-alert-dialog": "^1.1.15",
"@radix-ui/react-checkbox": "^1.3.3",
@@ -68,7 +69,6 @@
"@types/canvas-confetti": "^1.9.0",
"@types/color": "^4.2.1",
"@types/css-modules": "^1.0.5",
- "@types/eslint": "^8.56.12",
"@types/express": "^5.0.6",
"@types/leaflet": "^1.9.21",
"@types/lodash": "^4.17.24",
@@ -83,8 +83,6 @@
"@types/smpte-timecode": "^1.2.5",
"@types/yargs": "^17.0.35",
"@types/yargs-parser": "^21.0.3",
- "@typescript-eslint/eslint-plugin": "^8.60.0",
- "@typescript-eslint/parser": "^8.60.0",
"@uidotdev/usehooks": "^2.4.1",
"@vitejs/plugin-react": "^5.2.0",
"canvas-confetti": "^1.9.4",
@@ -95,13 +93,6 @@
"electron": "^42.11.15",
"electron-builder": "26.16.1",
"electron-vite": "^5.0.0",
- "eslint": "^8.57.1",
- "eslint-config-mifi": "^0.1.1",
- "eslint-plugin-import": "^2.32.0",
- "eslint-plugin-jsx-a11y": "^6.10.2",
- "eslint-plugin-react": "^7.37.5",
- "eslint-plugin-react-hooks": "^7.1.1",
- "eslint-plugin-unicorn": "56.0.1",
"fast-xml-parser": "^5.8.0",
"i18next-cli": "^1.58.1",
"immer": "^11.1.8",
@@ -112,6 +103,8 @@
"mkdirp": "^3.0.1",
"motion": "^12.40.0",
"nanoid": "^5.1.11",
+ "oxlint": "^1.89.0",
+ "oxlint-tsgolint": "^7.0.2005",
"p-map": "^7.0.4",
"p-retry": "^8.0.0",
"pretty-bytes": "^7.1.0",
diff --git a/script/checkLicenses.ts b/script/checkLicenses.ts
index 49b9eef7..0946345d 100644
--- a/script/checkLicenses.ts
+++ b/script/checkLicenses.ts
@@ -87,7 +87,7 @@ if (unsafeLicenses.length > 0) {
for (const l of unsafeLicenses) {
console.error(l.value);
- console.error(`${Object.keys(l.children).map((v) => `- ${v}`).join('\n')}`);
+ console.error(Object.keys(l.children).map((v) => `- ${v}`).join('\n'));
console.error();
}
process.exitCode = 1;
diff --git a/script/e2e.ts b/script/e2e.ts
index 19a74528..777aec4b 100644
--- a/script/e2e.ts
+++ b/script/e2e.ts
@@ -26,7 +26,7 @@ const ps = execa(losslessCutExePath, losslessCutArgs, { forceKillAfterDelay: 100
console.log('Started', losslessCutExePath);
// eslint-disable-next-line unicorn/prefer-top-level-await
-ps.catch((err) => console.error(err));
+ps.catch((err: unknown) => console.error(err));
const client = ky.extend({ baseUrl: `http://127.0.0.1:${port}` });
diff --git a/script/releaseImage.ts b/script/releaseImage.ts
index 25bb65aa..9c887532 100644
--- a/script/releaseImage.ts
+++ b/script/releaseImage.ts
@@ -36,6 +36,7 @@ async function getAccentHue(seed: string) {
// Unless it's (nearly) grey
if (Math.max(r, g, b) - Math.min(r, g, b) > 20) return Math.round(((Math.atan2(Math.sqrt(3) * (g - b), 2 * r - g - b) * 180) / Math.PI + 360) % 360);
}
+ // eslint-disable-next-line @typescript-eslint/no-misused-spread -- we want code points
return [...seed].reduce((acc, c) => (acc * 31 + c.codePointAt(0)!) % 360, 7);
}
const hue = await getAccentHue(version);
diff --git a/script/xcrunWrapper.ts b/script/xcrunWrapper.ts
index ef130082..2d60139d 100644
--- a/script/xcrunWrapper.ts
+++ b/script/xcrunWrapper.ts
@@ -76,7 +76,7 @@ async function runAttempt() {
if (err instanceof Error && 'exitCode' in err && err.exitCode === 1 && 'stdout' in err && err.stdout && typeof err.stdout === 'string') {
const errorJson = JSON.parse(err.stdout) as unknown;
if (!(errorJson != null && typeof errorJson === 'object' && 'product-errors' in errorJson && Array.isArray(errorJson['product-errors']))) {
- throw new TypeError('Invalid JSON');
+ throw new TypeError('Invalid JSON', { cause: err });
}
const productErrors = errorJson['product-errors'];
// Unable to authenticate
diff --git a/src/common/util.test.ts b/src/common/util.test.ts
index e4b39be4..87e1c2ff 100644
--- a/src/common/util.test.ts
+++ b/src/common/util.test.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { describe, expect, test } from 'vitest';
import { getFixChannelLayoutFilter, hasCustomChannelLayout, truncateFileName } from './util.js';
diff --git a/src/common/util.ts b/src/common/util.ts
index b6860862..81b5ce8f 100644
--- a/src/common/util.ts
+++ b/src/common/util.ts
@@ -37,6 +37,7 @@ const ellipsis = '…';
// Truncate a file name to `maxLength`, keeping its extension (if any), and without splitting characters.
// We cut out the middle, because the end of the name often has the parts that make it unique (e.g. cut times, segment number)
export function truncateFileName(name: string, maxLength: number, utf16 = false) {
+ // eslint-disable-next-line @typescript-eslint/no-misused-spread -- we want code points
const getLength = (str: string) => [...str].reduce((acc, char) => acc + getCharLength(char, utf16), 0);
if (getLength(name) <= maxLength) return name;
@@ -44,11 +45,12 @@ export function truncateFileName(name: string, maxLength: number, utf16 = false)
// only treat a short suffix as an extension, so that a dot early in the name doesn't make us exceed the limit
const ext = extIndex > 0 && name.length - extIndex <= 10 ? name.slice(extIndex) : '';
const stem = name.slice(0, name.length - ext.length);
+ // eslint-disable-next-line @typescript-eslint/no-misused-spread -- we want code points
const chars = [...stem];
const budget = maxLength - getLength(ext) - getLength(ellipsis);
const head = takeChars(chars, Math.floor(budget / 2), utf16);
- const tail = takeChars(chars.toReversed(), budget - getLength(head.join('')), utf16).reverse();
+ const tail = takeChars(chars.toReversed(), budget - getLength(head.join('')), utf16).toReversed();
return head.join('') + ellipsis + tail.join('') + ext;
}
diff --git a/src/main/aboutPanel.ts b/src/main/aboutPanel.ts
index 356809c1..d530e5ca 100644
--- a/src/main/aboutPanel.ts
+++ b/src/main/aboutPanel.ts
@@ -1,5 +1,5 @@
import type { AboutPanelOptionsOptions } from 'electron';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { app } from 'electron';
import { t } from 'i18next';
diff --git a/src/main/configStore.ts b/src/main/configStore.ts
index 15d5e492..07fd9ef4 100644
--- a/src/main/configStore.ts
+++ b/src/main/configStore.ts
@@ -1,5 +1,5 @@
import Store from 'electron-store';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import electron from 'electron';
import { join, dirname } from 'node:path';
import assert from 'node:assert';
@@ -211,7 +211,7 @@ export function onDidChange<T extends keyof Config>(key: T, callback: (val: Conf
return store.onDidChange(key, (val) => callback(val as Config[T]));
}
-export function reset<T extends keyof Config>(key: T) {
+export function reset(key: keyof Config) {
set(key, defaults[key]);
}
@@ -297,7 +297,7 @@ export async function init({ customConfigDir }: { customConfigDir: string | unde
assert(keysOrig.length > 0 && keysOrig.every((k) => k.length > 0), 'Invalid keys');
const map: Record<string, string> = {
- /* eslint-disable quote-props */
+ /* eslint-disable eslint-js/quote-props */
'esc': 'Escape',
'1': 'Digit1',
'2': 'Digit2',
@@ -397,7 +397,7 @@ export async function init({ customConfigDir }: { customConfigDir: string | unde
'shift': 'ShiftLeft',
'alt': 'AltLeft',
'meta': 'MetaLeft',
- /* eslint-enable quote-props */
+ /* eslint-enable eslint-js/quote-props */
};
const newKeys = keysOrig.flatMap((k) => {
diff --git a/src/main/contextMenu.ts b/src/main/contextMenu.ts
index 0d6d3a13..1cc16d96 100644
--- a/src/main/contextMenu.ts
+++ b/src/main/contextMenu.ts
@@ -1,5 +1,5 @@
import type { BrowserWindow } from 'electron';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { Menu } from 'electron';
// https://github.com/electron/electron/issues/4068#issuecomment-274159726
diff --git a/src/main/ffmpeg.ts b/src/main/ffmpeg.ts
index 933e52da..c509862c 100644
--- a/src/main/ffmpeg.ts
+++ b/src/main/ffmpeg.ts
@@ -6,7 +6,7 @@ import type { Options as ExecaOptions, ResultPromise } from 'execa';
import { execa } from 'execa';
import assert from 'node:assert';
import type { Readable } from 'node:stream';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { app, clipboard, nativeImage } from 'electron';
import { platform, arch, isWindows, isLinux } from './util.js';
diff --git a/src/main/ffmpegUtil.test.ts b/src/main/ffmpegUtil.test.ts
index fb7aea33..9d5e4de7 100644
--- a/src/main/ffmpegUtil.test.ts
+++ b/src/main/ffmpegUtil.test.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { describe, expect, test } from 'vitest';
import { getFfmpegJpegQuality, parseBlackDetectLine, parseSilenceDetectLine } from './ffmpegUtil';
diff --git a/src/main/httpServerUtil.test.ts b/src/main/httpServerUtil.test.ts
index ba3db4f3..3fe2f395 100644
--- a/src/main/httpServerUtil.test.ts
+++ b/src/main/httpServerUtil.test.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { test, expect, describe } from 'vitest';
import { isRequestAllowed } from './httpServerUtil.js';
diff --git a/src/main/i18n.ts b/src/main/i18n.ts
index d0023cd8..b01947fb 100644
--- a/src/main/i18n.ts
+++ b/src/main/i18n.ts
@@ -1,6 +1,6 @@
import i18n from 'i18next';
import Backend from 'i18next-fs-backend';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { app } from 'electron';
import { commonI18nOptions, loadPath, addPath } from './i18nCommon.js';
diff --git a/src/main/i18nCommon.ts b/src/main/i18nCommon.ts
index 431eb396..d913be99 100644
--- a/src/main/i18nCommon.ts
+++ b/src/main/i18nCommon.ts
@@ -1,6 +1,6 @@
// intentionally disabled because I don't know the quality of the languages, so better to default to english
// const LanguageDetector = window.require('i18next-electron-language-detector');
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { app } from 'electron';
import { join } from 'node:path';
import type { InitOptions } from 'i18next';
diff --git a/src/main/index.ts b/src/main/index.ts
index c3e5b90c..426162fd 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -2,10 +2,10 @@ process.traceDeprecation = true;
process.traceProcessWarnings = true;
/* eslint-disable import/first */
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import electron, { BrowserWindow, type BrowserWindowConstructorOptions, nativeTheme, shell, app, ipcMain, Notification, type NotificationConstructorOptions } from 'electron';
import i18n from 'i18next';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import debounce from 'lodash/debounce.js';
import yargsParser from 'yargs-parser';
import JSON5 from 'json5';
@@ -19,7 +19,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
import electronUnhandled from 'electron-unhandled';
import { fileTypeFromFile } from 'file-type';
import type { Asyncify } from 'type-fest';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { downloadChromeExtension } from 'electron-devtools-installer/dist/downloadChromeExtension.js';
import mitt from 'mitt';
@@ -424,7 +424,7 @@ async function init() {
if (isDev) {
- // eslint-disable-next-line @typescript-eslint/no-var-requires,global-require,import/no-extraneous-dependencies
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,global-require,import-js/no-extraneous-dependencies
installReactDevTools()
.then((extension) => logger.info('Added Extension', extension.name))
.catch((err: unknown) => logger.error('Failed to add extension', err));
diff --git a/src/main/logger.ts b/src/main/logger.ts
index 80355d78..d489762b 100644
--- a/src/main/logger.ts
+++ b/src/main/logger.ts
@@ -1,9 +1,9 @@
import winston from 'winston';
import util from 'node:util';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { app } from 'electron';
import { join } from 'node:path';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import type { TransformableInfo } from 'logform';
diff --git a/src/main/menu.ts b/src/main/menu.ts
index a136b260..7d191360 100644
--- a/src/main/menu.ts
+++ b/src/main/menu.ts
@@ -1,5 +1,5 @@
import type { BrowserWindow, MenuItem, MenuItemConstructorOptions } from 'electron';
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import electron from 'electron';
import { t } from 'i18next';
diff --git a/src/main/pathToFileURL.test.ts b/src/main/pathToFileURL.test.ts
index 7298820a..237413ae 100644
--- a/src/main/pathToFileURL.test.ts
+++ b/src/main/pathToFileURL.test.ts
@@ -1,5 +1,4 @@
-// eslint-disable-line unicorn/filename-case
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { test, expect, describe } from 'vitest';
import { pathToFileURL } from 'node:url';
diff --git a/src/main/progress.test.ts b/src/main/progress.test.ts
index 15457b53..b33494f4 100644
--- a/src/main/progress.test.ts
+++ b/src/main/progress.test.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { describe, expect, test } from 'vitest';
import { parseFfmpegProgressLine } from './progress';
diff --git a/src/main/updateChecker.ts b/src/main/updateChecker.ts
index 0b7b01b2..22f42b15 100644
--- a/src/main/updateChecker.ts
+++ b/src/main/updateChecker.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import electron from 'electron';
import semver from 'semver';
diff --git a/src/main/util.test.ts b/src/main/util.test.ts
index 5fb60818..f9fefe7c 100644
--- a/src/main/util.test.ts
+++ b/src/main/util.test.ts
@@ -1,4 +1,4 @@
-// eslint-disable-next-line import/no-extraneous-dependencies
+// eslint-disable-next-line import-js/no-extraneous-dependencies
import { describe, expect, test } from 'vitest';
import { join, resolve, sep } from 'node:path';
diff --git a/src/preload/index.ts b/src/preload/index.ts
index c74f840d..4efdd5f2 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -1,7 +1,7 @@
import type { RemoteRpcApi } from '../main/index.ts';
// eslint-disable-next-line @typescript-eslint/no-require-imports
-const { ipcRenderer } = require('electron');
+const { ipcRenderer } = require('electron') as typeof import('electron');
const apiProxy = new Proxy(
{} as RemoteRpcApi,
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 1be69368..5e570523 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -134,7 +134,7 @@ const { hasDisabledNetworking, pathToFileURL, lossyMode, isLinux } = window.requ
const hevcPlaybackSupportedPromise = doesPlayerSupportHevcPlayback();
// eslint-disable-next-line unicorn/prefer-top-level-await
-hevcPlaybackSupportedPromise.catch((err) => console.error(err));
+hevcPlaybackSupportedPromise.catch((err: unknown) => console.error(err));
function emitEvent(appEvent: AppEvent) {
ipcRenderer.send('appEvent', appEvent satisfies AppEvent);
@@ -551,7 +551,7 @@ function App() {
const toggleWaveformMode = useCallback(() => {
if (forceBigWaveform) return;
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (waveformModePreference === 'waveform') {
setWaveformMode('big-waveform');
} else if (waveformModePreference === 'big-waveform') {
@@ -1356,7 +1356,7 @@ function App() {
setProgress(totalProgress / segments.length);
};
- // eslint-disable-next-line no-restricted-syntax
+ // eslint-disable-next-line eslint-js/no-restricted-syntax
for (const [index, segment] of segments.entries()) {
const { start, end } = segment;
invariant(filePath != null);
diff --git a/src/renderer/src/ErrorBoundary.tsx b/src/renderer/src/ErrorBoundary.tsx
index 088d9953..a7de2339 100644
--- a/src/renderer/src/ErrorBoundary.tsx
+++ b/src/renderer/src/ErrorBoundary.tsx
@@ -28,13 +28,14 @@ class ErrorBoundary extends Component<{ children: ReactNode }> {
return (
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
<h1><Trans>Something went wrong</Trans></h1>
+ {/* eslint-disable-next-line @typescript-eslint/no-base-to-string -- error can be anything */}
<div style={{ whiteSpace: 'pre-wrap', wordBreak: 'break-all' }}>{error instanceof Error ? error.message : String(error)}</div>
<p><button type="button" onClick={() => openSendReportDialog({ err: error })} style={{ padding: 10, fontSize: 20 }}><Trans>Report error</Trans></button></p>
</div>
);
}
- // eslint-disable-next-line react/destructuring-assignment
+ // eslint-disable-next-line react-js/destructuring-assignment
return this.props.children;
}
}
diff --git a/src/renderer/src/LastCommands.tsx b/src/renderer/src/LastCommands.tsx
index f40b91ee..c70aa198 100644
--- a/src/renderer/src/LastCommands.tsx
+++ b/src/renderer/src/LastCommands.tsx
@@ -29,7 +29,7 @@ function LastCommands({ visible, onTogglePress, ffmpegCommandLog, setFfmpegComma
<div>
<Button onClick={() => setFfmpegCommandLog([])} style={{ fontSize: '1em', marginBottom: '.5em' }}>{t('Clear')}</Button>
- {sortBy(ffmpegCommandLog, (l) => -l.time).map(({ command, time }, i) => (
+ {sortBy(ffmpegCommandLog, (l) => -l.time.getTime()).map(({ command, time }, i) => (
// eslint-disable-next-line react/no-array-index-key
<div key={i} style={{ whiteSpace: 'pre', padding: '.3em 0', fontFamily: 'monospace', overflow: 'scroll' }}>
<CopyClipboardButton text={command} style={{ marginRight: '.5em', verticalAlign: 'middle' }} />
diff --git a/src/renderer/src/StreamsSelector.tsx b/src/renderer/src/StreamsSelector.tsx
index 0567c69b..88534379 100644
--- a/src/renderer/src/StreamsSelector.tsx
+++ b/src/renderer/src/StreamsSelector.tsx
@@ -541,7 +541,7 @@ const Stream = memo(({ filePath, stream, onToggle, toggleCopyStreamIds, copyStre
let Icon: typeof FaBan;
let codecTypeHuman;
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (stream.codec_type === 'audio') {
Icon = copyStream ? FaVolumeUp : FaVolumeMute;
codecTypeHuman = t('audio');
@@ -601,7 +601,7 @@ const Stream = memo(({ filePath, stream, onToggle, toggleCopyStreamIds, copyStre
</td>
<td style={{ maxWidth: '3em', overflow: 'hidden' }} title={stream.codec_name}>{stream.codec_name} {codecTag}</td>
<td>
- {duration != null && !Number.isNaN(duration) && `${formatTimecode({ seconds: duration, shorten: true })}`}
+ {duration != null && !Number.isNaN(duration) && formatTimecode({ seconds: duration, shorten: true })}
{stream.nb_frames != null ? <span> {stream.nb_frames}f</span> : null}
</td>
<td>{!Number.isNaN(bitrate) && (stream.codec_type === 'audio' ? `${Math.round(bitrate / 1000)} kbps` : prettyBytes(bitrate, { bits: true }))}</td>
diff --git a/src/renderer/src/Timeline.tsx b/src/renderer/src/Timeline.tsx
index 8c859173..4fb69962 100644
--- a/src/renderer/src/Timeline.tsx
+++ b/src/renderer/src/Timeline.tsx
@@ -319,7 +319,7 @@ function Timeline({
const mouseDragTimelinePos = getMouseTimelinePos(e2);
seekAbs(mouseDragTimelinePos);
try {
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (resizingSegmentRef.current?.operation === 'start') {
setCutTime('start', mouseDragTimelinePos);
} else if (resizingSegmentRef?.current?.operation === 'end') {
diff --git a/src/renderer/src/components/ConcatDialog.tsx b/src/renderer/src/components/ConcatDialog.tsx
index dde56502..a75971d7 100644
--- a/src/renderer/src/components/ConcatDialog.tsx
+++ b/src/renderer/src/components/ConcatDialog.tsx
@@ -209,7 +209,7 @@ function ConcatDialog({ isShown, onHide, paths, mergedFileTemplate: storedMerged
}
setAllFilesMeta((existing) => ({ ...existing, ...Object.fromEntries(newMetaEntries) }));
setUniqueSuffix(Date.now());
- })().catch((err) => {
+ })().catch((err: unknown) => {
if (err instanceof Error && err.name === 'AbortError') return;
console.error(err);
});
diff --git a/src/renderer/src/components/FileNameTemplateEditor.tsx b/src/renderer/src/components/FileNameTemplateEditor.tsx
index cd95e2ca..b84027bf 100644
--- a/src/renderer/src/components/FileNameTemplateEditor.tsx
+++ b/src/renderer/src/components/FileNameTemplateEditor.tsx
@@ -162,7 +162,7 @@ function FileNameTemplateEditor(opts: {
input!.setSelectionRange(startPos, endPos);
if (document.execCommand('insertText', false, formatVariable(toInsert))) return;
- const newValue = `${text.slice(0, startPos)}${`${formatVariable(toInsert)}${text.slice(endPos)}`}`;
+ const newValue = `${text.slice(0, startPos)}${formatVariable(toInsert)}${text.slice(endPos)}`;
setText(newValue);
debouncedSetTemplate(newValue);
}, [debouncedSetTemplate, text]);
diff --git a/src/renderer/src/components/GenericDialog.tsx b/src/renderer/src/components/GenericDialog.tsx
index fa17d91d..446c23a1 100644
--- a/src/renderer/src/components/GenericDialog.tsx
+++ b/src/renderer/src/components/GenericDialog.tsx
@@ -312,7 +312,7 @@ export function useDialog() {
let parseableValue = value.trim();
if (!parseableValue) return undefined;
let sign = 1;
- if (parseableValue[0] === '-') {
+ if (parseableValue.startsWith('-')) {
sign = -1;
parseableValue = parseableValue.slice(1);
}
diff --git a/src/renderer/src/components/SegmentCutpointButton.tsx b/src/renderer/src/components/SegmentCutpointButton.tsx
index 42904a8f..73997c51 100644
--- a/src/renderer/src/components/SegmentCutpointButton.tsx
+++ b/src/renderer/src/components/SegmentCutpointButton.tsx
@@ -25,7 +25,7 @@ const SegmentCutpointButton = ({ currentCutSeg, side, Icon, onClick, title, styl
return (
<Icon
size={13}
- title={title as string}
+ title={title!}
role="button"
style={{ flexShrink: 0, color: 'white', padding: start ? '4px 4px 4px 2px' : '4px 2px 4px 4px', borderLeft: start ? border : undefined, borderRight: !start ? border : undefined, background: backgroundColor, borderRadius: 6, ...style }}
onClick={onClick}
diff --git a/src/renderer/src/components/WhatsNew.tsx b/src/renderer/src/components/WhatsNew.tsx
index b9b2f11c..3d91be73 100644
--- a/src/renderer/src/components/WhatsNew.tsx
+++ b/src/renderer/src/components/WhatsNew.tsx
@@ -30,7 +30,7 @@ export default function WhatsNew() {
const matchingVersions = useMemo(() => versions
.filter(({ version }) => semver.gt(version, initialLastAppVersion) && semver.lte(version, appVersion))
- .sort(({ version: a }, { version: b }) => semver.compare(b, a)), [initialLastAppVersion]);
+ .toSorted(({ version: a }, { version: b }) => semver.compare(b, a)), [initialLastAppVersion]);
if (initialLastAppVersion === appVersion) return null;
diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsx
index a77ed871..5fe119a1 100644
--- a/src/renderer/src/dialogs/index.tsx
+++ b/src/renderer/src/dialogs/index.tsx
@@ -549,7 +549,7 @@ export async function promptDownloadMediaUrl(outPath: string) {
export async function deleteFiles({ paths, deleteIfTrashFails, signal }: { paths: string[], deleteIfTrashFails?: boolean | undefined, signal: AbortSignal }) {
const failedToTrashFiles: string[] = [];
- // eslint-disable-next-line no-restricted-syntax
+ // eslint-disable-next-line eslint-js/no-restricted-syntax
for (const path of paths) {
try {
if (testFailFsOperation) throw new Error('test trash failure');
@@ -590,7 +590,7 @@ export async function checkAppPath() {
const forceCheckMs = false;
const forceCheckTitle = false;
// this code is purposefully obfuscated to try to detect the most basic cloned app submissions to the MS Store
- // eslint-disable-next-line no-useless-concat, one-var, one-var-declaration-per-line
+ // eslint-disable-next-line no-useless-concat, one-var, eslint-js/one-var-declaration-per-line
const mf = 'mi' + 'fi.no', ap = 'Los' + 'slessC' + 'ut';
let payload: string | undefined;
if (isWindowsStoreBuild || (isDev && forceCheckMs)) {
diff --git a/src/renderer/src/edlFormats.ts b/src/renderer/src/edlFormats.ts
index b899959c..f7b344cf 100644
--- a/src/renderer/src/edlFormats.ts
+++ b/src/renderer/src/edlFormats.ts
@@ -402,7 +402,7 @@ export function parseDvAnalyzerSummaryTxt(txt: string) {
let headerFound = false;
const times: { time: number, name: string, tags: Record<string, string> }[] = [];
- // eslint-disable-next-line no-restricted-syntax
+ // eslint-disable-next-line eslint-js/no-restricted-syntax
for (const line of lines) {
if (headerFound) {
const match = line.match(/^(\d{2}):(\d{2}):(\d{2}).(\d{3})\s+(\S+)\s+-\s+(\S+)\s+(\S+\s+\S+)\s+-\s+(\S+\s+\S+)/);
@@ -447,7 +447,7 @@ export function parseSrt(text: string) {
lines = [];
};
- // eslint-disable-next-line no-restricted-syntax
+ // eslint-disable-next-line eslint-js/no-restricted-syntax
for (const lineRaw of text.trim().split(/\r?\n/)) {
const line = lineRaw.trim();
if (line === '') {
@@ -510,9 +510,9 @@ export function parseDjiGps1(lines: string[]) {
}
export function parseDjiGps2(lines: string[]) {
- const xml = new XMLParser().parse(lines.join('\n'));
- invariant(typeof xml.font === 'string');
- const line: string = xml.font.split('\n')[2];
+ const { font } = new XMLParser().parse(lines.join('\n')) as { font: unknown };
+ invariant(typeof font === 'string');
+ const line = font.split('\n')[2];
invariant(line != null);
const records: Record<string, string> = {};
const pairsMatch = line.match(/([^\s:[]+\s*:\s*[^\s\]]+)+/g);
diff --git a/src/renderer/src/edlStore.ts b/src/renderer/src/edlStore.ts
index e5d82fcf..f9ee8e82 100644
--- a/src/renderer/src/edlStore.ts
+++ b/src/renderer/src/edlStore.ts
@@ -160,7 +160,7 @@ export async function askForEdlImport({ type, fps, fileDuration, defaultPath }:
if (type === 'youtube') return askForYouTubeInput({ fileDuration });
let filters;
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (type === 'csv' || type === 'csv-frames') filters = [{ name: i18n.t('CSV files'), extensions: ['csv'] }];
else if (type === 'xmeml') filters = [{ name: i18n.t('XML files'), extensions: ['xml'] }];
else if (type === 'fcpxml') filters = [{ name: i18n.t('FCPXML files'), extensions: ['fcpxml'] }];
@@ -193,7 +193,7 @@ export async function exportEdlFile({ type, cutSegments, customOutDir, filePath,
let filters: { name: string, extensions: string[] }[] | undefined;
let ext: string | undefined;
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (type === 'csv') {
ext = 'csv';
filters = [{ name: i18n.t('CSV files'), extensions: [ext, 'txt'] }];
@@ -219,7 +219,7 @@ export async function exportEdlFile({ type, cutSegments, customOutDir, filePath,
const { canceled, filePath: savePath } = await dialog.showSaveDialog({ defaultPath, title: i18n.t('Export project'), ...(filters != null ? { filters } : {}) });
if (canceled || !savePath) return;
console.log('Saving', type, savePath);
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (type === 'csv') await saveCsv(savePath, cutSegments);
else if (type === 'tsv-human') await saveTsv(savePath, cutSegments);
else if (type === 'csv-human') await saveCsvHuman(savePath, cutSegments);
diff --git a/src/renderer/src/ffmpeg.ts b/src/renderer/src/ffmpeg.ts
index 70009788..29fbb2ee 100644
--- a/src/renderer/src/ffmpeg.ts
+++ b/src/renderer/src/ffmpeg.ts
@@ -84,7 +84,7 @@ export async function readFrames({ filePath, from, to, streamIndex }: {
const createdAt = new Date();
const packetsFiltered: Frame[] = (JSON.parse(new TextDecoder().decode(stdout)).packets as { flags: string, pts_time: string }[])
.map((p) => ({
- keyframe: p.flags[0] === 'K',
+ keyframe: p.flags.startsWith('K'),
time: parseFloat(p.pts_time),
createdAt,
}))
@@ -165,7 +165,7 @@ export function getSafeCutTime(frames: Frame[], cutTime: number, nextMode: boole
const findReverseIndex = <T>(arr: T[], cb: (value: T, i: number, obj: T[]) => unknown) => {
// eslint-disable-next-line unicorn/no-array-callback-reference
- const ret = [...arr].reverse().findIndex(cb);
+ const ret = arr.toReversed().findIndex(cb);
if (ret === -1) return -1;
return arr.length - 1 - ret;
};
@@ -578,6 +578,7 @@ export async function createChaptersFromSegments({ paths, defaultChapterNames, u
let timeAt = 0;
+ // eslint-disable-next-line array-callback-return -- false positive in oxlint (it doesn't see the returns inside try/finally)
return filesMeta.flatMap((meta, i) => {
const duration = parseFfprobeDuration(meta.format.duration) ?? 0;
diff --git a/src/renderer/src/ffprobe.ts b/src/renderer/src/ffprobe.ts
index 3434c047..f30b6787 100644
--- a/src/renderer/src/ffprobe.ts
+++ b/src/renderer/src/ffprobe.ts
@@ -12,7 +12,7 @@ export function parseLevel(videoStream: FFprobeStream) {
let level = (levelNumeric / 10).toFixed(1); // https://stackoverflow.com/questions/42619191/what-does-level-mean-in-ffprobe-output
if (parseFloat(level) >= 0) {
- if (level.slice(-2) === '.0') level = level.slice(0, -2); // slice off .0
+ if (level.endsWith('.0')) level = level.slice(0, -2); // slice off .0
const validLevels = ['1', '1b', '1.1', '1.2', '1.3', '2', '2.1', '2.2', '3', '3.1', '3.2', '4', '4.1', '4.2', '5', '5.1', '5.2', '6', '6.1', '6.2']; // https://en.wikipedia.org/wiki/Advanced_Video_Coding#Levels
if (validLevels.includes(level)) return level;
}
@@ -20,7 +20,7 @@ export function parseLevel(videoStream: FFprobeStream) {
// Note that on MacOS we don't use x265, but videotoolbox
let level = (levelNumeric / 30).toFixed(1); // https://stackoverflow.com/questions/69983131/whats-the-difference-between-ffprobe-level-and-h-264-level
if (parseFloat(level) >= 0) {
- if (level.slice(-2) === '.0') level = level.slice(0, -2); // slice off .0
+ if (level.endsWith('.0')) level = level.slice(0, -2); // slice off .0
const validLevels = ['1', '2', '2.1', '3', '3.1', '4', '4.1', '5', '5.1', '5.2', '6', '6.1', '6.2']; // https://en.wikipedia.org/wiki/High_Efficiency_Video_Coding_tiers_and_levels
if (validLevels.includes(level)) return level;
}
diff --git a/src/renderer/src/hooks/normalizeWheel.ts b/src/renderer/src/hooks/normalizeWheel.ts
index defa4f8f..5b683867 100644
--- a/src/renderer/src/hooks/normalizeWheel.ts
+++ b/src/renderer/src/hooks/normalizeWheel.ts
@@ -119,11 +119,11 @@ const PAGE_HEIGHT = 800;
* Firefox v4/Win7 | undefined | 3
*
*/
-type LegacyWheelEvent = WheelEvent<Element> & { axis?: number, HORIZONTAL_AXIS?: number };
+type LegacyWheelEvent = WheelEvent & { axis?: number, HORIZONTAL_AXIS?: number };
-export default function normalizeWheel(/* object */ event: WheelEvent<Element>) /* object */ {
+export default function normalizeWheel(/* object */ event: WheelEvent) /* object */ {
let sX = 0; let sY = 0; // spinX, spinY
- let pX = 0; let pY = 0; // pixelX, pixelY
+ let pX: number; let pY: number; // pixelX, pixelY
// Legacy
if ('detail' in event) { sY = event.detail; }
diff --git a/src/renderer/src/hooks/useFfmpegOperations.ts b/src/renderer/src/hooks/useFfmpegOperations.ts
index 06218082..456be4e1 100644
--- a/src/renderer/src/hooks/useFfmpegOperations.ts
+++ b/src/renderer/src/hooks/useFfmpegOperations.ts
@@ -83,7 +83,7 @@ function getMatroskaFlags(outFormat: string | undefined) {
const getChaptersInputArgs = (ffmetadataPath: string | undefined) => (ffmetadataPath ? ['-f', 'ffmetadata', '-i', ffmetadataPath] : []);
async function tryDeleteFiles(paths: string[]) {
- return pMap(paths, (path) => unlinkWithRetry(path).catch((err) => console.error('Failed to delete', path, err)), { concurrency: 5 });
+ return pMap(paths, (path) => unlinkWithRetry(path).catch((err: unknown) => console.error('Failed to delete', path, err)), { concurrency: 5 });
}
export async function maybeMkDeepOutDir({ outputDir, fileOutPath }: { outputDir: string, fileOutPath: string }) {
diff --git a/src/renderer/src/hooks/useFrameCapture.ts b/src/renderer/src/hooks/useFrameCapture.ts
index 5e6add74..fc4d9568 100644
--- a/src/renderer/src/hooks/useFrameCapture.ts
+++ b/src/renderer/src/hooks/useFrameCapture.ts
@@ -53,7 +53,7 @@ export default ({ appendFfmpegCommandLog, formatTimecode, treatInputFileModified
if (!outputTimestamps) {
const numDigits = getNumDigits(estimatedMaxNumFiles);
const outPathTemplate = getSuffixedOutPath({ customOutDir, filePath, nameSuffix: getSuffix(`%0${numDigits}d`) });
- const firstFileOutPath = getSuffixedOutPath({ customOutDir, filePath, nameSuffix: getSuffix(`${'1'.padStart(numDigits, '0')}`) }); // mimic ffmpeg output
+ const firstFileOutPath = getSuffixedOutPath({ customOutDir, filePath, nameSuffix: getSuffix('1'.padStart(numDigits, '0')) }); // mimic ffmpeg output
const args = await ffmpeg.captureFrames({ from: fromTime, to: toTime, videoPath: filePath, outPathTemplate, captureFormat, quality, filter, onProgress });
appendFfmpegCommandLog(args);
diff --git a/src/renderer/src/hooks/useKeyboard.ts b/src/renderer/src/hooks/useKeyboard.ts
index 2dc3dea6..d9d268da 100644
--- a/src/renderer/src/hooks/useKeyboard.ts
+++ b/src/renderer/src/hooks/useKeyboard.ts
@@ -106,13 +106,13 @@ export default ({ keyBindings, keyUpActions, getKeyboardAction, closeExportConfi
}, [onKeyUp2]);
useEffect(() => {
- const keyBindingsByKeyCode = keyBindings.reduce((acc, kb) => {
+ const keyBindingsByKeyCode = keyBindings.reduce<Record<string, KeyBinding[]>>((acc, kb) => {
kb.keys.split('+').forEach((key) => {
if (!acc[key]) acc[key] = [];
acc[key].push(kb);
});
return acc;
- }, {} as Record<string, KeyBinding[]>);
+ }, {});
function onKeyDown(params: KeyEventParams) {
if (onKeyDownRef.current == null) return true;
diff --git a/src/renderer/src/hooks/useSegments.tsx b/src/renderer/src/hooks/useSegments.tsx
index a9b9f647..f4a13363 100644
--- a/src/renderer/src/hooks/useSegments.tsx
+++ b/src/renderer/src/hooks/useSegments.tsx
@@ -667,7 +667,7 @@ function useSegments({ filePath, workingRef, setWorking, setProgress, videoStrea
return [index];
}
return [];
- }).reverse() // reverse, so that if we are on multiple, we select the last first. That way, auto play selected segments won't go on repeat on the same segment
+ }).toReversed() // reverse, so that if we are on multiple, we select the last first. That way, auto play selected segments won't go on repeat on the same segment
), [cutSegments]);
const focusSegmentAtCursor = useCallback(() => {
diff --git a/src/renderer/src/hooks/useTimelineScroll.ts b/src/renderer/src/hooks/useTimelineScroll.ts
index 17b9d64f..00d39d0a 100644
--- a/src/renderer/src/hooks/useTimelineScroll.ts
+++ b/src/renderer/src/hooks/useTimelineScroll.ts
@@ -55,7 +55,7 @@ function useTimelineScroll({ wheelSensitivity, mouseWheelZoomModifierKey, mouseW
}) {
const isCtrlHeldRef = useIsCtrlHeldRef();
- const onWheel = useCallback<WheelEventHandler<Element>>((wheelEvent) => {
+ const onWheel = useCallback<WheelEventHandler>((wheelEvent) => {
const { pixelX, pixelY } = normalizeWheel(wheelEvent);
const { ctrlKey, shiftKey, altKey, metaKey } = wheelEvent;
// if unknown, assume ctrl is really held (not a pinch)
diff --git a/src/renderer/src/hooks/useVideo.ts b/src/renderer/src/hooks/useVideo.ts
index 457ea09c..f1fea463 100644
--- a/src/renderer/src/hooks/useVideo.ts
+++ b/src/renderer/src/hooks/useVideo.ts
@@ -119,7 +119,7 @@ export default ({ filePath }: { filePath: string | undefined }) => {
// if (Math.abs(commandedTimeRef.current - video.currentTime) > 1) video.currentTime = commandedTimeRef.current;
if (resetPlaybackRate) setPlaybackRate(outputPlaybackRate);
- video?.play().catch((err) => {
+ video?.play().catch((err: unknown) => {
if (err instanceof Error && err.name === 'AbortError' && 'code' in err && err.code === 20) { // Probably "DOMException: The play() request was interrupted by a call to pause()."
console.error(err);
} else {
diff --git a/src/renderer/src/i18n.ts b/src/renderer/src/i18n.ts
index f7df35bb..b1711207 100644
--- a/src/renderer/src/i18n.ts
+++ b/src/renderer/src/i18n.ts
@@ -1,3 +1,4 @@
+// eslint-disable-next-line unicorn/prefer-export-from -- it's configured below
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
diff --git a/src/renderer/src/outFormats.ts b/src/renderer/src/outFormats.ts
index d33857a1..136aa702 100644
--- a/src/renderer/src/outFormats.ts
+++ b/src/renderer/src/outFormats.ts
@@ -146,10 +146,9 @@ const ffmpegFormats = {
const modifiedFormats = {
...ffmpegFormats,
+ ipod: 'M4A - Audio for iTunes',
};
-modifiedFormats.ipod = 'M4A - Audio for iTunes';
-
export type FfmpegFormat = keyof typeof modifiedFormats;
export default modifiedFormats;
diff --git a/src/renderer/src/reporting.tsx b/src/renderer/src/reporting.tsx
index b30b5825..a201f648 100644
--- a/src/renderer/src/reporting.tsx
+++ b/src/renderer/src/reporting.tsx
@@ -37,6 +37,7 @@ export function openSendReportDialog({ err, message, state }: {
const errorText = (() => {
if (err == null) return 'No error occurred.';
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- err can be anything
return err instanceof Error ? err.stack : String(err);
})();
diff --git a/src/renderer/src/segments.ts b/src/renderer/src/segments.ts
index f3bd3a4c..e25a4e6c 100644
--- a/src/renderer/src/segments.ts
+++ b/src/renderer/src/segments.ts
@@ -155,7 +155,7 @@ export function hasAnySegmentOverlap(sortedSegments: { start: number, end: numbe
return overlappingGroups.length > 0;
}
-// eslint-disable-next-line space-before-function-paren
+// eslint-disable-next-line eslint-js/space-before-function-paren
export function invertSegments(
sortedSegmentsIn: ({ start: number, end?: number | undefined, segId?: string | undefined, name?: string | undefined })[],
includeFirstSegment: boolean,
diff --git a/src/renderer/src/util.ts b/src/renderer/src/util.ts
index 49fb8196..73bbdab9 100644
--- a/src/renderer/src/util.ts
+++ b/src/renderer/src/util.ts
@@ -184,7 +184,7 @@ export function filenamify(name: string) {
return name.replaceAll(/[^\p{L}\p{N} ._-]/gu, '_');
}
-// eslint-disable-next-line space-before-function-paren
+// eslint-disable-next-line eslint-js/space-before-function-paren
export function withBlur<T extends { target?: { blur?: () => unknown } | object }>(cb: (a: T) => void) {
return (e: T) => {
cb(e);
diff --git a/src/renderer/src/util/metadata.ts b/src/renderer/src/util/metadata.ts
index da2cfdcc..19f62908 100644
--- a/src/renderer/src/util/metadata.ts
+++ b/src/renderer/src/util/metadata.ts
@@ -93,7 +93,7 @@ export function getLanguageSuggestions(uiLanguage: string): Suggestion[] {
}
return languages
.map(([value, bcp47]) => ({ value, label: `${displayNames?.of(bcp47) ?? value} (${value})` }))
- .sort((a, b) => a.label.localeCompare(b.label));
+ .toSorted((a, b) => a.label.localeCompare(b.label));
}
export const isValidLanguageCode = (code: string) => /^[a-z]{3}$/.test(code);
diff --git a/src/renderer/src/util/outputNameTemplate.ts b/src/renderer/src/util/outputNameTemplate.ts
index 1cba5fb2..ce6f965c 100644
--- a/src/renderer/src/util/outputNameTemplate.ts
+++ b/src/renderer/src/util/outputNameTemplate.ts
@@ -109,6 +109,7 @@ function getTemplateProblems({ fileNames, filePath, outputDir, safeOutputFileNam
error = i18n.t('At least one resulting file name has no length');
break;
}
+ // eslint-disable-next-line @typescript-eslint/no-misused-spread -- we want code points
const matchingInvalidChars = new Set([...fileName].filter((char) => invalidChars.has(char)));
if (matchingInvalidChars.size > 0) {
error = i18n.t('At least one resulting file name contains invalid character(s): {{invalidChars}}', { invalidChars: `"${[...matchingInvalidChars].map((char) => formatInvalidChar(char)).join('", "')}"` });
@@ -216,7 +217,7 @@ async function interpolateOutFileName(template: string, {
[segTagsVariable]: tags && {
// allow both original case and uppercase
...tags,
- ...Object.fromEntries(Object.entries(tags).map(([key, value]) => [`${key.toLocaleUpperCase('en-US')}`, value])),
+ ...Object.fromEntries(Object.entries(tags).map(([key, value]) => [key.toLocaleUpperCase('en-US'), value])),
},
FILE_EXPORT_COUNT: currentFileExportCount != null ? currentFileExportCount + 1 : undefined,
EXPORT_COUNT: exportCount != null ? exportCount + 1 : undefined,
diff --git a/src/renderer/src/util/rate-calculator.test.ts b/src/renderer/src/util/rate-calculator.test.ts
index fb2923a0..02c28abe 100644
--- a/src/renderer/src/util/rate-calculator.test.ts
+++ b/src/renderer/src/util/rate-calculator.test.ts
@@ -1,4 +1,3 @@
-// eslint-disable-line unicorn/filename-case
import { describe, it, expect } from 'vitest';
import { adjustRate, DEFAULT_PLAYBACK_RATE } from './rate-calculator';
diff --git a/src/renderer/src/util/rate-calculator.ts b/src/renderer/src/util/rate-calculator.ts
index bba52d97..04ff80b2 100644
--- a/src/renderer/src/util/rate-calculator.ts
+++ b/src/renderer/src/util/rate-calculator.ts
@@ -1,4 +1,3 @@
-// eslint-disable-line unicorn/filename-case
import clamp from 'lodash/clamp';
/**
diff --git a/src/renderer/src/util/streams.ts b/src/renderer/src/util/streams.ts
index 825e4eeb..6711e71c 100644
--- a/src/renderer/src/util/streams.ts
+++ b/src/renderer/src/util/streams.ts
@@ -140,7 +140,7 @@ function getPerStreamFlags({ stream, outputIndex, outFormat, manuallyCopyDisposi
addArgs(`-c:${outputIndex}`, codec);
}
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
if (stream.codec_type === 'subtitle') {
// mp4/mov only supports mov_text, so convert it https://stackoverflow.com/a/17584272/6519037
// https://github.com/mifi/lossless-cut/issues/418
@@ -156,7 +156,7 @@ function getPerStreamFlags({ stream, outputIndex, outFormat, manuallyCopyDisposi
// Only WebVTT subtitles are supported for WebM.
// https://github.com/mifi/lossless-cut/issues/2179#issuecomment-2395413115
addCodecArgs('webvtt');
- // eslint-disable-next-line unicorn/prefer-switch
+ // eslint-disable-next-line unicorn-js/prefer-switch
} else if (outFormat === 'srt') { // not technically lossless but why not
addCodecArgs('srt');
} else if (outFormat === 'ass') { // not technically lossless but why not
@@ -350,7 +350,7 @@ export function getKeyframeCutSeekCompensation({ formatName, streams, cutFrom }:
export const getAudioStreams = <T extends Pick<FFprobeStream, 'codec_type'>>(streams: T[]) => streams.filter((stream) => stream.codec_type === 'audio');
export const getRealVideoStreams = <T extends Pick<FFprobeStream, 'codec_type' | 'disposition'>>(streams: T[]) => streams.filter((stream) => stream.codec_type === 'video' && !isStreamThumbnail(stream));
export const getSubtitleStreams = <T extends Pick<FFprobeStream, 'codec_type'>>(streams: T[]) => streams.filter((stream) => stream.codec_type === 'subtitle');
-export const isGpsStream = <T extends Pick<FileStream, 'guessedType' | 'codec_type' | 'tags'>>(stream: T) => stream.codec_type === 'subtitle' && (stream.tags?.['handler_name'] === '\u0010DJI.Subtitle' || stream.guessedType === 'dji-gps-srt');
+export const isGpsStream = (stream: Pick<FileStream, 'guessedType' | 'codec_type' | 'tags'>) => stream.codec_type === 'subtitle' && (stream.tags?.['handler_name'] === '\u0010DJI.Subtitle' || stream.guessedType === 'dji-gps-srt');
// videoTracks/audioTracks seems to be 1-indexed, while ffmpeg is 0-indexes
const getHtml5TrackId = (ffmpegTrackIndex: number) => String(ffmpegTrackIndex + 1);
diff --git a/src/renderer/src/worker/evalWorker.ts b/src/renderer/src/worker/evalWorker.ts
index 5e29e628..c02432ed 100644
--- a/src/renderer/src/worker/evalWorker.ts
+++ b/src/renderer/src/worker/evalWorker.ts
@@ -59,7 +59,7 @@ Object.getOwnPropertyNames(myGlobal).forEach(function (prop) {
Object.defineProperty(myGlobal, prop, {
// eslint-disable-next-line func-names, object-shorthand
get: function () {
- // eslint-disable-next-line no-throw-literal
+ // eslint-disable-next-line no-throw-literal, @typescript-eslint/only-throw-error
throw `Security Exception: cannot access ${prop}`;
},
configurable: false,
@@ -77,7 +77,7 @@ Object.getOwnPropertyNames(myGlobal.__proto__).forEach(function (prop) {
Object.defineProperty(myGlobal.__proto__, prop, {
// eslint-disable-next-line func-names, object-shorthand
get: function () {
- // eslint-disable-next-line no-throw-literal
+ // eslint-disable-next-line no-throw-literal, @typescript-eslint/only-throw-error
throw `Security Exception: cannot access ${prop}`;
},
configurable: false,
@@ -91,13 +91,13 @@ Object.defineProperty(Array.prototype, 'join', {
writable: false,
configurable: false,
enumerable: false,
- // eslint-disable-next-line wrap-iife, func-names
+ // eslint-disable-next-line eslint-js/wrap-iife, func-names
value: function (old) {
// eslint-disable-next-line func-names
return function (arg?: unknown[]) {
// @ts-expect-error dunno how to fix
if (this.length > 500 || (arg && arg.length > 500)) {
- // eslint-disable-next-line no-throw-literal
+ // eslint-disable-next-line no-throw-literal, @typescript-eslint/only-throw-error
throw 'Exception: too many items';
}
@@ -124,7 +124,7 @@ Object.defineProperty(Array.prototype, 'join', {
myGlobal.fetch = undefined;
-// eslint-disable-next-line wrap-iife, func-names
+// eslint-disable-next-line eslint-js/wrap-iife, func-names
(function () {
onmessage = (event: MessageEvent<RequestMessageData>) => {
// eslint-disable-next-line strict, lines-around-directive
@@ -135,7 +135,7 @@ myGlobal.fetch = undefined;
try {
// https://stackoverflow.com/questions/8403108/calling-eval-in-particular-context
- // eslint-disable-next-line unicorn/new-for-builtins, no-new-func
+ // eslint-disable-next-line unicorn/new-for-builtins, no-new-func, @typescript-eslint/no-implied-eval
const result = Function(`\nwith (this) { return (${code}); }`).call(context);
postMessage({ id, data: result } satisfies ResponseMessageData);
} catch (e) {
diff --git a/website/scripts/appLinks.ts b/website/scripts/appLinks.ts
index f5698993..36931245 100644
--- a/website/scripts/appLinks.ts
+++ b/website/scripts/appLinks.ts
@@ -3,7 +3,7 @@
import fs from 'node:fs/promises';
// the app's list, shared through the repo rather than as a package
-// eslint-disable-next-line import/no-relative-packages
+// eslint-disable-next-line import-js/no-relative-packages
import { appLinkPrefix, appLinkTargets, websiteUrl } from '../../src/common/websiteUrls.ts';
const distDir = new URL('../dist/', import.meta.url);
@@ -33,7 +33,7 @@ await Promise.all(Object.entries(appLinkTargets).map(async ([name, target]) => {
}));
if (problems.length > 0) {
- console.error(`The app links to website pages that don't exist (see src/common/websiteUrls.ts):\n${problems.sort().join('\n')}`);
+ console.error(`The app links to website pages that don't exist (see src/common/websiteUrls.ts):\n${problems.toSorted().join('\n')}`);
process.exitCode = 1;
} else {
// https://developers.cloudflare.com/workers/static-assets/redirects/
diff --git a/website/src/components/Home.tsx b/website/src/components/Home.tsx
index 1036111f..9ea425b6 100644
--- a/website/src/components/Home.tsx
+++ b/website/src/components/Home.tsx
@@ -329,7 +329,7 @@ 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/no-invalid-html-attribute
+ // 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} />)}
@@ -338,6 +338,7 @@ export default function Home({ stars, release }: { stars: number, release: Relea
))}
</div>
+ {/* eslint-disable-next-line react-hooks/purity -- the year doesn't need to be stable between renders */}
<div className="footer-secondary" style={{ marginTop: '20px' }}>{new Date().getFullYear()} © Mikael Finstad</div>
</footer>
</div>