The frontend had no JS/TS linter — only svelte-check. Add flat-config ESLint (typescript-eslint
+ eslint-plugin-svelte) and Prettier (tabs/single-quote, matching the existing style).
Rules encode "catch bugs, not enforce taste":
- svelte/require-each-key KEPT — it is the exact bug class as the feed mis-tap fix. Fixed every
flagged block: keyed activeFilters, filteredUsers, stagedFiles (by previewUrl), captionTags,
admin tabs/jobs/users, the export-viewer suggestions/filters/comments, and the static skeleton
loops.
- svelte/prefer-svelte-reactivity KEPT — inline-disabled only the verified-safe sites (a local
freq Map in a $derived.by, throwaway URLSearchParams query builders), with a reason each.
- svelte/no-navigation-without-resolve OFF — wants resolve() around every goto()/href; taste, not
a bug, and pure churn.
- svelte/no-unused-svelte-ignore OFF — those comments are consumed by svelte-check, which ESLint
can't see, so it wrongly calls them unused; removing them would reintroduce a11y warnings.
- no-explicit-any OFF for *.test.ts only (partial fixtures legitimately use any).
Real code fixes beyond keys: removed a dead jobLabel(), an unused ViewerComment import and unused
catch binding, an unused scroll-lock arg, and replaced an empty interface with a type alias.
Then `prettier --write` (54 files). Formatting only. Verified: eslint clean, svelte-check 0 errors,
vitest 46 passed, vite build succeeds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
71 lines
2.4 KiB
JavaScript
71 lines
2.4 KiB
JavaScript
import js from '@eslint/js';
|
|
import ts from 'typescript-eslint';
|
|
import svelte from 'eslint-plugin-svelte';
|
|
import prettier from 'eslint-config-prettier';
|
|
import globals from 'globals';
|
|
import svelteConfig from './svelte.config.js';
|
|
|
|
/**
|
|
* Flat-config ESLint for the SvelteKit frontend. Type-aware where it's cheap; Prettier owns
|
|
* formatting (its config is last so it disables every stylistic rule that would fight the formatter).
|
|
*/
|
|
export default ts.config(
|
|
js.configs.recommended,
|
|
...ts.configs.recommended,
|
|
...svelte.configs.recommended,
|
|
prettier,
|
|
...svelte.configs.prettier,
|
|
{
|
|
languageOptions: {
|
|
globals: { ...globals.browser, ...globals.node }
|
|
}
|
|
},
|
|
{
|
|
files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
projectService: true,
|
|
extraFileExtensions: ['.svelte'],
|
|
parser: ts.parser,
|
|
svelteConfig
|
|
}
|
|
}
|
|
},
|
|
{
|
|
rules: {
|
|
// A leading underscore is the deliberate "intentionally unused" marker (e.g. `{#each x as _}`).
|
|
'@typescript-eslint/no-unused-vars': [
|
|
'error',
|
|
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' }
|
|
],
|
|
// Off on purpose. This rule wants every `goto('/x')` / `href="/x"` wrapped in `resolve()`
|
|
// for typed routes. That is a taste/ergonomics preference, not a correctness rule — string
|
|
// routes work fine and the app uses them deliberately. We keep the rules that catch actual
|
|
// bugs (require-each-key, prefer-svelte-reactivity) and drop this churn.
|
|
'svelte/no-navigation-without-resolve': 'off',
|
|
// Off: `svelte-ignore` comments are consumed by the Svelte compiler / svelte-check, which
|
|
// ESLint cannot see — so it reports every one as "unused" even when it is actively
|
|
// suppressing a real svelte-check a11y warning. Removing them on ESLint's say-so would
|
|
// reintroduce those warnings. svelte-check is the authority on these, not ESLint.
|
|
'svelte/no-unused-svelte-ignore': 'off'
|
|
}
|
|
},
|
|
{
|
|
// Test fixtures legitimately use `any` for partial/mock shapes (e.g. a stub upload that only
|
|
// sets the two fields the function under test reads). Not worth threading full types through.
|
|
files: ['**/*.test.ts'],
|
|
rules: { '@typescript-eslint/no-explicit-any': 'off' }
|
|
},
|
|
{
|
|
ignores: [
|
|
'.svelte-kit/',
|
|
'build/',
|
|
'dist/',
|
|
'node_modules/',
|
|
'static/export-viewer/',
|
|
'*.config.js',
|
|
'*.config.ts'
|
|
]
|
|
}
|
|
);
|