diff --git a/.changeset/thick-pans-tell.md b/.changeset/thick-pans-tell.md new file mode 100644 index 0000000000..396c31b49b --- /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 00e0920a3a..5c0b042cf6 100644 --- a/packages/svelte/scripts/generate-types.js +++ b/packages/svelte/scripts/generate-types.js @@ -37,3 +37,20 @@ 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) { + // 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}`); + } + + process.exit(1); +} diff --git a/packages/svelte/src/main/main-client.js b/packages/svelte/src/main/main-client.js index c813008d2b..019fc9c81f 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 diff --git a/packages/svelte/src/transition/index.js b/packages/svelte/src/transition/index.js index b3ebbbba0a..371c3e146e 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 & { diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index 6414dc80b2..01bbe7eaef 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 * */