mirror of
https://github.com/Donkie/Spoolman.git
synced 2026-10-21 17:42:16 -05:00
client_v2: re-enable no-navigation-without-resolve, scoped per file
5eb660f turned svelte/no-navigation-without-resolve off globally because every hit
at the time was a false positive: the href had already been resolved by a params.ts
helper or handed in as a pre-resolved prop. Switching the rule off repo-wide also
removed the only automated guard against the real bug it exists to catch, and that
bug is one nobody developing at the root path can see -- a missing resolve() works
perfectly until an operator deploys under SPOOLMAN_BASE_PATH.
The rule is on again. The eleven known-good sites are silenced where they live:
- Ten .svelte files carry a file-level disable inside their <script>, with the
reason attached via the `--` description syntax. Per-line disables don't work for
most of them -- the rule anchors on the href attribute, which prettier puts on its
own line inside a multi-line element, where an HTML comment can't go.
- params.ts's two goto() calls take eslint-disable-next-line each. Both targets are
base-path-independent already: a bare `?query` resolves against the current URL,
and the other is built from resolve('/').
A new file, or a new component that builds an href itself, is caught again. Verified
by adding a raw <a href="/spool/show/1"> and watching the rule fire.
This commit is contained in:
1 parent
89ffd3e4b1
commit
64e94bd97f
11 files changed
+43
-7
No files matched your search
@@ -31,13 +31,14 @@ export default ts.config(
|
||||
},
|
||||
rules: {
|
||||
// Typed as `no-undef`; TypeScript already reports undefined identifiers.
|
||||
'no-undef': 'off',
|
||||
// Base-path resolution is centralized in src/lib/library/params.ts helpers
|
||||
// (selectHref/libraryHref/etc. already call resolve() from $app/paths), and
|
||||
// generic components take a pre-resolved href prop. This rule can't see through
|
||||
// those helpers, so it only produces false positives here — and blindly wrapping
|
||||
// call sites in resolve() would double-apply the deploy base path.
|
||||
'svelte/no-navigation-without-resolve': 'off'
|
||||
'no-undef': 'off'
|
||||
// svelte/no-navigation-without-resolve is left ON: it is the only automated guard
|
||||
// against base-path navigation bugs, and those are invisible to anyone developing
|
||||
// at the root path. It can't see through the helpers in src/lib/library/params.ts
|
||||
// (selectHref/libraryHref/... already call resolve() from $app/paths) nor through
|
||||
// components that take an already-resolved href prop, so the files where that is
|
||||
// the case carry a file-level disable naming the reason. Never "fix" one of those
|
||||
// by wrapping the call site in resolve() — that double-applies the base path.
|
||||
// svelte/prefer-svelte-reactivity is left ON to guard against in-place mutation of
|
||||
// reactive Set/Map. The current hits are all transient computation-local collections
|
||||
// and are silenced with per-line eslint-disable comments at each site.
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Generic link component: `href` arrives already resolved against the deploy base
|
||||
path (the params.ts helpers that produce it call resolve()), so resolving it
|
||||
again here would double-apply the base path. */
|
||||
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||
// Inspector breadcrumb trail. The last item is the current entity (rendered
|
||||
// static); earlier items with an `href` are navigable links. A `muted` crumb
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Generic link component: `href` arrives already resolved against the deploy base
|
||||
path (the params.ts helpers that produce it call resolve()), so resolving it
|
||||
again here would double-apply the base path. */
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Generic link component: `href` arrives already resolved against the deploy base
|
||||
path (the params.ts helpers that produce it call resolve()), so resolving it
|
||||
again here would double-apply the base path. */
|
||||
import * as m from '$lib/paraglide/messages';
|
||||
import ChevronLeft from '@lucide/svelte/icons/chevron-left';
|
||||
import ChevronRight from '@lucide/svelte/icons/chevron-right';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Every href below comes from a src/lib/library/params.ts helper, which already
|
||||
resolves against the deploy base path; resolving again would double-apply it. */
|
||||
import Swatch from '../Swatch.svelte';
|
||||
import ColorEditor from '../ColorEditor.svelte';
|
||||
import Button from '../Button.svelte';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Every href below comes from a src/lib/library/params.ts helper, which already
|
||||
resolves against the deploy base path; resolving again would double-apply it. */
|
||||
import SearchInput from '../SearchInput.svelte';
|
||||
import Swatch from '../Swatch.svelte';
|
||||
import MaterialBadge from '../MaterialBadge.svelte';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Every href below comes from a src/lib/library/params.ts helper, which already
|
||||
resolves against the deploy base path; resolving again would double-apply it. */
|
||||
import Swatch from '../Swatch.svelte';
|
||||
import Button from '../Button.svelte';
|
||||
import NumberInput from '../NumberInput.svelte';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Every href below comes from a src/lib/library/params.ts helper, which already
|
||||
resolves against the deploy base path; resolving again would double-apply it. */
|
||||
import Swatch from '../Swatch.svelte';
|
||||
import ProgressBar from '../ProgressBar.svelte';
|
||||
import { rowIdentity, type RowContext, type SpoolVM } from '$lib/utils/library';
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Every href below comes from a src/lib/library/params.ts helper, which already
|
||||
resolves against the deploy base path; resolving again would double-apply it. */
|
||||
import Swatch from '../Swatch.svelte';
|
||||
import EditableField from '../EditableField.svelte';
|
||||
import NumberInput from '../NumberInput.svelte';
|
||||
|
||||
@@ -129,6 +129,9 @@ function currentState(): LibraryState {
|
||||
*/
|
||||
function navigate(next: LibraryState, replace = false): void {
|
||||
const qs = serializeState(next);
|
||||
// Both targets are base-path-independent: a bare `?query` resolves against the
|
||||
// current URL, and window.location.pathname already includes the base path.
|
||||
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
||||
goto(qs ? `?${qs}` : window.location.pathname, {
|
||||
replaceState: replace,
|
||||
keepFocus: true,
|
||||
@@ -270,5 +273,7 @@ export function openSearchResult(kind: EntityKind, id: string): void {
|
||||
}
|
||||
const p = new URLSearchParams();
|
||||
p.set('sel', `${kind}:${id}`);
|
||||
// libraryPath is `resolve('/')`, so the base path is already applied.
|
||||
// eslint-disable-next-line svelte/no-navigation-without-resolve
|
||||
goto(`${libraryPath}?${p.toString()}`, { noScroll: true });
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<script lang="ts">
|
||||
/* eslint-disable svelte/no-navigation-without-resolve --
|
||||
Every href below comes from a src/lib/library/params.ts helper, which already
|
||||
resolves against the deploy base path; resolving again would double-apply it. */
|
||||
import Swatch from '$components/Swatch.svelte';
|
||||
import type { Spool } from '$lib/types';
|
||||
import { inventory } from '$lib/stores/inventory.svelte';
|
||||
|
||||
Reference in new issue
Block a user