diff --git a/eslint.config.js b/eslint.config.js index 1924af9fa5a..4ca26296b16 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,4 +1,5 @@ import tseslint from 'typescript-eslint' +import jsdoc from 'eslint-plugin-jsdoc' import preferLet from 'eslint-plugin-prefer-let' /** @type {import('eslint').Linter.Config[]} */ @@ -7,6 +8,7 @@ export default [ ignores: [ '**/*.d.ts', '**/dist/**', + '**/docs/**', '**/coverage/**', '**/bench/**', '**/examples/**', @@ -85,4 +87,88 @@ export default [ 'no-var': 'error', }, }, + { + files: ['packages/**/*.{ts,tsx}'], + ignores: ['packages/**/*.test.ts'], + plugins: { jsdoc }, + settings: { + jsdoc: { + // Set our own contexts at the root to identify the types of things we care + // to enforce JSDoc rules on. Mostly we care about: + // - exported public APIs + // - not private class methods + // - not private class properties + // - not anything marked `@private` (`ignorePrivate` setting) + contexts: [ + // function foo() {} + 'ClassDeclaration', + // function foo() {} + 'FunctionDeclaration', + // let foo = function () {} + ':not(MethodDefinition) > FunctionExpression', + // Class{ foo() {} } but not Class{ #foo() {} } or Class { get foo() {} } + 'MethodDefinition:not([kind=get]):not([key.type=PrivateIdentifier]) FunctionExpression', + // let foo = () => {} + ':not(PropertyDefinition) > ArrowFunctionExpression', + // Class{ foo = () => {} } but not Class{ #foo = () => {} } + 'PropertyDefinition:not([key.type=PrivateIdentifier]) ArrowFunctionExpression', + ], + ignorePrivate: true, + tagNamePreference: { + // TODO: Temporarily allow both `@returns` and `@return`, but + // eventually we can find/replace to the standard `@returns` and + // remove this setting + return: 'return', + }, + }, + }, + rules: { + // Using modified base rulesets from: + // https://github.com/gajus/eslint-plugin-jsdoc?tab=readme-ov-file#granular-flat-configs + + // Modified version of jsdoc/flat/contents-typescript-error + 'jsdoc/informative-docs': 'off', + 'jsdoc/match-description': 'off', + 'jsdoc/no-blank-block-descriptions': 'error', + 'jsdoc/no-blank-blocks': 'error', + 'jsdoc/text-escaping': 'off', + + // Modified version of jsdoc/flat/logical-typescript-error + 'jsdoc/check-access': 'error', + 'jsdoc/check-param-names': 'error', + 'jsdoc/check-property-names': 'error', + 'jsdoc/check-syntax': 'error', + 'jsdoc/check-tag-names': ['error'], + 'jsdoc/check-template-names': 'error', + 'jsdoc/check-types': 'error', + 'jsdoc/check-values': 'error', + 'jsdoc/empty-tags': 'error', + 'jsdoc/escape-inline-tags': 'error', + 'jsdoc/implements-on-classes': 'error', + 'jsdoc/require-returns-check': 'error', + 'jsdoc/require-yields-check': 'error', + 'jsdoc/no-bad-blocks': 'error', + 'jsdoc/no-defaults': 'error', + 'jsdoc/no-types': 'error', + 'jsdoc/no-undefined-types': 'error', + 'jsdoc/valid-types': 'error', + + // Modified version of jsdoc/flat/stylistic-typescript-error + 'jsdoc/check-alignment': 'error', + 'jsdoc/check-line-alignment': 'error', + 'jsdoc/lines-before-block': 'off', + 'jsdoc/multiline-blocks': 'error', + 'jsdoc/no-multi-asterisks': 'error', + 'jsdoc/require-asterisk-prefix': 'error', + 'jsdoc/require-hyphen-before-param-description': ['error', 'never'], + 'jsdoc/tag-lines': 'off', + + // Additional rules we manually added + 'jsdoc/require-param': 'error', + 'jsdoc/require-param-description': 'error', + 'jsdoc/require-param-name': 'error', + 'jsdoc/require-returns': 'error', + 'jsdoc/require-returns-description': 'error', + }, + }, ] diff --git a/package.json b/package.json index 75697b8a958..f4e91ecd583 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dependencies": { "@typescript/native-preview": "catalog:", "eslint": "^9.33.0", + "eslint-plugin-jsdoc": "^61.5.0", "eslint-plugin-prefer-let": "^4.0.0", "prettier": "^3.3.3", "tsx": "catalog:", diff --git a/packages/async-context-middleware/src/lib/async-context.ts b/packages/async-context-middleware/src/lib/async-context.ts index a1250d60922..cd1d1511c19 100644 --- a/packages/async-context-middleware/src/lib/async-context.ts +++ b/packages/async-context-middleware/src/lib/async-context.ts @@ -8,7 +8,7 @@ const storage = new AsyncLocalStorage() * Middleware that stores the request context in `AsyncLocalStorage` so it is available * to all functions in the same async execution context. * - * @return A middleware function that stores the request context in `AsyncLocalStorage` + * @returns A middleware function that stores the request context in `AsyncLocalStorage` */ export function asyncContext(): Middleware { return (context, next) => storage.run(context, next) @@ -17,7 +17,7 @@ export function asyncContext(): Middleware { /** * Get the request context from `AsyncLocalStorage`. * - * @return The request context + * @returns The request context */ export function getContext(): RequestContext { let context = storage.getStore() diff --git a/packages/cookie/src/lib/cookie.ts b/packages/cookie/src/lib/cookie.ts index 56ec6ee47b8..0c86ec82d02 100644 --- a/packages/cookie/src/lib/cookie.ts +++ b/packages/cookie/src/lib/cookie.ts @@ -154,7 +154,7 @@ export class Cookie implements CookieProperties { * Extracts the value of this cookie from a `Cookie` header value. * * @param headerValue The `Cookie` header to parse - * @return The value of this cookie, or `null` if it's not present + * @returns The value of this cookie, or `null` if it's not present */ async parse(headerValue: string | null): Promise { if (!headerValue) return null @@ -218,7 +218,7 @@ export class Cookie implements CookieProperties { * * @param value The value to serialize * @param props Additional properties to use when serializing the cookie - * @return The `Set-Cookie` header value for this cookie + * @returns The `Set-Cookie` header value for this cookie */ async serialize(value: string, props?: CookieProperties): Promise { let header = new SetCookieHeader({ @@ -251,7 +251,7 @@ export class Cookie implements CookieProperties { * * @param name The name of the cookie * @param options Options for the cookie - * @return A new `Cookie` object + * @returns A new `Cookie` object */ export function createCookie(name: string, options?: CookieOptions): Cookie { return new Cookie(name, options) diff --git a/packages/fetch-proxy/src/lib/fetch-proxy.ts b/packages/fetch-proxy/src/lib/fetch-proxy.ts index 214345efc7f..0838f5278c3 100644 --- a/packages/fetch-proxy/src/lib/fetch-proxy.ts +++ b/packages/fetch-proxy/src/lib/fetch-proxy.ts @@ -38,7 +38,7 @@ export interface FetchProxyOptions { * * @param input The URL or request to forward * @param init Optional request init options - * @return A promise that resolves to the proxied response + * @returns A promise that resolves to the proxied response */ export interface FetchProxy { (input: URL | RequestInfo, init?: RequestInit): Promise @@ -49,7 +49,7 @@ export interface FetchProxy { * * @param target The URL of the server to proxy requests to * @param options Options to customize the behavior of the proxy - * @return A fetch function that forwards requests to the target server + * @returns A fetch function that forwards requests to the target server */ export function createFetchProxy(target: string | URL, options?: FetchProxyOptions): FetchProxy { let localFetch = options?.fetch ?? globalThis.fetch diff --git a/packages/fetch-router/src/lib/app-storage.ts b/packages/fetch-router/src/lib/app-storage.ts index 2635fb7559f..7498844d55c 100644 --- a/packages/fetch-router/src/lib/app-storage.ts +++ b/packages/fetch-router/src/lib/app-storage.ts @@ -8,7 +8,7 @@ export class AppStorage { * Check if a value is stored for the given key. * * @param key The key to check - * @return `true` if a value is stored for the given key, `false` otherwise + * @returns `true` if a value is stored for the given key, `false` otherwise */ has>(key: key): boolean { return this.#map.has(key) @@ -18,7 +18,7 @@ export class AppStorage { * Get a value from storage. * * @param key The key to get - * @return The value for the given key + * @returns The value for the given key */ get>(key: key): StorageValue { if (!this.#map.has(key)) { @@ -47,7 +47,7 @@ export class AppStorage { * Create a storage key with an optional default value. * * @param defaultValue The default value for the storage key - * @return The new storage key + * @returns The new storage key */ export function createStorageKey(defaultValue?: T): StorageKey { return { defaultValue } diff --git a/packages/fetch-router/src/lib/controller.ts b/packages/fetch-router/src/lib/controller.ts index be69a137b8b..4c2dc768735 100644 --- a/packages/fetch-router/src/lib/controller.ts +++ b/packages/fetch-router/src/lib/controller.ts @@ -63,7 +63,7 @@ export type BuildAction Promise diff --git a/packages/fetch-router/src/lib/route-helpers/form.ts b/packages/fetch-router/src/lib/route-helpers/form.ts index 2d7719bc33f..c887f50c5c2 100644 --- a/packages/fetch-router/src/lib/route-helpers/form.ts +++ b/packages/fetch-router/src/lib/route-helpers/form.ts @@ -27,7 +27,7 @@ export interface FormOptions { * * @param pattern The route pattern to use for the form and its submit action * @param options Options to configure the form action routes - * @return The route map with `index` and `action` routes + * @returns The route map with `index` and `action` routes */ export function createFormRoutes( pattern: pattern | RoutePattern, diff --git a/packages/fetch-router/src/lib/route-helpers/resource.ts b/packages/fetch-router/src/lib/route-helpers/resource.ts index 21499e68399..fb4683a269b 100644 --- a/packages/fetch-router/src/lib/route-helpers/resource.ts +++ b/packages/fetch-router/src/lib/route-helpers/resource.ts @@ -45,7 +45,7 @@ export type ResourceOptions = { * * @param base The base route pattern to use for the resource * @param options Options to configure the resource routes - * @return The route map with CRUD routes + * @returns The route map with CRUD routes */ export function createResourceRoutes( base: base | RoutePattern, diff --git a/packages/fetch-router/src/lib/route-helpers/resources.ts b/packages/fetch-router/src/lib/route-helpers/resources.ts index c58ff06bcf4..2b72d00acdb 100644 --- a/packages/fetch-router/src/lib/route-helpers/resources.ts +++ b/packages/fetch-router/src/lib/route-helpers/resources.ts @@ -52,7 +52,7 @@ export type ResourcesOptions = { * * @param base The base route pattern to use for the resources * @param options Options to configure the resource routes - * @return The route map with CRUD routes + * @returns The route map with CRUD routes */ export function createResourcesRoutes( base: base | RoutePattern, diff --git a/packages/fetch-router/src/lib/route-map.ts b/packages/fetch-router/src/lib/route-map.ts index bca298d8d5a..fc9cf6546de 100644 --- a/packages/fetch-router/src/lib/route-map.ts +++ b/packages/fetch-router/src/lib/route-map.ts @@ -41,7 +41,7 @@ export class Route< * Build a URL href for this route using the given parameters. * * @param args The parameters to use for building the href - * @return The built URL href + * @returns The built URL href */ href(...args: HrefBuilderArgs): string { return this.pattern.href(...args) @@ -51,7 +51,7 @@ export class Route< * Match a URL against this route's pattern. * * @param url The URL to match - * @return The match result, or `null` if the URL doesn't match + * @returns The match result, or `null` if the URL doesn't match */ match(url: string | URL): RouteMatch | null { return this.pattern.match(url) @@ -71,7 +71,7 @@ export type BuildRoute(defs: defs): BuildRouteMap<'/', defs> /** @@ -79,7 +79,7 @@ export function createRoutes(defs: defs): BuildRou * * @param base The base pattern for all routes * @param defs The route definitions - * @return The route map + * @returns The route map */ export function createRoutes( base: base | RoutePattern, @@ -128,7 +128,7 @@ export type BuildRouteMap = Simplif }> // prettier-ignore -type BuildRouteWithBase = +type BuildRouteWithBase = def extends string ? Route<'ANY', Join> : def extends RoutePattern ? Route<'ANY', Join> : def extends { method: infer method extends RequestMethod | 'ANY', pattern: infer pattern } ? ( diff --git a/packages/fetch-router/src/lib/router.ts b/packages/fetch-router/src/lib/router.ts index ccb5b50ddcc..a33f7a27825 100644 --- a/packages/fetch-router/src/lib/router.ts +++ b/packages/fetch-router/src/lib/router.ts @@ -71,7 +71,7 @@ export interface Router { * * @param input The request input to fetch * @param init The request init options - * @return The response from the route that matched the request + * @returns The response from the route that matched the request */ fetch(input: string | URL | Request, init?: RequestInit): Promise /** @@ -177,7 +177,7 @@ function noMatchHandler({ url }: RequestContext): Response { * Create a new router. * * @param options Options to configure the router - * @return The new router + * @returns The new router */ export function createRouter(options?: RouterOptions): Router { let defaultHandler = options?.defaultHandler ?? noMatchHandler diff --git a/packages/file-storage/src/lib/file-storage.ts b/packages/file-storage/src/lib/file-storage.ts index f0d0c549d1f..102eb4e1275 100644 --- a/packages/file-storage/src/lib/file-storage.ts +++ b/packages/file-storage/src/lib/file-storage.ts @@ -6,14 +6,14 @@ export interface FileStorage { * Get a [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) at the given key. * * @param key The key to look up - * @return The file with the given key, or `null` if no such key exists + * @returns The file with the given key, or `null` if no such key exists */ get(key: string): File | null | Promise /** * Check if a file with the given key exists. * * @param key The key to look up - * @return `true` if a file with the given key exists, `false` otherwise + * @returns `true` if a file with the given key exists, `false` otherwise */ has(key: string): boolean | Promise /** @@ -73,7 +73,7 @@ export interface FileStorage { * Use the `limit` option to limit how many results you get back in the `files` array. * * @param options Options for the list operation - * @return An object with an array of `files` and an optional `cursor` property + * @returns An object with an array of `files` and an optional `cursor` property */ list(options?: T): ListResult | Promise> /** @@ -82,7 +82,7 @@ export interface FileStorage { * * @param key The key to store the file under * @param file The file to store - * @return A new `File` object backed by this storage + * @returns A new `File` object backed by this storage */ put(key: string, file: File): File | Promise /** diff --git a/packages/form-data-middleware/src/lib/form-data.ts b/packages/form-data-middleware/src/lib/form-data.ts index c9eba79aa27..b8b5a506eb7 100644 --- a/packages/form-data-middleware/src/lib/form-data.ts +++ b/packages/form-data-middleware/src/lib/form-data.ts @@ -28,7 +28,7 @@ export interface FormDataOptions extends ParseFormDataOptions { * Middleware that parses `FormData` from the request body and populates `context.formData`. * * @param options Options for parsing form data - * @return A middleware function that parses form data + * @returns A middleware function that parses form data */ export function formData(options?: FormDataOptions): Middleware { let suppressErrors = options?.suppressErrors ?? false diff --git a/packages/form-data-parser/src/lib/form-data.ts b/packages/form-data-parser/src/lib/form-data.ts index 66bb22046fe..20828c62a43 100644 --- a/packages/form-data-parser/src/lib/form-data.ts +++ b/packages/form-data-parser/src/lib/form-data.ts @@ -30,7 +30,7 @@ export class MaxFilesExceededError extends FormDataParseError { */ export class FileUpload extends File { /** - * The name of the field used to upload the file. + * The name of the `` field used to upload the file. */ readonly fieldName: string @@ -47,7 +47,7 @@ export class FileUpload extends File { * A function used for handling file uploads. * * @param file The uploaded file - * @return A value to store in `FormData`, or `void`/`null` to skip + * @returns A value to store in `FormData`, or `void`/`null` to skip */ export interface FileUploadHandler { (file: FileUpload): void | null | string | Blob | Promise @@ -84,7 +84,7 @@ export interface ParseFormDataOptions extends MultipartParserOptions { * @param request The `Request` object to parse * @param options Options for the parser * @param uploadHandler A function that handles file uploads. It receives a `File` object and may return any value that is valid in a `FormData` object - * @return A `Promise` that resolves to a `FormData` object containing the parsed data + * @returns A `Promise` that resolves to a `FormData` object containing the parsed data */ export async function parseFormData( request: Request, diff --git a/packages/fs/src/lib/fs.ts b/packages/fs/src/lib/fs.ts index e5ccb9f56f8..01a5228dbf8 100644 --- a/packages/fs/src/lib/fs.ts +++ b/packages/fs/src/lib/fs.ts @@ -38,7 +38,7 @@ export interface OpenFileOptions { * @alias getFile * @param filename The path to the file * @param options Options to override the file's metadata - * @return A `File` object + * @returns A `File` object */ export function openFile(filename: string, options?: OpenFileOptions): File { let stats = fs.statSync(filename) @@ -90,7 +90,7 @@ export { type OpenFileOptions as GetFileOptions, openFile as getFile } * * @param to The path to write the file to, or an open file descriptor * @param file The file to write - * @return A promise that resolves when the file is written + * @returns A promise that resolves when the file is written */ export function writeFile(to: string | number | fs.promises.FileHandle, file: File): Promise { return new Promise(async (resolve, reject) => { diff --git a/packages/headers/src/lib/accept-encoding.ts b/packages/headers/src/lib/accept-encoding.ts index 94dd67d3057..279a449f897 100644 --- a/packages/headers/src/lib/accept-encoding.ts +++ b/packages/headers/src/lib/accept-encoding.ts @@ -89,7 +89,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { * Returns `true` if the header matches the given encoding (i.e. it is "acceptable"). * * @param encoding The encoding to check - * @return `true` if the encoding is acceptable, `false` otherwise + * @returns `true` if the encoding is acceptable, `false` otherwise */ accepts(encoding: string): boolean { return encoding.toLowerCase() === 'identity' || this.getWeight(encoding) > 0 @@ -99,7 +99,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { * Gets the weight an encoding. Performs wildcard matching so `*` matches all encodings. * * @param encoding The encoding to get - * @return The weight of the encoding, or `0` if it is not in the header + * @returns The weight of the encoding, or `0` if it is not in the header */ getWeight(encoding: string): number { let lower = encoding.toLowerCase() @@ -117,7 +117,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { * Returns the most preferred encoding from the given list of encodings. * * @param encodings The encodings to choose from - * @return The most preferred encoding or `null` if none match + * @returns The most preferred encoding or `null` if none match */ getPreferred(encodings: readonly encoding[]): encoding | null { let sorted = encodings @@ -133,7 +133,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { * Gets the weight of an encoding. If it is not in the header verbatim, this returns `null`. * * @param encoding The encoding to get - * @return The weight of the encoding, or `null` if it is not in the header + * @returns The weight of the encoding, or `null` if it is not in the header */ get(encoding: string): number | null { return this.#map.get(encoding.toLowerCase()) ?? null @@ -163,7 +163,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { * Checks if the header contains a given encoding. * * @param encoding The encoding to check - * @return `true` if the encoding is in the header, `false` otherwise + * @returns `true` if the encoding is in the header, `false` otherwise */ has(encoding: string): boolean { return this.#map.has(encoding.toLowerCase()) @@ -179,7 +179,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { /** * Returns an iterator of all encoding and weight pairs. * - * @return An iterator of `[encoding, weight]` tuples + * @returns An iterator of `[encoding, weight]` tuples */ entries(): IterableIterator<[string, number]> { return this.#map.entries() @@ -207,7 +207,7 @@ export class AcceptEncoding implements HeaderValue, Iterable<[string, number]> { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { let pairs: string[] = [] diff --git a/packages/headers/src/lib/accept-language.ts b/packages/headers/src/lib/accept-language.ts index 7cc9ff064fc..9e1b138f9ee 100644 --- a/packages/headers/src/lib/accept-language.ts +++ b/packages/headers/src/lib/accept-language.ts @@ -89,7 +89,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { * Returns `true` if the header matches the given language (i.e. it is "acceptable"). * * @param language The locale identifier of the language to check - * @return `true` if the language is acceptable, `false` otherwise + * @returns `true` if the language is acceptable, `false` otherwise */ accepts(language: string): boolean { return this.getWeight(language) > 0 @@ -100,7 +100,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { * matching, so `en` matches `en-US` and `en-GB`, and `*` matches all languages. * * @param language The locale identifier of the language to get - * @return The weight of the language, or `0` if it is not in the header + * @returns The weight of the language, or `0` if it is not in the header */ getWeight(language: string): number { let [base, subtype] = language.toLowerCase().split('-') @@ -122,7 +122,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { * Returns the most preferred language from the given list of languages. * * @param languages The locale identifiers of the languages to choose from - * @return The most preferred language or `null` if none match + * @returns The most preferred language or `null` if none match */ getPreferred(languages: readonly language[]): language | null { let sorted = languages @@ -139,7 +139,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { * verbatim, this returns `null`. * * @param language The locale identifier of the language to get - * @return The weight of the language, or `null` if it is not in the header + * @returns The weight of the language, or `null` if it is not in the header */ get(language: string): number | null { return this.#map.get(language.toLowerCase()) ?? null @@ -169,7 +169,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { * Checks if the header contains a language with the given locale identifier. * * @param language The locale identifier of the language to check - * @return `true` if the language is in the header, `false` otherwise + * @returns `true` if the language is in the header, `false` otherwise */ has(language: string): boolean { return this.#map.has(language.toLowerCase()) @@ -185,7 +185,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { /** * Returns an iterator of all language and weight pairs. * - * @return An iterator of `[language, weight]` tuples + * @returns An iterator of `[language, weight]` tuples */ entries(): IterableIterator<[string, number]> { return this.#map.entries() @@ -213,7 +213,7 @@ export class AcceptLanguage implements HeaderValue, Iterable<[string, number]> { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { let pairs: string[] = [] diff --git a/packages/headers/src/lib/accept.ts b/packages/headers/src/lib/accept.ts index 65ff1904424..9a30722b67d 100644 --- a/packages/headers/src/lib/accept.ts +++ b/packages/headers/src/lib/accept.ts @@ -89,7 +89,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { * Returns `true` if the header matches the given media type (i.e. it is "acceptable"). * * @param mediaType The media type to check - * @return `true` if the media type is acceptable, `false` otherwise + * @returns `true` if the media type is acceptable, `false` otherwise */ accepts(mediaType: string): boolean { return this.getWeight(mediaType) > 0 @@ -99,7 +99,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { * Gets the weight of a given media type. Also supports wildcards, so e.g. `text/*` will match `text/html`. * * @param mediaType The media type to get the weight of - * @return The weight of the media type + * @returns The weight of the media type */ getWeight(mediaType: string): number { let [type, subtype] = mediaType.toLowerCase().split('/') @@ -121,7 +121,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { * Returns the most preferred media type from the given list of media types. * * @param mediaTypes The list of media types to choose from - * @return The most preferred media type or `null` if none match + * @returns The most preferred media type or `null` if none match */ getPreferred(mediaTypes: readonly mediaType[]): mediaType | null { let sorted = mediaTypes @@ -137,7 +137,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { * Returns the weight of a media type. If it is not in the header verbatim, this returns `null`. * * @param mediaType The media type to get the weight of - * @return The weight of the media type, or `null` if it is not in the header + * @returns The weight of the media type, or `null` if it is not in the header */ get(mediaType: string): number | null { return this.#map.get(mediaType.toLowerCase()) ?? null @@ -167,7 +167,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { * Checks if a media type is in the header. * * @param mediaType The media type to check - * @return `true` if the media type is in the header (verbatim), `false` otherwise + * @returns `true` if the media type is in the header (verbatim), `false` otherwise */ has(mediaType: string): boolean { return this.#map.has(mediaType.toLowerCase()) @@ -183,7 +183,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { /** * Returns an iterator of all media type and weight pairs. * - * @return An iterator of `[mediaType, weight]` tuples + * @returns An iterator of `[mediaType, weight]` tuples */ entries(): IterableIterator<[string, number]> { return this.#map.entries() @@ -211,7 +211,7 @@ export class Accept implements HeaderValue, Iterable<[string, number]> { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { let pairs: string[] = [] diff --git a/packages/headers/src/lib/cache-control.ts b/packages/headers/src/lib/cache-control.ts index 8a1268ba821..03fc120a654 100644 --- a/packages/headers/src/lib/cache-control.ts +++ b/packages/headers/src/lib/cache-control.ts @@ -264,7 +264,7 @@ export class CacheControl implements HeaderValue, CacheControlInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { let parts = [] diff --git a/packages/headers/src/lib/content-disposition.ts b/packages/headers/src/lib/content-disposition.ts index ba7a7b45f55..b9c02298d42 100644 --- a/packages/headers/src/lib/content-disposition.ts +++ b/packages/headers/src/lib/content-disposition.ts @@ -88,7 +88,7 @@ export class ContentDisposition implements HeaderValue, ContentDispositionInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { if (!this.type) { diff --git a/packages/headers/src/lib/content-range.ts b/packages/headers/src/lib/content-range.ts index df1257b85aa..5ee97ea09c4 100644 --- a/packages/headers/src/lib/content-range.ts +++ b/packages/headers/src/lib/content-range.ts @@ -64,7 +64,7 @@ export class ContentRange implements HeaderValue, ContentRangeInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { if (!this.unit || this.size === undefined) return '' diff --git a/packages/headers/src/lib/content-type.ts b/packages/headers/src/lib/content-type.ts index d2c77b2c9dd..4feb3ce8f07 100644 --- a/packages/headers/src/lib/content-type.ts +++ b/packages/headers/src/lib/content-type.ts @@ -65,7 +65,7 @@ export class ContentType implements HeaderValue, ContentTypeInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { if (!this.mediaType) { diff --git a/packages/headers/src/lib/cookie.ts b/packages/headers/src/lib/cookie.ts index e55802e9f9f..f7391716038 100644 --- a/packages/headers/src/lib/cookie.ts +++ b/packages/headers/src/lib/cookie.ts @@ -65,7 +65,7 @@ export class Cookie implements HeaderValue, Iterable<[string, string]> { * Gets the value of a cookie with the given name from the header. * * @param name The name of the cookie - * @return The value of the cookie, or `null` if the cookie does not exist + * @returns The value of the cookie, or `null` if the cookie does not exist */ get(name: string): string | null { return this.#map.get(name) ?? null @@ -94,7 +94,7 @@ export class Cookie implements HeaderValue, Iterable<[string, string]> { * True if a cookie with the given name exists in the header. * * @param name The name of the cookie - * @return `true` if a cookie with the given name exists in the header + * @returns `true` if a cookie with the given name exists in the header */ has(name: string): boolean { return this.#map.has(name) @@ -110,7 +110,7 @@ export class Cookie implements HeaderValue, Iterable<[string, string]> { /** * Returns an iterator of all cookie name and value pairs. * - * @return An iterator of `[name, value]` tuples + * @returns An iterator of `[name, value]` tuples */ entries(): IterableIterator<[string, string]> { return this.#map.entries() @@ -135,7 +135,7 @@ export class Cookie implements HeaderValue, Iterable<[string, string]> { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { let pairs: string[] = [] diff --git a/packages/headers/src/lib/if-match.ts b/packages/headers/src/lib/if-match.ts index 986a442d176..475dd7c7168 100644 --- a/packages/headers/src/lib/if-match.ts +++ b/packages/headers/src/lib/if-match.ts @@ -42,7 +42,7 @@ export class IfMatch implements HeaderValue, IfMatchInit { * Note: This method checks only for exact matches and does not consider wildcards. * * @param tag The entity tag to check for - * @return `true` if the tag is present in the header, `false` otherwise + * @returns `true` if the tag is present in the header, `false` otherwise */ has(tag: string): boolean { return this.tags.includes(quoteEtag(tag)) @@ -58,7 +58,7 @@ export class IfMatch implements HeaderValue, IfMatchInit { * will never match. * * @param tag The entity tag to check against - * @return `true` if the precondition passes, `false` if it fails (should return 412) + * @returns `true` if the precondition passes, `false` if it fails (should return 412) */ matches(tag: string): boolean { if (this.tags.length === 0) { @@ -90,7 +90,7 @@ export class IfMatch implements HeaderValue, IfMatchInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString() { return this.tags.join(', ') diff --git a/packages/headers/src/lib/if-none-match.ts b/packages/headers/src/lib/if-none-match.ts index 172b7d6e594..04930515a6e 100644 --- a/packages/headers/src/lib/if-none-match.ts +++ b/packages/headers/src/lib/if-none-match.ts @@ -42,7 +42,7 @@ export class IfNoneMatch implements HeaderValue, IfNoneMatchInit { * Note: This method checks only for exact matches and does not consider wildcards. * * @param tag The entity tag to check for - * @return `true` if the tag is present in the header, `false` otherwise + * @returns `true` if the tag is present in the header, `false` otherwise */ has(tag: string): boolean { return this.tags.includes(quoteEtag(tag)) @@ -52,7 +52,7 @@ export class IfNoneMatch implements HeaderValue, IfNoneMatchInit { * Checks if this header matches the given entity tag. * * @param tag The entity tag to check for - * @return `true` if the tag is present in the header (or the header contains a wildcard), `false` otherwise + * @returns `true` if the tag is present in the header (or the header contains a wildcard), `false` otherwise */ matches(tag: string): boolean { return this.has(tag) || this.tags.includes('*') @@ -61,7 +61,7 @@ export class IfNoneMatch implements HeaderValue, IfNoneMatchInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString() { return this.tags.join(', ') diff --git a/packages/headers/src/lib/if-range.ts b/packages/headers/src/lib/if-range.ts index 919171e91b8..4975eb4a4d0 100644 --- a/packages/headers/src/lib/if-range.ts +++ b/packages/headers/src/lib/if-range.ts @@ -41,7 +41,7 @@ export class IfRange implements HeaderValue { * Weak entity tags (prefixed with `W/`) are never considered a match. * * @param resource The current resource state to compare against - * @return `true` if the condition is satisfied, `false` otherwise + * @returns `true` if the condition is satisfied, `false` otherwise * * @example * ```ts @@ -84,7 +84,7 @@ export class IfRange implements HeaderValue { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString() { return this.value diff --git a/packages/headers/src/lib/range.ts b/packages/headers/src/lib/range.ts index 1054b51b168..ed98f18dd7e 100644 --- a/packages/headers/src/lib/range.ts +++ b/packages/headers/src/lib/range.ts @@ -86,7 +86,7 @@ export class Range implements HeaderValue, RangeInit { * Checks if this range can be satisfied for a resource of the given size. * * @param resourceSize The size of the resource in bytes - * @return `false` if the range is malformed or all ranges are beyond the resource size + * @returns `false` if the range is malformed or all ranges are beyond the resource size */ canSatisfy(resourceSize: number): boolean { // No unit or no ranges means header was malformed or empty @@ -125,7 +125,7 @@ export class Range implements HeaderValue, RangeInit { * Returns an empty array if the range cannot be satisfied. * * @param resourceSize The size of the resource in bytes - * @return An array of ranges with resolved start and end values + * @returns An array of ranges with resolved start and end values */ normalize(resourceSize: number): Array<{ start: number; end: number }> { if (!this.canSatisfy(resourceSize)) { @@ -159,7 +159,7 @@ export class Range implements HeaderValue, RangeInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { if (!this.unit || this.ranges.length === 0) return '' diff --git a/packages/headers/src/lib/set-cookie.ts b/packages/headers/src/lib/set-cookie.ts index 82edca0083f..8a7cdbb0fe8 100644 --- a/packages/headers/src/lib/set-cookie.ts +++ b/packages/headers/src/lib/set-cookie.ts @@ -167,7 +167,7 @@ export class SetCookie implements HeaderValue, SetCookieInit { /** * Returns the string representation of the header value. * - * @return The header value as a string + * @returns The header value as a string */ toString(): string { if (!this.name) { diff --git a/packages/headers/src/lib/super-headers.ts b/packages/headers/src/lib/super-headers.ts index 4e98ddca03e..bec67153f2a 100644 --- a/packages/headers/src/lib/super-headers.ts +++ b/packages/headers/src/lib/super-headers.ts @@ -272,7 +272,7 @@ export class SuperHeaders extends Headers { * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Headers/get) * * @param name The name of the header to get - * @return The header value, or `null` if not found + * @returns The header value, or `null` if not found */ override get(name: string): string | null { let key = name.toLowerCase() @@ -298,7 +298,7 @@ export class SuperHeaders extends Headers { * * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Headers/getSetCookie) * - * @return An array of `Set-Cookie` header values + * @returns An array of `Set-Cookie` header values */ override getSetCookie(): string[] { return this.#setCookies.map((v) => (typeof v === 'string' ? v : v.toString())) @@ -310,7 +310,7 @@ export class SuperHeaders extends Headers { * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Headers/has) * * @param name The name of the header to check - * @return `true` if the header is present, `false` otherwise + * @returns `true` if the header is present, `false` otherwise */ override has(name: string): boolean { let key = name.toLowerCase() @@ -340,7 +340,7 @@ export class SuperHeaders extends Headers { * * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Headers/keys) * - * @return An iterator of header keys + * @returns An iterator of header keys */ override *keys(): HeadersIterator { for (let [key] of this) yield key @@ -351,7 +351,7 @@ export class SuperHeaders extends Headers { * * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Headers/values) * - * @return An iterator of header values + * @returns An iterator of header values */ override *values(): HeadersIterator { for (let [, value] of this) yield value @@ -362,7 +362,7 @@ export class SuperHeaders extends Headers { * * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/API/Headers/entries) * - * @return An iterator of `[key, value]` tuples + * @returns An iterator of `[key, value]` tuples */ override *entries(): HeadersIterator<[string, string]> { for (let [key] of this.#map) { @@ -396,7 +396,7 @@ export class SuperHeaders extends Headers { /** * Returns a string representation of the headers suitable for use in a HTTP message. * - * @return The headers formatted for HTTP + * @returns The headers formatted for HTTP */ override toString(): string { let lines: string[] = [] diff --git a/packages/html-template/src/lib/safe-html.ts b/packages/html-template/src/lib/safe-html.ts index 8c087d139b8..8173d330e8e 100644 --- a/packages/html-template/src/lib/safe-html.ts +++ b/packages/html-template/src/lib/safe-html.ts @@ -16,7 +16,7 @@ function createSafeHtml(value: string): SafeHtml { * Checks if a value is a `SafeHtml` string. * * @param value The value to check - * @return `true` if the value is a `SafeHtml` string + * @returns `true` if the value is a `SafeHtml` string */ export function isSafeHtml(value: unknown): value is SafeHtml { return typeof value === 'object' && value != null && (value as any)[kSafeHtml] === true @@ -85,7 +85,7 @@ type SafeHtmlHelper = { * * @param strings The template strings * @param values The values to interpolate - * @return A `SafeHtml` value + * @returns A `SafeHtml` value */ (strings: TemplateStringsArray, ...values: Interpolation[]): SafeHtml /** @@ -96,7 +96,7 @@ type SafeHtmlHelper = { * * @param strings The template strings * @param values The values to interpolate - * @return A `SafeHtml` value + * @returns A `SafeHtml` value */ raw(strings: TemplateStringsArray, ...values: Interpolation[]): SafeHtml } diff --git a/packages/interaction/src/lib/interaction.ts b/packages/interaction/src/lib/interaction.ts index 1297396c709..6f81eae3579 100644 --- a/packages/interaction/src/lib/interaction.ts +++ b/packages/interaction/src/lib/interaction.ts @@ -107,7 +107,7 @@ export type InteractionSetup = (this: Interaction) => void * * @param type The unique string identifier for this interaction type * @param interaction The setup function that configures the interaction - * @return The type string, for use as an event name + * @returns The type string, for use as an event name */ export function defineInteraction(type: type, interaction: InteractionSetup) { interactions.set(type, interaction) @@ -161,7 +161,7 @@ export type ContainerOptions = { * * @param target The event target to wrap (DOM element, window, document, or any EventTarget) * @param options Optional configuration for the container - * @return An `EventsContainer` with `dispose()` and `set()` methods + * @returns An `EventsContainer` with `dispose()` and `set()` methods */ export function createContainer( target: target, @@ -272,7 +272,7 @@ export function createContainer( * * @param target The event target to add listeners to * @param listeners The event listeners to add - * @return A function to dispose all listeners + * @returns A function to dispose all listeners */ export function on( target: target, diff --git a/packages/interaction/src/lib/interactions/popover.ts b/packages/interaction/src/lib/interactions/popover.ts index 82b509b38b8..bd4443033c5 100644 --- a/packages/interaction/src/lib/interactions/popover.ts +++ b/packages/interaction/src/lib/interactions/popover.ts @@ -6,7 +6,7 @@ import { defineInteraction, type Interaction } from '../interaction' * Dispatches on the owner of a popover when the popover toggles. * * ### Example - + * * ```html *