From df6e46362f7a3544ed166a427fd23f80f77b0743 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 1 Feb 2024 11:23:00 -0500 Subject: [PATCH 1/4] fix: make inline doc links valid --- .changeset/thick-pans-tell.md | 5 +++++ packages/svelte/scripts/generate-types.js | 15 +++++++++++++++ packages/svelte/src/transition/index.js | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 .changeset/thick-pans-tell.md diff --git a/.changeset/thick-pans-tell.md b/.changeset/thick-pans-tell.md new file mode 100644 index 000000000000..396c31b49b5f --- /dev/null +++ b/.changeset/thick-pans-tell.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: make inline doc links valid diff --git a/packages/svelte/scripts/generate-types.js b/packages/svelte/scripts/generate-types.js index 00e0920a3af6..4fc8a980d9ff 100644 --- a/packages/svelte/scripts/generate-types.js +++ b/packages/svelte/scripts/generate-types.js @@ -37,3 +37,18 @@ await createBundle({ [`${pkg.name}/types/compiler/interfaces`]: `${dir}/src/compiler/types/legacy-interfaces.d.ts` } }); + +const types = fs.readFileSync(`${dir}/types/index.d.ts`, 'utf-8'); + +const bad_links = [...types.matchAll(/\]\((\/[^)]+)\)/g)]; +if (bad_links.length > 0) { + console.error( + `The following links in JSDoc annotations should be prefixed with https://svelte.dev:` + ); + + for (const [, link] of bad_links) { + console.error(`- ${link}`); + } + + process.exit(1); +} diff --git a/packages/svelte/src/transition/index.js b/packages/svelte/src/transition/index.js index b3ebbbba0adc..371c3e146ed7 100644 --- a/packages/svelte/src/transition/index.js +++ b/packages/svelte/src/transition/index.js @@ -215,7 +215,7 @@ function assign(tar, src) { } /** - * The `crossfade` function creates a pair of [transitions](/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. + * The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. * * https://svelte.dev/docs/svelte-transition#crossfade * @param {import('./public').CrossfadeParams & { From b7237376319a8096a5267a2d0ac2deeef5f3fe1f Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 1 Feb 2024 11:24:02 -0500 Subject: [PATCH 2/4] couple more --- packages/svelte/src/main/main-client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/main/main-client.js b/packages/svelte/src/main/main-client.js index c813008d2b1e..019fc9c81fe9 100644 --- a/packages/svelte/src/main/main-client.js +++ b/packages/svelte/src/main/main-client.js @@ -17,7 +17,7 @@ import { is_array } from '../internal/client/utils.js'; * * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted. * - * `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api). + * `onMount` does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api). * * https://svelte.dev/docs/svelte#onmount * @template T @@ -107,7 +107,7 @@ function create_custom_event(type, detail, { bubbles = false, cancelable = false } /** - * Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname). + * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname). * Event dispatchers are functions that can take two arguments: `name` and `detail`. * * Component events created with `createEventDispatcher` create a From 7f0216f79193fd88a1a3dbdd82fd2ae5c707eea9 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 1 Feb 2024 11:30:16 -0500 Subject: [PATCH 3/4] doh --- packages/svelte/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index 6414dc80b2f7..01bbe7eaefd7 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -229,7 +229,7 @@ declare module 'svelte' { * * If a function is returned _synchronously_ from `onMount`, it will be called when the component is unmounted. * - * `onMount` does not run inside a [server-side component](/docs#run-time-server-side-component-api). + * `onMount` does not run inside a [server-side component](https://svelte.dev/docs#run-time-server-side-component-api). * * https://svelte.dev/docs/svelte#onmount * */ @@ -267,7 +267,7 @@ declare module 'svelte' { * */ export function getAllContexts = Map>(): T; /** - * Creates an event dispatcher that can be used to dispatch [component events](/docs#template-syntax-component-directives-on-eventname). + * Creates an event dispatcher that can be used to dispatch [component events](https://svelte.dev/docs#template-syntax-component-directives-on-eventname). * Event dispatchers are functions that can take two arguments: `name` and `detail`. * * Component events created with `createEventDispatcher` create a @@ -2169,7 +2169,7 @@ declare module 'svelte/transition' { getTotalLength(): number; }, { delay, speed, duration, easing }?: DrawParams | undefined): TransitionConfig; /** - * The `crossfade` function creates a pair of [transitions](/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. + * The `crossfade` function creates a pair of [transitions](https://svelte.dev/docs#template-syntax-element-directives-transition-fn) called `send` and `receive`. When an element is 'sent', it looks for a corresponding element being 'received', and generates a transition that transforms the element to its counterpart's position and fades it out. When an element is 'received', the reverse happens. If there is no counterpart, the `fallback` transition is used. * * https://svelte.dev/docs/svelte-transition#crossfade * */ From f6edb436b7b1dab2ac0e7f4802c7b4092a912312 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 1 Feb 2024 11:40:26 -0500 Subject: [PATCH 4/4] ugh --- packages/svelte/scripts/generate-types.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/svelte/scripts/generate-types.js b/packages/svelte/scripts/generate-types.js index 4fc8a980d9ff..5c0b042cf6b0 100644 --- a/packages/svelte/scripts/generate-types.js +++ b/packages/svelte/scripts/generate-types.js @@ -42,11 +42,13 @@ const types = fs.readFileSync(`${dir}/types/index.d.ts`, 'utf-8'); const bad_links = [...types.matchAll(/\]\((\/[^)]+)\)/g)]; if (bad_links.length > 0) { + // eslint-disable-next-line no-console console.error( `The following links in JSDoc annotations should be prefixed with https://svelte.dev:` ); for (const [, link] of bad_links) { + // eslint-disable-next-line no-console console.error(`- ${link}`); }