chore: add ESLint with security plugin, fix code quality warnings

- Install eslint, typescript-eslint, eslint-plugin-security
- Add eslint.config.mjs with project-tuned rules
- Fix redundant catch assignment in cutVideo
- Fix let→const for promise dedup patterns
- No security bugs found — all regex warnings are false positives (anchored patterns)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
xRangerDE 2026-03-22 14:55:35 +01:00
parent d9bdf744fd
commit 18940d0640
4 changed files with 1169 additions and 13 deletions

25
eslint.config.mjs Normal file
View File

@ -0,0 +1,25 @@
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import security from 'eslint-plugin-security';
export default [
js.configs.recommended,
...tseslint.configs.recommended,
security.configs.recommended,
{
files: ['src/**/*.ts'],
rules: {
// Tune down noisy rules for existing codebase
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
'no-console': 'off',
'security/detect-object-injection': 'off', // Too many false positives with Record types
'security/detect-non-literal-fs-filename': 'off', // All paths come from controlled sources
'no-async-promise-executor': 'warn',
'no-empty': ['warn', { allowEmptyCatch: true }],
}
},
{
ignores: ['dist/**', 'release/**', 'node_modules/**', 'scripts/**', 'tmp_*/**']
}
];

1141
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,10 +25,14 @@
"electron-updater": "^6.1.0" "electron-updater": "^6.1.0"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^10.0.1",
"@types/node": "^20.10.0", "@types/node": "^20.10.0",
"electron": "^28.0.0", "electron": "^28.0.0",
"electron-builder": "^24.9.0", "electron-builder": "^24.9.0",
"typescript": "^5.3.0" "eslint": "^10.1.0",
"eslint-plugin-security": "^4.0.0",
"typescript": "^5.3.0",
"typescript-eslint": "^8.57.1"
}, },
"build": { "build": {
"appId": "de.24-music.twitch-vod-manager", "appId": "de.24-music.twitch-vod-manager",

View File

@ -1095,8 +1095,7 @@ function withInFlightDedup<T>(
return existing; return existing;
} }
let requestPromise: Promise<T>; const requestPromise: Promise<T> = factory().finally(() => {
requestPromise = factory().finally(() => {
if (store.get(key) === requestPromise) { if (store.get(key) === requestPromise) {
store.delete(key); store.delete(key);
} }
@ -1412,8 +1411,7 @@ function requestTwitchLogin(): Promise<boolean> {
return twitchLoginInFlight; return twitchLoginInFlight;
} }
let loginPromise: Promise<boolean>; const loginPromise: Promise<boolean> = twitchLogin().finally(() => {
loginPromise = twitchLogin().finally(() => {
if (twitchLoginInFlight === loginPromise) { if (twitchLoginInFlight === loginPromise) {
twitchLoginInFlight = null; twitchLoginInFlight = null;
} }
@ -1883,9 +1881,7 @@ async function cutVideo(
let inputBytes = 0; let inputBytes = 0;
try { try {
inputBytes = fs.statSync(inputFile).size; inputBytes = fs.statSync(inputFile).size;
} catch { } catch { }
inputBytes = 0;
}
const cutRequiredBytes = Math.max(96 * 1024 * 1024, Math.ceil(inputBytes * 0.75)); const cutRequiredBytes = Math.max(96 * 1024 * 1024, Math.ceil(inputBytes * 0.75));
const cutDiskCheck = ensureDiskSpace(path.dirname(outputFile), cutRequiredBytes, 'Video-Cut'); const cutDiskCheck = ensureDiskSpace(path.dirname(outputFile), cutRequiredBytes, 'Video-Cut');