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:
parent
fd0e39862c
commit
08e0eca92d
12 changed files with 522 additions and 3452 deletions
|
|
@ -10,7 +10,7 @@ export default defineConfig([
|
|||
files: ['**/*.{js,jsx}'],
|
||||
extends: [
|
||||
js.configs.recommended,
|
||||
reactHooks.configs.flat.recommended,
|
||||
reactHooks.configs['recommended-latest'],
|
||||
reactRefresh.configs.vite,
|
||||
],
|
||||
languageOptions: {
|
||||
|
|
@ -23,7 +23,22 @@ export default defineConfig([
|
|||
},
|
||||
},
|
||||
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 } },
|
||||
},
|
||||
])
|
||||
|
|
|
|||
3920
dashboard/package-lock.json
generated
3920
dashboard/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,7 @@
|
|||
"scripts": {
|
||||
"dev": "vite",
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
@ -21,14 +21,15 @@
|
|||
"zod": "^4.3.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.39.5",
|
||||
"@types/react": "^18.2.64",
|
||||
"@types/react-dom": "^18.2.21",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"autoprefixer": "^10.4.23",
|
||||
"eslint": "^8.57.0",
|
||||
"eslint-plugin-react": "^7.34.0",
|
||||
"eslint-plugin-react-hooks": "^4.6.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.5",
|
||||
"eslint": "^9.39.5",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"eslint-plugin-react-refresh": "^0.4.26",
|
||||
"globals": "^15.15.0",
|
||||
"postcss": "^8.5.6",
|
||||
"tailwindcss": "^3.4.19",
|
||||
"vite": "^4.5.3"
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ const NAV = `
|
|||
<a class="cta" href="${SITE.url}/">Get free clips</a>
|
||||
</div></header>`
|
||||
|
||||
const footer = (related) => `
|
||||
const footer = (_related) => `
|
||||
<footer class="site"><div class="wrap">
|
||||
<div class="row">
|
||||
<a href="${SITE.url}/">OpenShorts</a>
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ export default function Legal() {
|
|||
</div>
|
||||
|
||||
<div className="space-y-3 mb-12">
|
||||
{DOCS.map(({ icon: Icon, title, desc, href, es }) => (
|
||||
{DOCS.map(({ title, desc, href, es }) => (
|
||||
<a
|
||||
key={href}
|
||||
href={href}
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ export default function ClipEditor({ jobId, clipIndex, clipTitle, onClose, onRer
|
|||
const words = useMemo(() => (edl?.words || []), [edl]);
|
||||
const sourceAvailable = !!edl?.source?.available;
|
||||
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 minSeg = limits.min_segment_seconds || MIN_SEGMENT_SECONDS;
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ export default function PricingPage({ onRequireLogin }) {
|
|||
</div>
|
||||
|
||||
<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 className="flex items-center gap-2 text-ink2">
|
||||
<Icon size={15} className="text-muted shrink-0" />
|
||||
|
|
|
|||
|
|
@ -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]);
|
||||
|
||||
const handleAutoEdit = async () => {
|
||||
|
|
|
|||
|
|
@ -81,8 +81,6 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
|
|||
const [actorGallery, setActorGallery] = useState([]);
|
||||
const [loadingGallery, setLoadingGallery] = useState(false);
|
||||
const [uploadedActorPreview, setUploadedActorPreview] = useState(null); // {localPreview, serverUrl}
|
||||
const [productPhoto, setProductPhoto] = useState(null); // {preview, serverUrl}
|
||||
const [productDescription, setProductDescription] = useState('');
|
||||
|
||||
// Step 3: Generate
|
||||
const [generating, setGenerating] = useState(false);
|
||||
|
|
@ -102,12 +100,14 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
|
|||
const [copied, setCopied] = useState('');
|
||||
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(() => {
|
||||
if (fromCache && scripts.length > 0 && !actorDescription) {
|
||||
setActorDescription(scripts[0].actor_description || '');
|
||||
setEditedNarration(scripts[0].full_narration || '');
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// Fetch actor gallery on mount
|
||||
|
|
@ -125,6 +125,7 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
|
|||
if (elevenLabsKey) {
|
||||
fetchVoices();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [elevenLabsKey]);
|
||||
|
||||
// Reset selected voice when actor gender changes
|
||||
|
|
@ -142,6 +143,8 @@ export default function SaaShortsTab({ geminiApiKey, elevenLabsKey, falKey, uplo
|
|||
} else {
|
||||
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]);
|
||||
|
||||
// Poll generation status
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ export default function TopUpModal({ onClose, required, remaining, context = 'wa
|
|||
setTopups(d.topups || []);
|
||||
})
|
||||
.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
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import Modal from './ui/Modal';
|
|||
|
||||
const DISMISS_KEY = 'os_watermark_notice_dismissed';
|
||||
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export function watermarkNoticeDismissed() {
|
||||
try { return localStorage.getItem(DISMISS_KEY) === '1'; } catch { return false; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import { track } from '../lib/analytics';
|
|||
import { report as reportAttribution } from '../lib/attribution';
|
||||
|
||||
const AuthContext = createContext(null);
|
||||
// eslint-disable-next-line react-refresh/only-export-components
|
||||
export const useAuth = () => useContext(AuthContext);
|
||||
|
||||
export function AuthProvider({ children }) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue