Skip to content

Commit 9451a32

Browse files
committed
chore: fix lint errors, add lint ci
1 parent 5bec0cf commit 9451a32

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

.github/workflows/lint.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: lint
2+
on:
3+
push:
4+
pull_request:
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
- uses: oven-sh/setup-bun@v2
11+
- uses: actions/cache@v4
12+
id: cache-packages
13+
with:
14+
path: |
15+
~/.bun/install/cache
16+
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
17+
- if: steps.cache-packages.outputs.cache-hit != 'true'
18+
run: bun i --frozen-lockfile
19+
20+
- run: bun lint

eslint.config.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
import rules from '@mochaa/eslintrc';
1+
import {configBuilder} from '@mochaa/eslintrc';
22

3-
export default rules;
3+
export default configBuilder({}, {
4+
rules: {
5+
'node/prefer-global/process': 'off',
6+
},
7+
});

src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ app.mount('/https:/', routes);
77
app.mount('/http:/', routes);
88
bind(app);
99

10-
app.add('GET', /(?:)/, async (request, context) => {
11-
console.log(request.url);
12-
return context.bindings.ASSETS.fetch(request);
13-
});
10+
// eslint-disable-next-line regexp/no-empty-group
11+
app.add('GET', /(?:)/, async (request, context) => context.bindings.ASSETS.fetch(request));
1412

1513
export default app;

src/routes/github.com.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ app.add('GET', '/:user/:repo/releases/download/*', async (request, context) => {
2424
`https://github.com/${user}/${repo}/releases/download/${wild}`,
2525
{
2626
redirect: 'follow',
27-
headers: range ? headers : undefined,
27+
headers: range === null ? headers : undefined,
2828
},
2929
);
3030
});
@@ -46,7 +46,7 @@ app.add('GET', '/:user/:repo/releases/latest/download/:artifact', async (request
4646
`https://github.com/${user}/${repo}/releases/latest/download/${artifact}`,
4747
{
4848
redirect: 'follow',
49-
headers: range ? headers : undefined,
49+
headers: range === null ? headers : undefined,
5050
},
5151
);
5252
});
@@ -101,7 +101,7 @@ app.add('GET', '/:user/:repo/raw/*', async (_, context) => {
101101

102102
app.add('GET', '/:user/:repo/info/refs', async (request, context) => {
103103
const service = context.url.searchParams.get('service');
104-
if (!service) {
104+
if (service === null) {
105105
return reply(403, `Please upgrade your git client.
106106
GitHub.com no longer supports git over dumb-http: https://github.com/blog/809`);
107107
}
@@ -118,7 +118,7 @@ GitHub.com no longer supports git over dumb-http: https://github.com/blog/809`);
118118
const headers = new Headers();
119119
const protocol = request.headers.get('git-protocol');
120120

121-
if (protocol) {
121+
if (protocol !== null) {
122122
headers.set('Git-Protocol', protocol);
123123
}
124124

@@ -138,15 +138,15 @@ app.add('POST', '/:user/:repo/git-upload-pack', async (request, context) => {
138138
const type = request.headers.get('content-type');
139139
const encoding = request.headers.get('content-encoding');
140140

141-
if (protocol) {
141+
if (protocol !== null) {
142142
headers.set('Git-Protocol', protocol);
143143
}
144144

145-
if (type) {
145+
if (type !== null) {
146146
headers.set('Content-Type', type);
147147
}
148148

149-
if (encoding) {
149+
if (encoding !== null) {
150150
headers.set('Content-Encoding', encoding);
151151
}
152152

0 commit comments

Comments
 (0)