chore(dashboard): make npm run lint work again

eslint.config.js was written for ESLint 9's flat config but package.json
pinned ESLint 8 and the script still passed --ext, so lint had not run in
months. Upgrade to ESLint 9 with @eslint/js and globals, keep
eslint-plugin-react-hooks on v5 (v7 ships the React Compiler rules, which
flag 21 places that would be a refactor, not a lint fix), drop the unused
eslint-plugin-react, and tune the rules to the house style: ignored catch
bindings, constant exports next to components, node globals for the build
scripts, and the entry point exempt from fast-refresh checks.

The findings that remained were fixed at the source: two unused Icon
destructures, an unused footer argument, two dead state pairs, one
useCallback dependency memoised, and six run-once effects marked as such.
This commit is contained in:
juancarlos.cavero 2026-08-25 19:24:46 +02:00
parent fd0e39862c
commit 08e0eca92d
12 changed files with 522 additions and 3452 deletions

View file

@ -10,7 +10,7 @@ export default defineConfig([
files: ['**/*.{js,jsx}'], files: ['**/*.{js,jsx}'],
extends: [ extends: [
js.configs.recommended, js.configs.recommended,
reactHooks.configs.flat.recommended, reactHooks.configs['recommended-latest'],
reactRefresh.configs.vite, reactRefresh.configs.vite,
], ],
languageOptions: { languageOptions: {
@ -23,7 +23,22 @@ export default defineConfig([
}, },
}, },
rules: { rules: {
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }], // `catch (e)` / `catch (_)` with the error deliberately ignored is the
// house style for best-effort localStorage and fetch calls.
'no-unused-vars': ['error', {
varsIgnorePattern: '^[A-Z_]', argsIgnorePattern: '^_', caughtErrors: 'none',
}],
// Contexts and modals export a hook or a constant next to the component.
'react-refresh/only-export-components': ['error', { allowConstantExport: true }],
}, },
}, },
{
// The entry point mounts a few one-off components; nothing here hot-reloads.
files: ['src/main.jsx'],
rules: { 'react-refresh/only-export-components': 'off' },
},
{
files: ['vite.config.js', 'vite-plugin-seo.js', 'seo/**/*.js'],
languageOptions: { globals: { ...globals.node } },
},
]) ])

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",
"build": "vite build", "build": "vite build",
"lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", "lint": "eslint . --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview" "preview": "vite preview"
}, },
"dependencies": { "dependencies": {
@ -21,14 +21,15 @@
"zod": "^4.3.6" "zod": "^4.3.6"
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.39.5",
"@types/react": "^18.2.64", "@types/react": "^18.2.64",
"@types/react-dom": "^18.2.21", "@types/react-dom": "^18.2.21",
"@vitejs/plugin-react": "^4.2.1", "@vitejs/plugin-react": "^4.2.1",
"autoprefixer": "^10.4.23", "autoprefixer": "^10.4.23",
"eslint": "^8.57.0", "eslint": "^9.39.5",
"eslint-plugin-react": "^7.34.0", "eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.26",
"eslint-plugin-react-refresh": "^0.4.5", "globals": "^15.15.0",
"postcss": "^8.5.6", "postcss": "^8.5.6",
"tailwindcss": "^3.4.19", "tailwindcss": "^3.4.19",
"vite": "^4.5.3" "vite": "^4.5.3"

View file

@ -191,7 +191,7 @@ const NAV = `
<a class="cta" href="${SITE.url}/">Get free clips</a> <a class="cta" href="${SITE.url}/">Get free clips</a>
</div></header>` </div></header>`
const footer = (related) => ` const footer = (_related) => `
<footer class="site"><div class="wrap"> <footer class="site"><div class="wrap">
<div class="row"> <div class="row">
<a href="${SITE.url}/">OpenShorts</a> <a href="${SITE.url}/">OpenShorts</a>

View file

@ -67,7 +67,7 @@ export default function Legal() {
</div> </div>
<div className="space-y-3 mb-12"> <div className="space-y-3 mb-12">
{DOCS.map(({ icon: Icon, title, desc, href, es }) => ( {DOCS.map(({ title, desc, href, es }) => (
<a <a
key={href} key={href}
href={href} href={href}

View file

@ -200,7 +200,7 @@ export default function ClipEditor({ jobId, clipIndex, clipTitle, onClose, onRer
const words = useMemo(() => (edl?.words || []), [edl]); const words = useMemo(() => (edl?.words || []), [edl]);
const sourceAvailable = !!edl?.source?.available; const sourceAvailable = !!edl?.source?.available;
const sourceDuration = edl?.source?.duration || 0; const sourceDuration = edl?.source?.duration || 0;
const canonical = edl?.canonical_range || { start: 0, end: 0 }; const canonical = useMemo(() => edl?.canonical_range || { start: 0, end: 0 }, [edl]);
const limits = edl?.limits || { max_segments: 12, min_segment_seconds: MIN_SEGMENT_SECONDS, max_total_seconds: 180 }; const limits = edl?.limits || { max_segments: 12, min_segment_seconds: MIN_SEGMENT_SECONDS, max_total_seconds: 180 };
const minSeg = limits.min_segment_seconds || MIN_SEGMENT_SECONDS; const minSeg = limits.min_segment_seconds || MIN_SEGMENT_SECONDS;

View file

@ -220,7 +220,7 @@ export default function PricingPage({ onRequireLogin }) {
</div> </div>
<div className="divide-y divide-rule border-b border-rule"> <div className="divide-y divide-rule border-b border-rule">
{HOSTED_VS_SELF.map(({ icon: Icon, label, hosted, self }) => ( {HOSTED_VS_SELF.map(({ label, hosted, self }) => (
<div key={label} className="py-4 grid gap-2 md:grid-cols-[9rem_1fr_1fr] md:gap-x-6 md:items-start"> <div key={label} className="py-4 grid gap-2 md:grid-cols-[9rem_1fr_1fr] md:gap-x-6 md:items-start">
<div className="flex items-center gap-2 text-ink2"> <div className="flex items-center gap-2 text-ink2">
<Icon size={15} className="text-muted shrink-0" /> <Icon size={15} className="text-muted shrink-0" />

View file

@ -271,6 +271,9 @@ export default function ResultCard({ clip, index, jobId, durable, uploadPostKey,
}); });
} }
} }
// Reset only when the modal opens for a clip; connection changes while
// it is open must not wipe the user's selection.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [showModal, clip]); }, [showModal, clip]);
const handleAutoEdit = async () => { const handleAutoEdit = async () => {

View file

@ -81,8 +81,6 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
const [actorGallery, setActorGallery] = useState([]); const [actorGallery, setActorGallery] = useState([]);
const [loadingGallery, setLoadingGallery] = useState(false); const [loadingGallery, setLoadingGallery] = useState(false);
const [uploadedActorPreview, setUploadedActorPreview] = useState(null); // {localPreview, serverUrl} const [uploadedActorPreview, setUploadedActorPreview] = useState(null); // {localPreview, serverUrl}
const [productPhoto, setProductPhoto] = useState(null); // {preview, serverUrl}
const [productDescription, setProductDescription] = useState('');
// Step 3: Generate // Step 3: Generate
const [generating, setGenerating] = useState(false); const [generating, setGenerating] = useState(false);
@ -102,12 +100,14 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
const [copied, setCopied] = useState(''); const [copied, setCopied] = useState('');
const [logsExpanded, setLogsExpanded] = useState(true); const [logsExpanded, setLogsExpanded] = useState(true);
// Pre-fill from cache on mount // Pre-fill from cache on mount (once: later cache changes must not
// overwrite what the user typed).
useEffect(() => { useEffect(() => {
if (fromCache && scripts.length > 0 && !actorDescription) { if (fromCache && scripts.length > 0 && !actorDescription) {
setActorDescription(scripts[0].actor_description || ''); setActorDescription(scripts[0].actor_description || '');
setEditedNarration(scripts[0].full_narration || ''); setEditedNarration(scripts[0].full_narration || '');
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
// Fetch actor gallery on mount // Fetch actor gallery on mount
@ -125,6 +125,7 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
if (elevenLabsKey) { if (elevenLabsKey) {
fetchVoices(); fetchVoices();
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [elevenLabsKey]); }, [elevenLabsKey]);
// Reset selected voice when actor gender changes // Reset selected voice when actor gender changes
@ -142,6 +143,8 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
} else { } else {
setSelectedVoice(genderDefaults[`${language}-${actorGender}`] || genderDefaults['en-female']); setSelectedVoice(genderDefaults[`${language}-${actorGender}`] || genderDefaults['en-female']);
} }
// Re-pick only when the gender/language choice changes, not on every voices refresh.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [actorGender, language]); }, [actorGender, language]);
// Poll generation status // Poll generation status

View file

@ -55,6 +55,8 @@ export default function TopUpModal({ onClose, required, remaining, context = 'wa
setTopups(d.topups || []); setTopups(d.topups || []);
}) })
.catch(() => {}); .catch(() => {});
// Plans are fetched once per open; the props only shape the copy.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
// Instrumented in three steps on purpose. Between 25-jul and 1-ago the modals // Instrumented in three steps on purpose. Between 25-jul and 1-ago the modals

View file

@ -3,6 +3,7 @@ import Modal from './ui/Modal';
const DISMISS_KEY = 'os_watermark_notice_dismissed'; const DISMISS_KEY = 'os_watermark_notice_dismissed';
// eslint-disable-next-line react-refresh/only-export-components
export function watermarkNoticeDismissed() { export function watermarkNoticeDismissed() {
try { return localStorage.getItem(DISMISS_KEY) === '1'; } catch { return false; } try { return localStorage.getItem(DISMISS_KEY) === '1'; } catch { return false; }
} }

View file

@ -11,6 +11,7 @@ import { track } from '../lib/analytics';
import { report as reportAttribution } from '../lib/attribution'; import { report as reportAttribution } from '../lib/attribution';
const AuthContext = createContext(null); const AuthContext = createContext(null);
// eslint-disable-next-line react-refresh/only-export-components
export const useAuth = () => useContext(AuthContext); export const useAuth = () => useContext(AuthContext);
export function AuthProvider({ children }) { export function AuthProvider({ children }) {