Multi-Hoster-Upload/eslint.config.mjs
Administrator f237d0f97a fix(doodstream): survive transient network blips around the upload
After 3.3.26 fixed the filecode parsing, the remaining intermittent failure is
a generic "fetch failed" — a transient network error on one of the requests
around the multi-minute upload. Can't tell from one log line whether it's the
server-discovery GET or the post-upload result-submit, so harden both:

- _fetch (the native-fetch chokepoint for discovery, redirects, result-submit):
  retry up to 3x with short backoff on a thrown network error, each attempt
  bounded by a 20s timeout (Node fetch has none by default). Caller aborts are
  not retried. The big file upload (undici) is retried at the upload-manager
  level, not here.
- result-submit is now best-effort: if it still fails after retries but we
  already hold the filecode from the CDN response, return that instead of
  discarding a completed upload.
- label the undici upload-POST error with phase + MB sent + node, preserving the
  original message so transient classification still matches.
- eslint: add AbortSignal to globals.
- Tests: _fetch transient-retry path (10 doodstream tests total).

"fetch failed" is already classified transient by upload-manager, so this is
additive resilience; next logs will show if anything still slips through.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 00:44:20 +02:00

86 lines
2.8 KiB
JavaScript

import security from 'eslint-plugin-security';
export default [
{
files: ['**/*.js'],
ignores: ['node_modules/**', 'release/**', 'tests/**'],
plugins: { security },
languageOptions: {
ecmaVersion: 2022,
sourceType: 'commonjs',
globals: {
require: 'readonly',
module: 'readonly',
exports: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
process: 'readonly',
console: 'readonly',
setTimeout: 'readonly',
clearTimeout: 'readonly',
setInterval: 'readonly',
clearInterval: 'readonly',
setImmediate: 'readonly',
Buffer: 'readonly',
URL: 'readonly',
fetch: 'readonly',
AbortController: 'readonly',
AbortSignal: 'readonly',
navigator: 'readonly',
document: 'readonly',
window: 'readonly',
localStorage: 'readonly',
HTMLElement: 'readonly',
alert: 'readonly',
confirm: 'readonly',
requestAnimationFrame: 'readonly',
queueMicrotask: 'readonly',
Intl: 'readonly',
crypto: 'readonly',
URLSearchParams: 'readonly',
EventSource: 'readonly',
}
},
rules: {
// Security rules
// detect-object-injection disabled: 78 false positives from config lookups like obj[hosterName]
'security/detect-object-injection': 'off',
'security/detect-non-literal-regexp': 'warn',
'security/detect-unsafe-regex': 'warn',
'security/detect-buffer-noassert': 'warn',
'security/detect-eval-with-expression': 'error',
'security/detect-no-csrf-before-method-override': 'warn',
'security/detect-possible-timing-attacks': 'warn',
'security/detect-pseudoRandomBytes': 'warn',
// Code quality
'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'no-undef': 'error',
'no-constant-condition': 'warn',
'no-debugger': 'error',
'no-duplicate-case': 'error',
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-ex-assign': 'error',
'no-extra-boolean-cast': 'warn',
'no-func-assign': 'error',
'no-inner-declarations': 'error',
'no-irregular-whitespace': 'error',
'no-unreachable': 'error',
'use-isnan': 'error',
'valid-typeof': 'error',
'eqeqeq': ['warn', 'always'],
'no-caller': 'error',
'no-eval': 'error',
'no-implied-eval': 'error',
'no-new-func': 'error',
'no-throw-literal': 'warn',
'no-self-assign': 'error',
'no-self-compare': 'error',
'no-loss-of-precision': 'error',
'no-dupe-keys': 'error',
'no-unsafe-finally': 'error',
'no-unmodified-loop-condition': 'warn',
'no-template-curly-in-string': 'warn',
}
}
];