Skip to content

Commit 35f60e3

Browse files
authored
fix(docs): add plugin-eslint-tsdoc (#4525)
* fix(docs): fix eslint identified tsdoc tags and add eslint-plugin-tsdoc to prevent regression * fix(pin): pin eslint-plugin-typedoc
1 parent 6604067 commit 35f60e3

32 files changed

+187
-132
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
"eslint-plugin-prettier": "4.0.0",
8181
"eslint-plugin-simple-import-sort": "7.0.0",
8282
"eslint-plugin-sort-export-all": "1.2.2",
83+
"eslint-plugin-tsdoc": "0.2.17",
8384
"esprint": "3.6.0",
8485
"fastify": "^4.11.0",
8586
"figlet": "^1.5.0",

packages/smithy-client/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": ["eslint-plugin-tsdoc"],
3+
"rules": {
4+
"tsdoc/syntax": "warn"
5+
}
6+
}

packages/smithy-client/src/date-utils.ts

+27-27
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ const MONTHS: Array<String> = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
1414
* since not all environments will have this as the expected
1515
* format.
1616
*
17-
* See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString
18-
* > Prior to ECMAScript 2018, the format of the return value
19-
* > varied according to the platform. The most common return
20-
* > value was an RFC-1123 formatted date stamp, which is a
21-
* > slightly updated version of RFC-822 date stamps.
17+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toUTCString}
18+
* - Prior to ECMAScript 2018, the format of the return value
19+
* - varied according to the platform. The most common return
20+
* - value was an RFC-1123 formatted date stamp, which is a
21+
* - slightly updated version of RFC-822 date stamps.
2222
*/
2323
export function dateToUtcString(date: Date): string {
2424
const year = date.getUTCFullYear();
@@ -51,10 +51,10 @@ const RFC3339 = new RegExp(/^(\d{4})-(\d{2})-(\d{2})[tT](\d{2}):(\d{2}):(\d{2})(
5151
* Input strings must conform to RFC3339 section 5.6, and cannot have a UTC
5252
* offset. Fractional precision is supported.
5353
*
54-
* {@see https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
54+
* @see {@link https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
5555
*
56-
* @param value the value to parse
57-
* @return a Date or undefined
56+
* @param value - the value to parse
57+
* @returns a Date or undefined
5858
*/
5959
export const parseRfc3339DateTime = (value: unknown): Date | undefined => {
6060
if (value === null || value === undefined) {
@@ -91,10 +91,10 @@ const RFC3339_WITH_OFFSET = new RegExp(
9191
* Input strings must conform to RFC3339 section 5.6, and can have a UTC
9292
* offset. Fractional precision is supported.
9393
*
94-
* {@see https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
94+
* @see {@link https://xml2rfc.tools.ietf.org/public/rfc/html/rfc3339.html#anchor14}
9595
*
96-
* @param value the value to parse
97-
* @return a Date or undefined
96+
* @param value - the value to parse
97+
* @returns a Date or undefined
9898
*/
9999
export const parseRfc3339DateTimeWithOffset = (value: unknown): Date | undefined => {
100100
if (value === null || value === undefined) {
@@ -142,10 +142,10 @@ const ASC_TIME = new RegExp(
142142
*
143143
* Input strings must conform to RFC7231 section 7.1.1.1. Fractional seconds are supported.
144144
*
145-
* {@see https://datatracker.ietf.org/doc/html/rfc7231.html#section-7.1.1.1}
145+
* @see {@link https://datatracker.ietf.org/doc/html/rfc7231.html#section-7.1.1.1}
146146
*
147-
* @param value the value to parse
148-
* @return a Date or undefined
147+
* @param value - the value to parse
148+
* @returns a Date or undefined
149149
*/
150150
export const parseRfc7231DateTime = (value: unknown): Date | undefined => {
151151
if (value === null || value === undefined) {
@@ -204,8 +204,8 @@ export const parseRfc7231DateTime = (value: unknown): Date | undefined => {
204204
*
205205
* Input strings must be an integer or floating point number. Fractional seconds are supported.
206206
*
207-
* @param value the value to parse
208-
* @return a Date or undefined
207+
* @param value - the value to parse
208+
* @returns a Date or undefined
209209
*/
210210
export const parseEpochTimestamp = (value: unknown): Date | undefined => {
211211
if (value === null || value === undefined) {
@@ -237,10 +237,10 @@ interface RawTime {
237237
/**
238238
* Build a date from a numeric year, month, date, and an match with named groups
239239
* "H", "m", s", and "frac", representing hours, minutes, seconds, and optional fractional seconds.
240-
* @param year numeric year
241-
* @param month numeric month, 1-indexed
242-
* @param day numeric year
243-
* @param match match with groups "H", "m", s", and "frac"
240+
* @param year - numeric year
241+
* @param month - numeric month, 1-indexed
242+
* @param day - numeric year
243+
* @param match - match with groups "H", "m", s", and "frac"
244244
*/
245245
const buildDate = (year: number, month: number, day: number, time: RawTime): Date => {
246246
const adjustedMonth = month - 1; // JavaScript, and our internal data structures, expect 0-indexed months
@@ -270,8 +270,8 @@ const buildDate = (year: number, month: number, day: number, time: RawTime): Dat
270270
* but keep '22' as 2022. in 2099, '11' will represent '2111', but '98' should be '2098'.
271271
* There's no description of an RFC 850 date being considered too far in the past in RFC-7231,
272272
* so it's entirely possible that 2011 is a valid interpretation of '11' in 2099.
273-
* @param value the 2 digit year to parse
274-
* @return number a year that is equal to or greater than the current UTC year
273+
* @param value - the 2 digit year to parse
274+
* @returns number a year that is equal to or greater than the current UTC year
275275
*/
276276
const parseTwoDigitYear = (value: string): number => {
277277
const thisYear = new Date().getUTCFullYear();
@@ -296,8 +296,8 @@ const FIFTY_YEARS_IN_MILLIS = 50 * 365 * 24 * 60 * 60 * 1000;
296296
* than 50 years in the future as representing the most recent year in
297297
* the past that had the same last two digits.</blockquote>
298298
*
299-
* @param input a Date that assumes the two-digit year was in the future
300-
* @return a Date that is in the past if input is > 50 years in the future
299+
* @param input - a Date that assumes the two-digit year was in the future
300+
* @returns a Date that is in the past if input is \> 50 years in the future
301301
*/
302302
const adjustRfc850Year = (input: Date): Date => {
303303
if (input.getTime() - new Date().getTime() > FIFTY_YEARS_IN_MILLIS) {
@@ -328,9 +328,9 @@ const DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
328328

329329
/**
330330
* Validate the day is valid for the given month.
331-
* @param year the year
332-
* @param month the month (0-indexed)
333-
* @param day the day of the month
331+
* @param year - the year
332+
* @param month - the month (0-indexed)
333+
* @param day - the day of the month
334334
*/
335335
const validateDayOfMonth = (year: number, month: number, day: number) => {
336336
let maxDays = DAYS_IN_MONTH[month];

packages/smithy-client/src/default-error-handler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { HttpResponse, ResponseMetadata } from "@aws-sdk/types";
33
import { decorateServiceException } from "./exceptions";
44

55
/**
6-
* Always throws an error with the given {@param exceptionCtor} and other arguments.
6+
* Always throws an error with the given `exceptionCtor` and other arguments.
77
* This is only called from an error handling code path.
88
*
99
* @internal

packages/smithy-client/src/defaults-mode.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const loadConfigsForDefaultMode = (mode: ResolvedDefaultsMode): DefaultsM
3838
* * `"auto"`: <p>The AUTO mode is an experimental mode that builds on the standard mode. The SDK will attempt to discover the execution environment to determine the appropriate settings automatically.</p><p>Note that the auto detection is heuristics-based and does not guarantee 100% accuracy. STANDARD mode will be used if the execution environment cannot be determined. The auto detection might query <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html">EC2 Instance Metadata service</a>, which might introduce latency. Therefore we recommend choosing an explicit defaults_mode instead if startup latency is critical to your application</p>
3939
* * `"legacy"`: <p>The LEGACY mode provides default settings that vary per SDK and were used prior to establishment of defaults_mode</p>
4040
*
41-
* @default "legacy"
41+
* @defaultValue "legacy"
4242
*/
4343
export type DefaultsMode = "standard" | "in-region" | "cross-region" | "mobile" | "auto" | "legacy";
4444

packages/smithy-client/src/emitWarningIfUnsupportedVersion.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let warningEmitted = false;
66
*
77
* Emits warning if the provided Node.js version string is pending deprecation.
88
*
9-
* @param {string} version - The Node.js version string.
9+
* @param version - The Node.js version string.
1010
*/
1111
export const emitWarningIfUnsupportedVersion = (version: string) => {
1212
if (version && !warningEmitted && parseInt(version.substring(1, version.indexOf("."))) < 14) {

packages/smithy-client/src/object-mapping.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export function map(arg0: any, arg1?: any, arg2?: any): any {
200200
}
201201

202202
/**
203-
* Convert a regular object { k: v } to { k: [, v] } mapping instruction set with default
203+
* Convert a regular object `{ k: v }` to `{ k: [, v] }` mapping instruction set with default
204204
* filter.
205205
*
206206
* @internal

packages/smithy-client/src/parse-utils.ts

+23-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Give an input string, strictly parses a boolean value.
55
*
6-
* @param value The boolean string to parse.
6+
* @param value - The boolean string to parse.
77
* @returns true for "true", false for "false", otherwise an error is thrown.
88
*/
99
export const parseBoolean = (value: string): boolean => {
@@ -24,7 +24,7 @@ export const parseBoolean = (value: string): boolean => {
2424
* Casts strings and numbers with a warning if there is evidence that they were
2525
* intended to be booleans.
2626
*
27-
* @param value A value that is expected to be a boolean.
27+
* @param value - A value that is expected to be a boolean.
2828
* @returns The value if it's a boolean, undefined if it's null/undefined,
2929
* otherwise an error is thrown.
3030
*/
@@ -68,7 +68,7 @@ export const expectBoolean = (value: any): boolean | undefined => {
6868
* Casts strings with a warning if the string is a parseable number.
6969
* This is to unblock slight API definition/implementation inconsistencies.
7070
*
71-
* @param value A value that is expected to be a number.
71+
* @param value - A value that is expected to be a number.
7272
* @returns The value if it's a number, undefined if it's null/undefined,
7373
* otherwise an error is thrown.
7474
*/
@@ -98,7 +98,7 @@ const MAX_FLOAT = Math.ceil(2 ** 127 * (2 - 2 ** -23));
9898
*
9999
* Asserts a value is a 32-bit float and returns it.
100100
*
101-
* @param value A value that is expected to be a 32-bit float.
101+
* @param value - A value that is expected to be a 32-bit float.
102102
* @returns The value if it's a float, undefined if it's null/undefined,
103103
* otherwise an error is thrown.
104104
*/
@@ -149,7 +149,7 @@ export const expectFloat32 = (value: any): number | undefined => {
149149
*
150150
* Asserts a value is an integer and returns it.
151151
*
152-
* @param value A value that is expected to be an integer.
152+
* @param value - A value that is expected to be an integer.
153153
* @returns The value if it's an integer, undefined if it's null/undefined,
154154
* otherwise an error is thrown.
155155
*/
@@ -175,7 +175,7 @@ export const expectInt = expectLong;
175175
*
176176
* Asserts a value is a 32-bit integer and returns it.
177177
*
178-
* @param value A value that is expected to be an integer.
178+
* @param value - A value that is expected to be an integer.
179179
* @returns The value if it's an integer, undefined if it's null/undefined,
180180
* otherwise an error is thrown.
181181
*/
@@ -186,7 +186,7 @@ export const expectInt32 = (value: any): number | undefined => expectSizedInt(va
186186
*
187187
* Asserts a value is a 16-bit integer and returns it.
188188
*
189-
* @param value A value that is expected to be an integer.
189+
* @param value - A value that is expected to be an integer.
190190
* @returns The value if it's an integer, undefined if it's null/undefined,
191191
* otherwise an error is thrown.
192192
*/
@@ -197,7 +197,7 @@ export const expectShort = (value: any): number | undefined => expectSizedInt(va
197197
*
198198
* Asserts a value is an 8-bit integer and returns it.
199199
*
200-
* @param value A value that is expected to be an integer.
200+
* @param value - A value that is expected to be an integer.
201201
* @returns The value if it's an integer, undefined if it's null/undefined,
202202
* otherwise an error is thrown.
203203
*/
@@ -229,8 +229,8 @@ const castInt = (value: number, size: IntSize) => {
229229
*
230230
* Asserts a value is not null or undefined and returns it, or throws an error.
231231
*
232-
* @param value A value that is expected to be defined
233-
* @param location The location where we're expecting to find a defined object (optional)
232+
* @param value - A value that is expected to be defined
233+
* @param location - The location where we're expecting to find a defined object (optional)
234234
* @returns The value if it's not undefined, otherwise throws an error
235235
*/
236236
export const expectNonNull = <T>(value: T | null | undefined, location?: string): T => {
@@ -249,7 +249,7 @@ export const expectNonNull = <T>(value: T | null | undefined, location?: string)
249249
* Asserts a value is an JSON-like object and returns it. This is expected to be used
250250
* with values parsed from JSON (arrays, objects, numbers, strings, booleans).
251251
*
252-
* @param value A value that is expected to be an object
252+
* @param value - A value that is expected to be an object
253253
* @returns The value if it's an object, undefined if it's null/undefined,
254254
* otherwise an error is thrown.
255255
*/
@@ -270,7 +270,7 @@ export const expectObject = (value: any): Record<string, any> | undefined => {
270270
* Asserts a value is a string and returns it.
271271
* Numbers and boolean will be cast to strings with a warning.
272272
*
273-
* @param value A value that is expected to be a string.
273+
* @param value - A value that is expected to be a string.
274274
* @returns The value if it's a string, undefined if it's null/undefined,
275275
* otherwise an error is thrown.
276276
*/
@@ -294,9 +294,9 @@ export const expectString = (value: any): string | undefined => {
294294
* Asserts a value is a JSON-like object with only one non-null/non-undefined key and
295295
* returns it.
296296
*
297-
* @param value A value that is expected to be an object with exactly one non-null,
297+
* @param value - A value that is expected to be an object with exactly one non-null,
298298
* non-undefined key.
299-
* @return the value if it's a union, undefined if it's null/undefined, otherwise
299+
* @returns the value if it's a union, undefined if it's null/undefined, otherwise
300300
* an error is thrown.
301301
*/
302302
export const expectUnion = (value: unknown): Record<string, any> | undefined => {
@@ -329,7 +329,7 @@ export const expectUnion = (value: unknown): Record<string, any> | undefined =>
329329
* "NaN", any implicit Nan values will result in an error being thrown. If any
330330
* other type is provided, an exception will be thrown.
331331
*
332-
* @param value A number or string representation of a double.
332+
* @param value - A number or string representation of a double.
333333
* @returns The value as a number, or undefined if it's null/undefined.
334334
*/
335335
export const strictParseDouble = (value: string | number): number | undefined => {
@@ -355,7 +355,7 @@ export const strictParseFloat = strictParseDouble;
355355
* "NaN", any implicit Nan values will result in an error being thrown. If any
356356
* other type is provided, an exception will be thrown.
357357
*
358-
* @param value A number or string representation of a float.
358+
* @param value - A number or string representation of a float.
359359
* @returns The value as a number, or undefined if it's null/undefined.
360360
*/
361361
export const strictParseFloat32 = (value: string | number): number | undefined => {
@@ -390,7 +390,7 @@ const parseNumber = (value: string): number => {
390390
* being thrown. Null or undefined will be returned as undefined. Any other
391391
* type will result in an exception being thrown.
392392
*
393-
* @param value A number or string representation of a non-numeric float.
393+
* @param value - A number or string representation of a non-numeric float.
394394
* @returns The value as a number, or undefined if it's null/undefined.
395395
*/
396396
export const limitedParseDouble = (value: string | number): number | undefined => {
@@ -423,7 +423,7 @@ export const limitedParseFloat = limitedParseDouble;
423423
* being thrown. Null or undefined will be returned as undefined. Any other
424424
* type will result in an exception being thrown.
425425
*
426-
* @param value A number or string representation of a non-numeric float.
426+
* @param value - A number or string representation of a non-numeric float.
427427
* @returns The value as a number, or undefined if it's null/undefined.
428428
*/
429429
export const limitedParseFloat32 = (value: string | number): number | undefined => {
@@ -455,7 +455,7 @@ const parseFloatString = (value: string): number => {
455455
* an integer, or the raw value is any type other than a string or number, an
456456
* exception will be thrown.
457457
*
458-
* @param value A number or string representation of an integer.
458+
* @param value - A number or string representation of an integer.
459459
* @returns The value as a number, or undefined if it's null/undefined.
460460
*/
461461
export const strictParseLong = (value: string | number): number | undefined => {
@@ -483,7 +483,7 @@ export const strictParseInt = strictParseLong;
483483
* an integer, or the raw value is any type other than a string or number, an
484484
* exception will be thrown.
485485
*
486-
* @param value A number or string representation of a 32-bit integer.
486+
* @param value - A number or string representation of a 32-bit integer.
487487
* @returns The value as a number, or undefined if it's null/undefined.
488488
*/
489489
export const strictParseInt32 = (value: string | number): number | undefined => {
@@ -504,7 +504,7 @@ export const strictParseInt32 = (value: string | number): number | undefined =>
504504
* an integer, or the raw value is any type other than a string or number, an
505505
* exception will be thrown.
506506
*
507-
* @param value A number or string representation of a 16-bit integer.
507+
* @param value - A number or string representation of a 16-bit integer.
508508
* @returns The value as a number, or undefined if it's null/undefined.
509509
*/
510510
export const strictParseShort = (value: string | number): number | undefined => {
@@ -525,7 +525,7 @@ export const strictParseShort = (value: string | number): number | undefined =>
525525
* an integer, or the raw value is any type other than a string or number, an
526526
* exception will be thrown.
527527
*
528-
* @param value A number or string representation of an 8-bit integer.
528+
* @param value - A number or string representation of an 8-bit integer.
529529
* @returns The value as a number, or undefined if it's null/undefined.
530530
*/
531531
export const strictParseByte = (value: string | number): number | undefined => {
@@ -551,7 +551,7 @@ const stackTraceWarning = (message: string): string => {
551551
};
552552

553553
/**
554-
* @private
554+
* @internal
555555
*/
556556
export const logger = {
557557
warn: console.warn,

packages/smithy-client/src/ser-utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Serializes a number, turning non-numeric values into strings.
55
*
6-
* @param value The number to serialize.
6+
* @param value - The number to serialize.
77
* @returns A number, or a string if the given number was non-numeric.
88
*/
99
export const serializeFloat = (value: number): string | number => {

packages/smithy-client/src/split-every.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* Given an input string, splits based on the delimiter after a given
55
* number of delimiters has been encountered.
66
*
7-
* @param value The input string to split.
8-
* @param delimiter The delimiter to split on.
9-
* @param numDelimiters The number of delimiters to have encountered to split.
7+
* @param value - The input string to split.
8+
* @param delimiter - The delimiter to split on.
9+
* @param numDelimiters - The number of delimiters to have encountered to split.
1010
*/
1111
export function splitEvery(value: string, delimiter: string, numDelimiters: number): Array<string> {
1212
// Fail if we don't have a clear number to split on.

packages/types/.eslintrc.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"plugins": ["eslint-plugin-tsdoc"],
3+
"rules": {
4+
"tsdoc/syntax": "warn"
5+
}
6+
}

0 commit comments

Comments
 (0)