Skip to content

Commit 0866329

Browse files
authored
fix: remove --experimental-strip-types (#25)
and change to npm trusted publisher node-modules/github-actions#14 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated the minimum required Node.js version in the installation instructions. * **Chores** * Simplified linting configuration by extending an external base config and removing local rule overrides. * Updated Node.js engine requirement, development dependencies, and removed the "alpha" publish tag. * Modified GitHub Actions workflow configuration for releases. * **Style** * Refactored property access syntax in source files for consistency. * **Tests** * Renamed imports in test files for clarity and consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8e29e53 commit 0866329

File tree

8 files changed

+24
-165
lines changed

8 files changed

+24
-165
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ on:
66

77
jobs:
88
release:
9-
name: Node.js
10-
uses: eggjs/github-actions/.github/workflows/node-release.yml@master
9+
name: NPM
10+
uses: eggjs/github-actions/.github/workflows/npm-release.yml@master
1111
secrets:
12-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
1312
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}

.oxlintrc.json

Lines changed: 3 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -4,152 +4,12 @@
44
"node": true,
55
"mocha": true
66
},
7-
"categories": {
8-
"correctness": "error",
9-
"perf": "error",
10-
"nursery": "error",
11-
"restriction": "error",
12-
"style": "error",
13-
"pedantic": "error",
14-
"suspicious": "error"
15-
},
16-
"plugins": [
17-
"import",
18-
"typescript",
19-
"unicorn",
20-
"jsdoc",
21-
"node",
22-
"promise",
23-
"oxc"
24-
],
25-
"rules": {
26-
// eslint
27-
"constructor-super": "error",
28-
"getter-return": "error",
29-
"no-undef": "error",
30-
"no-unreachable": "error",
31-
"no-var": "error",
32-
"no-eq-null": "error",
33-
"no-await-in-loop": "allow",
34-
"eqeqeq": ["error", "smart"],
35-
"init-declarations": "allow",
36-
"curly": "allow",
37-
"no-ternary": "allow",
38-
"max-params": ["error", 5],
39-
"no-await-expression-member": "error",
40-
"no-continue": "allow",
41-
"guard-for-in": "allow",
42-
"func-style": "allow",
43-
"sort-imports": "allow",
44-
"yoda": "allow",
45-
"sort-keys": "allow",
46-
"no-magic-numbers": "allow",
47-
"no-duplicate-imports": "error",
48-
"no-multi-assign": "error",
49-
"func-names": "error",
50-
"default-param-last": "error",
51-
"prefer-object-spread": "error",
52-
"no-undefined": "allow",
53-
"no-plusplus": "allow",
54-
// maybe warn
55-
"no-console": "allow",
56-
"no-extraneous-class": "allow",
57-
"no-empty-function": "error",
58-
"max-depth": ["error", 6],
59-
"max-lines-per-function": "allow",
60-
"no-lonely-if": "error",
61-
"max-lines": "allow",
62-
"require-await": "allow",
63-
"max-nested-callbacks": ["error", 5],
64-
"max-classes-per-file": "allow",
65-
"radix": "allow",
66-
"no-negated-condition": "error",
67-
"no-else-return": "error",
68-
"no-throw-literal": "error",
69-
"id-length": "allow",
70-
"arrow-body-style": "allow",
71-
72-
// import
73-
"import/exports-last": "allow",
74-
"import/max-dependencies": "allow",
75-
"import/no-cycle": "error",
76-
"import/no-anonymous-default-export": "allow",
77-
"import/no-namespace": "error",
78-
"import/named": "error",
79-
"import/export": "error",
80-
"import/no-default-export": "allow",
81-
"import/unambiguous": "error",
82-
"import/group-exports": "allow",
83-
"import/extensions": "allow",
84-
"import/consistent-type-specifier-style": "allow",
85-
"import/prefer-default-export": "allow",
86-
87-
// promise
88-
"promise/no-return-wrap": "error",
89-
"promise/param-names": "error",
90-
"promise/prefer-await-to-callbacks": "error",
91-
"promise/prefer-await-to-then": "error",
92-
"promise/prefer-catch": "error",
93-
"promise/no-return-in-finally": "error",
94-
"promise/avoid-new": "error",
95-
96-
// unicorn
97-
"unicorn/error-message": "error",
98-
"unicorn/no-null": "allow",
99-
"unicorn/filename-case": "allow",
100-
"unicorn/prefer-structured-clone": "error",
101-
"unicorn/prefer-logical-operator-over-ternary": "error",
102-
"unicorn/prefer-number-properties": "error",
103-
"unicorn/prefer-array-some": "error",
104-
"unicorn/prefer-string-slice": "error",
105-
// "unicorn/no-null": "error",
106-
"unicorn/throw-new-error": "error",
107-
"unicorn/catch-error-name": "allow",
108-
"unicorn/prefer-spread": "allow",
109-
"unicorn/numeric-separators-style": "error",
110-
"unicorn/prefer-string-raw": "error",
111-
"unicorn/text-encoding-identifier-case": "error",
112-
"unicorn/no-array-for-each": "error",
113-
"unicorn/explicit-length-check": "error",
114-
"unicorn/no-lonely-if": "error",
115-
"unicorn/no-useless-undefined": "allow",
116-
"unicorn/prefer-date-now": "error",
117-
"unicorn/no-static-only-class": "allow",
118-
"unicorn/no-typeof-undefined": "error",
119-
"unicorn/prefer-negative-index": "error",
120-
"unicorn/no-anonymous-default-export": "allow",
121-
122-
// oxc
123-
"oxc/no-map-spread": "error",
124-
"oxc/no-rest-spread-properties": "allow",
125-
"oxc/no-optional-chaining": "allow",
126-
"oxc/no-async-await": "allow",
127-
"oxc/no-barrel-file": "allow",
128-
129-
// typescript
130-
"typescript/explicit-function-return-type": "allow",
131-
"typescript/consistent-type-imports": "error",
132-
"typescript/consistent-type-definitions": "error",
133-
"typescript/consistent-indexed-object-style": "allow",
134-
"typescript/no-inferrable-types": "error",
135-
"typescript/array-type": "error",
136-
"typescript/no-non-null-assertion": "error",
137-
"typescript/no-explicit-any": "error",
138-
"typescript/no-import-type-side-effects": "error",
139-
"typescript/no-dynamic-delete": "error",
140-
"typescript/prefer-ts-expect-error": "error",
141-
"typescript/ban-ts-comment": "error",
142-
"typescript/prefer-enum-initializers": "error",
143-
"typescript/explicit-module-boundary-types": "allow",
144-
145-
// jsdoc
146-
"jsdoc/require-returns": "allow",
147-
"jsdoc/require-param": "allow"
148-
},
7+
"rules": {},
1498
"ignorePatterns": [
1509
"index.d.ts",
15110
"test/fixtures/**",
15211
"__snapshots__",
15312
"example/cjs/helloworld.js"
154-
]
13+
],
14+
"extends": ["./node_modules/@eggjs/oxlint-config/.oxlintrc.json"]
15515
}

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Koa is not bundled with any middleware.
1919

2020
## Installation
2121

22-
@eggjs/koa@3 requires **node v22.17.1** or higher for Node.js LTS support.
22+
@eggjs/koa@3 requires **node v22.18.0** or higher for Node.js LTS support.
2323

2424
```bash
2525
npm install @eggjs/koa

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22
"name": "@eggjs/koa",
33
"version": "3.0.0",
44
"engines": {
5-
"node": ">= 22.17.1"
5+
"node": ">= 22.18.0"
66
},
77
"publishConfig": {
8-
"access": "public",
9-
"tag": "alpha"
8+
"access": "public"
109
},
1110
"description": "Koa web app framework for https://eggjs.org",
1211
"scripts": {
1312
"pretest": "npm run lint -- --fix",
14-
"test": "node --test --test-force-exit --test-update-snapshots --experimental-strip-types",
13+
"test": "node --test --test-force-exit --test-update-snapshots",
1514
"preci": "npm run lint",
1615
"ci": "c8 -r html -r lcov -r text npm test",
1716
"postci": "npm run prepublishOnly",
@@ -64,6 +63,7 @@
6463
"vary": "^1.1.2"
6564
},
6665
"devDependencies": {
66+
"@eggjs/oxlint-config": "^1.0.0",
6767
"@eggjs/tsconfig": "^3.0.0",
6868
"@types/accepts": "^1.3.7",
6969
"@types/content-type": "^1.1.8",
@@ -85,7 +85,7 @@
8585
"husky": "9",
8686
"lint-staged": "15",
8787
"mm": "^4.0.1",
88-
"oxlint": "^1.9.0",
88+
"oxlint": "^1.11.0",
8989
"prettier": "3",
9090
"supertest": "^3.1.0",
9191
"typescript": "^5.8.3"

src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export class Context {
203203
return;
204204
}
205205

206-
const { res } = this;
206+
const res = this.res;
207207

208208
// first unset all headers
209209
for (const name of res.getHeaderNames()) {

src/response.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export class Response {
198198
return Number.parseInt(this.get('Content-Length')) || 0;
199199
}
200200

201-
const { body } = this;
201+
const body = this.body;
202202
if (!body || body instanceof Stream) {
203203
return undefined;
204204
}

test/request/accept.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import assert from 'node:assert/strict';
22
import { describe, it } from 'node:test';
33

4-
import Accept from 'accepts';
4+
import accepts from 'accepts';
55

6-
import context, { request as Request } from '../test-helpers/context.ts';
6+
import context, { request as createRequest } from '../test-helpers/context.ts';
77

88
describe('ctx.accept', () => {
99
it('should return an Accept instance', () => {
1010
const ctx = context();
1111
ctx.req.headers.accept =
1212
'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain';
13-
assert.ok(ctx.accept instanceof Accept);
13+
assert.ok(ctx.accept instanceof accepts);
1414
});
1515
});
1616

@@ -20,10 +20,10 @@ describe('ctx.accept=', () => {
2020
ctx.req.headers.accept = 'text/plain';
2121
assert.deepStrictEqual(ctx.accepts(), ['text/plain']);
2222

23-
const request = Request();
23+
const request = createRequest();
2424
request.req.headers.accept =
2525
'application/*;q=0.2, image/jpeg;q=0.8, text/html, text/plain';
26-
ctx.accept = Accept(request.req);
26+
ctx.accept = accepts(request.req);
2727
assert.deepStrictEqual(ctx.accepts(), [
2828
'text/html',
2929
'text/plain',

test/request/ip.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { describe, it } from 'node:test';
33
import Stream from 'node:stream';
44

55
import Koa from '../../src/index.ts';
6-
import { request as Request } from '../test-helpers/context.ts';
6+
import { request as createRequest } from '../test-helpers/context.ts';
77

88
describe('req.ip', () => {
99
describe('with req.ips present', () => {
@@ -17,7 +17,7 @@ describe('req.ip', () => {
1717
req.headers['x-forwarded-for'] = '127.0.0.1';
1818
(req.socket as unknown as { remoteAddress: string }).remoteAddress =
1919
'127.0.0.2';
20-
const request = Request(req, undefined, app);
20+
const request = createRequest(req, undefined, app);
2121
assert.strictEqual(request.ip, '127.0.0.1');
2222
});
2323
});
@@ -27,7 +27,7 @@ describe('req.ip', () => {
2727
const req = { socket: new Stream.Duplex() };
2828
(req.socket as unknown as { remoteAddress: string }).remoteAddress =
2929
'127.0.0.2';
30-
const request = Request(req);
30+
const request = createRequest(req);
3131
assert.strictEqual(request.ip, '127.0.0.2');
3232
});
3333

@@ -40,7 +40,7 @@ describe('req.ip', () => {
4040
// empty
4141
},
4242
});
43-
assert.strictEqual(Request({ socket }).ip, '');
43+
assert.strictEqual(createRequest({ socket }).ip, '');
4444
});
4545
});
4646
});
@@ -49,7 +49,7 @@ describe('req.ip', () => {
4949
const req = { socket: new Stream.Duplex() };
5050
(req.socket as unknown as { remoteAddress: string }).remoteAddress =
5151
'127.0.0.2';
52-
const request = Request(req);
52+
const request = createRequest(req);
5353
assert.strictEqual(request.ip, '127.0.0.2');
5454
(req.socket as unknown as { remoteAddress: string }).remoteAddress =
5555
'127.0.0.1';
@@ -60,7 +60,7 @@ describe('req.ip', () => {
6060
const req = { socket: new Stream.Duplex() };
6161
(req.socket as unknown as { remoteAddress: string }).remoteAddress =
6262
'127.0.0.2';
63-
const request = Request(req);
63+
const request = createRequest(req);
6464
assert.strictEqual(request.ip, '127.0.0.2');
6565
request.ip = '127.0.0.1';
6666
assert.strictEqual(request.ip, '127.0.0.1');

0 commit comments

Comments
 (0)