Skip to content

Commit 58f0726

Browse files
committed
chore: enable oxfmt
1 parent 00d2439 commit 58f0726

82 files changed

Lines changed: 5637 additions & 1109 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/nodejs-16.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ name: Node.js 16 CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88

99
jobs:
1010
build:
11-
1211
runs-on: ubuntu-latest
1312

1413
steps:
@@ -20,4 +19,4 @@ jobs:
2019
- run: npm install
2120
- run: npm run prepublishOnly
2221
- run: node -v
23-
- run: npm run test-node16
22+
- run: npm run test-node16

.github/workflows/nodejs.yml

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,49 @@ name: CI
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66
pull_request:
7-
branches: [ master ]
7+
branches: [master]
88
merge_group:
99

1010
jobs:
11-
Job:
11+
typecheck:
12+
runs-on: ubuntu-latest
13+
concurrency:
14+
group: typecheck-${{ github.workflow }}-#${{ github.event.pull_request.number || github.head_ref || github.ref }}
15+
cancel-in-progress: true
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
19+
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6
25+
with:
26+
node-version: '24'
27+
cache: 'pnpm'
28+
29+
- name: Install dependencies
30+
run: pnpm install --frozen-lockfile
31+
32+
- name: Run lint
33+
run: pnpm run lint
34+
35+
- name: Check dedupe
36+
run: pnpm dedupe --check
37+
38+
- name: Run typecheck
39+
run: pnpm run typecheck
40+
41+
- name: Run format check
42+
run: pnpm run fmtcheck
43+
44+
- name: Run build
45+
run: pnpm run build
46+
47+
test:
1248
name: Node.js
1349
uses: node-modules/github-actions/.github/workflows/node-test.yml@master
1450
with:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Release
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [master]
66

77
jobs:
88
release:

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ test/fixtures/ts-esm/*.js
1717
.eslintcache
1818
.tshy*
1919
.idea/
20-
pnpm-lock.yaml

.oxfmtrc.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 120,
4+
"singleQuote": true,
5+
"ignorePatterns": [
6+
"CHANGELOG.md"
7+
],
8+
"experimentalSortImports": {
9+
"groups": [
10+
["type-import"],
11+
["type-builtin", "value-builtin"],
12+
["type-external", "value-external", "type-internal", "value-internal"],
13+
["type-parent", "type-sibling", "type-index", "value-parent", "value-sibling", "value-index"],
14+
["ts-equals-import"],
15+
["unknown"]
16+
],
17+
"newlinesBetween": true,
18+
"order": "asc"
19+
}
20+
}

.oxlintrc.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"env": {
44
"node": true
55
},
6-
"extends": [
7-
"./node_modules/@eggjs/oxlint-config/.oxlintrc.json"
8-
],
6+
"extends": ["./node_modules/@eggjs/oxlint-config/.oxlintrc.json"],
97
"categories": {
108
"correctness": "allow",
119
"suspicious": "allow",
@@ -126,4 +124,4 @@
126124
"arrow-body-style": "allow",
127125
"prefer-destructuring": "allow"
128126
}
129-
}
127+
}

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -56,30 +56,30 @@ console.log('status: %s, body size: %d, headers: %j', res.status, data.length, r
5656
#### Arguments
5757

5858
- **url** String | Object - The URL to request, either a String or a Object that return by [url.parse](https://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost).
59-
- ***options*** Object - Optional
60-
- ***method*** String - Request method, defaults to `GET`. Could be `GET`, `POST`, `DELETE` or `PUT`. Alias 'type'.
61-
- ***data*** Object - Data to be sent. Will be stringify automatically.
62-
- ***content*** String | [Buffer](https://nodejs.org/api/buffer.html) - Manually set the content of payload. If set, `data` will be ignored.
63-
- ***stream*** [stream.Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable) - Stream to be pipe to the remote. If set, `data` and `content` will be ignored.
64-
- ***writeStream*** [stream.Writable](https://nodejs.org/api/stream.html#stream_class_stream_writable) - A writable stream to be piped by the response stream. Responding data will be write to this stream and `callback` will be called with `data` set `null` after finished writing.
65-
- ***files*** {Array<ReadStream|Buffer|String> | Object | ReadStream | Buffer | String - The files will send with `multipart/form-data` format, base on `formstream`. If `method` not set, will use `POST` method by default.
66-
- ***contentType*** String - Type of request data. Could be `json` (**Notes**: not use `application/json` here). If it's `json`, will auto set `Content-Type: application/json` header.
67-
- ***dataType*** String - Type of response data. Could be `text` or `json`. If it's `text`, the `callback`ed `data` would be a String. If it's `json`, the `data` of callback would be a parsed JSON Object and will auto set `Accept: application/json` header. Default `callback`ed `data` would be a `Buffer`.
68-
- ***fixJSONCtlChars*** Boolean - Fix the control characters (U+0000 through U+001F) before JSON parse response. Default is `false`.
69-
- ***headers*** Object - Request headers.
70-
- ***timeout*** Number | Array - Request timeout in milliseconds for connecting phase and response receiving phase. Default is `5000`. You can use `timeout: 5000` to tell urllib use same timeout on two phase or set them separately such as `timeout: [3000, 5000]`, which will set connecting timeout to 3s and response 5s.
71-
- ***keepAliveTimeout*** `number | null` - Default is `4000`, 4 seconds - The timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. 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.
72-
- ***auth*** String - `username:password` used in HTTP Basic Authorization.
73-
- ***digestAuth*** String - `username:password` used in HTTP [Digest Authorization](https://en.wikipedia.org/wiki/Digest_access_authentication).
74-
- ***followRedirect*** Boolean - follow HTTP 3xx responses as redirects. defaults to true.
75-
- ***maxRedirects*** Number - The maximum number of redirects to follow, defaults to 10.
76-
- ***formatRedirectUrl*** Function - Format the redirect url by yourself. Default is `url.resolve(from, to)`.
77-
- ***beforeRequest*** Function - Before request hook, you can change every thing here.
78-
- ***streaming*** Boolean - lets you get the `res` object when request connected, default `false`. alias `customResponse`
79-
- ***compressed*** Boolean - Accept `gzip, br` response content and auto decode it, default is `false`.
80-
- ***timing*** Boolean - Enable timing or not, default is `true`.
81-
- ***socketPath*** String | null - request a unix socket service, default is `null`.
82-
- ***highWaterMark*** Number - default is `67108864`, 64 KiB.
59+
- **_options_** Object - Optional
60+
- **_method_** String - Request method, defaults to `GET`. Could be `GET`, `POST`, `DELETE` or `PUT`. Alias 'type'.
61+
- **_data_** Object - Data to be sent. Will be stringify automatically.
62+
- **_content_** String | [Buffer](https://nodejs.org/api/buffer.html) - Manually set the content of payload. If set, `data` will be ignored.
63+
- **_stream_** [stream.Readable](https://nodejs.org/api/stream.html#stream_class_stream_readable) - Stream to be pipe to the remote. If set, `data` and `content` will be ignored.
64+
- **_writeStream_** [stream.Writable](https://nodejs.org/api/stream.html#stream_class_stream_writable) - A writable stream to be piped by the response stream. Responding data will be write to this stream and `callback` will be called with `data` set `null` after finished writing.
65+
- **_files_** {Array<ReadStream|Buffer|String> | Object | ReadStream | Buffer | String - The files will send with `multipart/form-data` format, base on `formstream`. If `method` not set, will use `POST` method by default.
66+
- **_contentType_** String - Type of request data. Could be `json` (**Notes**: not use `application/json` here). If it's `json`, will auto set `Content-Type: application/json` header.
67+
- **_dataType_** String - Type of response data. Could be `text` or `json`. If it's `text`, the `callback`ed `data` would be a String. If it's `json`, the `data` of callback would be a parsed JSON Object and will auto set `Accept: application/json` header. Default `callback`ed `data` would be a `Buffer`.
68+
- **_fixJSONCtlChars_** Boolean - Fix the control characters (U+0000 through U+001F) before JSON parse response. Default is `false`.
69+
- **_headers_** Object - Request headers.
70+
- **_timeout_** Number | Array - Request timeout in milliseconds for connecting phase and response receiving phase. Default is `5000`. You can use `timeout: 5000` to tell urllib use same timeout on two phase or set them separately such as `timeout: [3000, 5000]`, which will set connecting timeout to 3s and response 5s.
71+
- **_keepAliveTimeout_** `number | null` - Default is `4000`, 4 seconds - The timeout after which a socket without active requests will time out. Monitors time between activity on a connected socket. 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.
72+
- **_auth_** String - `username:password` used in HTTP Basic Authorization.
73+
- **_digestAuth_** String - `username:password` used in HTTP [Digest Authorization](https://en.wikipedia.org/wiki/Digest_access_authentication).
74+
- **_followRedirect_** Boolean - follow HTTP 3xx responses as redirects. defaults to true.
75+
- **_maxRedirects_** Number - The maximum number of redirects to follow, defaults to 10.
76+
- **_formatRedirectUrl_** Function - Format the redirect url by yourself. Default is `url.resolve(from, to)`.
77+
- **_beforeRequest_** Function - Before request hook, you can change every thing here.
78+
- **_streaming_** Boolean - lets you get the `res` object when request connected, default `false`. alias `customResponse`
79+
- **_compressed_** Boolean - Accept `gzip, br` response content and auto decode it, default is `false`.
80+
- **_timing_** Boolean - Enable timing or not, default is `true`.
81+
- **_socketPath_** String | null - request a unix socket service, default is `null`.
82+
- **_highWaterMark_** Number - default is `67108864`, 64 KiB.
8383

8484
#### Options: `options.data`
8585

examples/h2-other-side-closed-exit-0-fetch.cjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const { fetch, setGlobalDispatcher, Agent } = require('..');
22

3-
setGlobalDispatcher(new Agent({
4-
allowH2: true,
5-
}));
3+
setGlobalDispatcher(
4+
new Agent({
5+
allowH2: true,
6+
}),
7+
);
68

79
async function main() {
810
for (let i = 0; i < 100; i++) {
@@ -21,13 +23,15 @@ async function main() {
2123
}
2224
}
2325

24-
main().then(() => {
25-
console.log('main end');
26-
}).catch(err => {
27-
console.error('main error throw: %s', err);
28-
// console.error(err);
29-
process.exit(1);
30-
});
26+
main()
27+
.then(() => {
28+
console.log('main end');
29+
})
30+
.catch((err) => {
31+
console.error('main error throw: %s', err);
32+
// console.error(err);
33+
process.exit(1);
34+
});
3135

3236
process.on('beforeExit', (...args) => {
3337
console.error('beforeExit', args);

examples/h2-other-side-closed-exit-0.cjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
const { request, Agent, setGlobalDispatcher } = require('undici');
22

3-
setGlobalDispatcher(new Agent({
4-
allowH2: true,
5-
}));
3+
setGlobalDispatcher(
4+
new Agent({
5+
allowH2: true,
6+
}),
7+
);
68

79
async function main() {
810
for (let i = 0; i < 100; i++) {
@@ -21,13 +23,15 @@ async function main() {
2123
}
2224
}
2325

24-
main().then(() => {
25-
console.log('main end');
26-
}).catch(err => {
27-
console.error('main error throw: %s', err);
28-
// console.error(err);
29-
process.exit(1);
30-
});
26+
main()
27+
.then(() => {
28+
console.log('main end');
29+
})
30+
.catch((err) => {
31+
console.error('main error throw: %s', err);
32+
// console.error(err);
33+
process.exit(1);
34+
});
3135

3236
process.on('beforeExit', (...args) => {
3337
console.error('beforeExit', args);

examples/httpclient.cjs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,20 @@ function tryHttpclient(HttpClient, name) {
99
timing: true,
1010
};
1111
const urllib = new HttpClient();
12-
urllib.on('response', function(info) {
12+
urllib.on('response', function (info) {
1313
// console.log(name, httpAgent, httpAgent.getCurrentStatus());
1414
// console.log(name, httpsAgent, httpsAgent.getCurrentStatus());
1515
console.log('response', name, info.res);
1616
});
17-
urllib.request('https://nodejs.org', options)
18-
.then(function() {
17+
urllib
18+
.request('https://nodejs.org', options)
19+
.then(function () {
1920
return urllib.request('https://nodejs.org', options);
2021
})
21-
.then(function() {
22+
.then(function () {
2223
return urllib.request('https://nodejs.org/en/', options);
2324
})
24-
.catch(function(err) {
25+
.catch(function (err) {
2526
console.error('catch', err);
2627
});
2728
}

0 commit comments

Comments
 (0)