Skip to content

Commit b4b1a14

Browse files
authored
chore: enable oxfmt jsdoc feature (#757)
https://oxc.rs/docs/guide/usage/formatter/config-file-reference.html#jsdoc <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Reformatted JSDoc comments across multiple files for improved clarity and consistency. * **Chores** * Updated code formatting configuration to enforce consistent documentation block formatting standards. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent df29cb0 commit b4b1a14

5 files changed

Lines changed: 47 additions & 64 deletions

File tree

src/HttpClient.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,32 @@ export type ClientOptions = {
7676
defaultArgs?: RequestOptions;
7777
/** Allow to use HTTP2 first. Default is `false` */
7878
allowH2?: boolean;
79-
/**
80-
* Custom DNS lookup function, default is `dns.lookup`.
81-
*/
79+
/** Custom DNS lookup function, default is `dns.lookup`. */
8280
lookup?: LookupFunction;
8381
/**
84-
* check request address to protect from SSRF and similar attacks.
85-
* It receive two arguments(ip and family) and should return true or false to identified the address is legal or not.
86-
* It rely on lookup and have the same version requirement.
82+
* Check request address to protect from SSRF and similar attacks. It receive two arguments(ip and family) and should
83+
* return true or false to identified the address is legal or not. It rely on lookup and have the same version
84+
* requirement.
8785
*/
8886
checkAddress?: CheckAddressFunction;
8987
connect?: {
9088
key?: string | Buffer;
9189
/**
92-
* A string or Buffer containing the certificate key of the client in PEM format.
93-
* Notes: This is necessary only if using the client certificate authentication
90+
* A string or Buffer containing the certificate key of the client in PEM format. Notes: This is necessary only if
91+
* using the client certificate authentication
9492
*/
9593
cert?: string | Buffer;
9694
/**
97-
* If `true`, the server certificate is verified against the list of supplied CAs.
98-
* An 'error' event is emitted if verification fails.
99-
* Default: `true`
95+
* If `true`, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if
96+
* verification fails. Default: `true`
10097
*/
10198
rejectUnauthorized?: boolean;
10299
/**
103-
* socketPath string | null (optional) - Default: null - An IPC endpoint, either Unix domain socket or Windows named pipe
100+
* SocketPath string | null (optional) - Default: null - An IPC endpoint, either Unix domain socket or Windows named
101+
* pipe
104102
*/
105103
socketPath?: string | null;
106-
/**
107-
* connect timeout, default is 10000ms
108-
*/
104+
/** Connect timeout, default is 10000ms */
109105
timeout?: number;
110106
};
111107
};

src/Request.ts

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ export type RequestOptions = {
3232
*/
3333
stream?: Readable;
3434
/**
35-
* A writable stream to be piped by the response stream.
36-
* Responding data will be write to this stream and callback
35+
* A writable stream to be piped by the response stream. Responding data will be write to this stream and callback
3736
* will be called with data set null after finished writing.
3837
*/
3938
writeStream?: Writable;
4039
/**
41-
* The files will send with multipart/form-data format, base on formstream.
42-
* If method not set, will use POST method by default.
40+
* The files will send with multipart/form-data format, base on formstream. If method not set, will use POST method by
41+
* default.
4342
*/
4443
files?:
4544
| Array<Readable | Buffer | string>
@@ -51,16 +50,14 @@ export type RequestOptions = {
5150
/** Type of request data, could be 'json'. If it's 'json', will auto set Content-Type: 'application/json' header. */
5251
contentType?: string;
5352
/**
54-
* Type of response data. Could be text or json.
55-
* If it's text or html, the callbacked data would be a String.
56-
* If it's json, the data of callback would be a parsed JSON Object
57-
* and will auto set Accept: 'application/json' header.
53+
* Type of response data. Could be text or json. If it's text or html, the callbacked data would be a String. If it's
54+
* json, the data of callback would be a parsed JSON Object and will auto set Accept: 'application/json' header.
5855
* Default is 'buffer'.
5956
*/
6057
dataType?: 'text' | 'html' | 'json' | 'buffer' | 'stream';
6158
/**
62-
* urllib default use URLSearchParams to stringify form data which don't support nested object,
63-
* will use qs instead of URLSearchParams to support nested object by set this option to true.
59+
* Urllib default use URLSearchParams to stringify form data which don't support nested object, will use qs instead of
60+
* URLSearchParams to support nested object by set this option to true.
6461
*/
6562
nestedQuerystring?: boolean;
6663
/**
@@ -85,27 +82,23 @@ export type RequestOptions = {
8582
/** Request headers. */
8683
headers?: IncomingHttpHeaders;
8784
/**
88-
* Request timeout in milliseconds for connecting phase and response receiving phase.
89-
* Defaults is `5000`, both are 5 seconds. You can use timeout: 5000 to tell urllib use same timeout on two phase or set them separately such as
85+
* Request timeout in milliseconds for connecting phase and response receiving phase. Defaults is `5000`, both are 5
86+
* seconds. You can use timeout: 5000 to tell urllib use same timeout on two phase or set them separately such as
9087
* timeout: [3000, 5000], which will set connecting timeout to 3s and response 5s.
9188
*/
9289
timeout?: number | number[];
9390
/**
94-
* Default is `4000`, 4 seconds - The timeout after which a socket without active requests will time out.
95-
* Monitors time between activity on a connected socket.
96-
* This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details.
91+
* Default is `4000`, 4 seconds - The timeout after which a socket without active requests will time out. Monitors
92+
* time between activity on a connected socket. This value may be overridden by _keep-alive_ hints from the server.
93+
* See [MDN: HTTP - Headers - Keep-Alive
94+
* directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details.
9795
*/
9896
keepAliveTimeout?: number;
99-
/**
100-
* username:password used in HTTP Basic Authorization.
101-
* Alias to `headers.authorization = xxx`
102-
**/
97+
/** Username:password used in HTTP Basic Authorization. Alias to `headers.authorization = xxx` */
10398
auth?: string;
104-
/**
105-
* username:password used in HTTP Digest Authorization.
106-
* */
99+
/** Username:password used in HTTP Digest Authorization. */
107100
digestAuth?: string;
108-
/** follow HTTP 3xx responses as redirects. defaults to true. */
101+
/** Follow HTTP 3xx responses as redirects. defaults to true. */
109102
followRedirect?: boolean;
110103
/** The maximum number of redirects to follow, defaults to 10. */
111104
maxRedirects?: number;
@@ -118,28 +111,26 @@ export type RequestOptions = {
118111
/**
119112
* @deprecated
120113
* Alias to compressed
121-
* */
114+
*/
122115
gzip?: boolean;
123-
/**
124-
* Enable timing or not, default is `true`.
125-
* */
116+
/** Enable timing or not, default is `true`. */
126117
timing?: boolean;
127118
/**
128-
* Auto retry times on 5xx response, default is `0`. Don't work on streaming request
129-
* It's not supported by using retry and writeStream, because the retry request can't stop the stream which is consuming.
130-
**/
119+
* Auto retry times on 5xx response, default is `0`. Don't work on streaming request It's not supported by using retry
120+
* and writeStream, because the retry request can't stop the stream which is consuming.
121+
*/
131122
retry?: number;
132123
/** Wait a delay(ms) between retries */
133124
retryDelay?: number;
134125
/**
135-
* Determine whether retry, a response object as the first argument.
136-
* It will retry when status >= 500 by default. Request error is not included.
126+
* Determine whether retry, a response object as the first argument. It will retry when status >= 500 by default.
127+
* Request error is not included.
137128
*/
138129
isRetry?: (response: HttpClientResponse) => boolean;
139130
/**
140-
* Auto retry times on socket error, default is `1`. Don't work on streaming request
141-
* It's not supported by using retry and writeStream, because the retry request can't stop the stream which is consuming.
142-
**/
131+
* Auto retry times on socket error, default is `1`. Don't work on streaming request It's not supported by using retry
132+
* and writeStream, because the retry request can't stop the stream which is consuming.
133+
*/
143134
socketErrorRetry?: number;
144135
/** Default: `null` */
145136
opaque?: unknown;
@@ -148,13 +139,9 @@ export type RequestOptions = {
148139
* Maybe you should use opaque instead
149140
*/
150141
ctx?: unknown;
151-
/**
152-
* request dispatcher, default is getGlobalDispatcher()
153-
*/
142+
/** Request dispatcher, default is getGlobalDispatcher() */
154143
dispatcher?: Dispatcher;
155-
/**
156-
* unix domain socket file path
157-
*/
144+
/** Unix domain socket file path */
158145
socketPath?: string | null;
159146
/** Whether the request should stablish a keep-alive or not. Default `false`, try to keep alive by default */
160147
reset?: boolean;

src/Response.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ export type SocketInfo = {
2222
connectPort?: string;
2323
};
2424

25-
/**
26-
* https://eggjs.org/en/core/httpclient.html#timing-boolean
27-
*/
25+
/** https://eggjs.org/en/core/httpclient.html#timing-boolean */
2826
export type Timing = {
2927
// socket assigned
3028
queuing: number;
@@ -47,9 +45,9 @@ export type RawResponseWithMeta = Readable & {
4745
statusCode: number;
4846
statusText: string;
4947
/**
50-
* @alias statusText
5148
* @deprecated use `statusText` instead
52-
**/
49+
* @alias statusText
50+
*/
5351
statusMessage: string;
5452
headers: IncomingHttpHeaders;
5553
timing: Timing;

src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ export function getDefaultHttpClient(rejectUnauthorized?: boolean, allowH2?: boo
5151

5252
interface UrllibRequestOptions extends RequestOptions {
5353
/**
54-
* If `true`, the server certificate is verified against the list of supplied CAs.
55-
* An 'error' event is emitted if verification fails.
56-
* Default: `true`
54+
* If `true`, the server certificate is verified against the list of supplied CAs. An 'error' event is emitted if
55+
* verification fails. Default: `true`
5756
*/
5857
rejectUnauthorized?: boolean;
5958
/** Allow to use HTTP2 first. Default is `false` */

vite.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export default defineConfig({
2020
newlinesBetween: true,
2121
order: 'asc',
2222
},
23+
jsdoc: {
24+
preferCodeFences: true,
25+
},
2326
},
2427
lint: {
2528
options: {

0 commit comments

Comments
 (0)