Skip to content

Commit 10c0d0f

Browse files
committed
Fix unicorn lint errors from eslint-plugin-unicorn v65
Add split() limits and use .includes() over repeated equality checks.
1 parent e78d9d3 commit 10c0d0f

7 files changed

Lines changed: 28 additions & 32 deletions

File tree

bun.lock

Lines changed: 20 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integration/scenarios/s31-sse-streaming.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('S31 — SSE streaming', () => {
5454
expect(text).toContain('"done":true');
5555

5656
// Parse the SSE event
57-
const jsonStr = text.split('data: ')[1]?.split('\n')[0] ?? '';
57+
const jsonStr = text.split('data: ', 2)[1]?.split('\n', 1)[0] ?? '';
5858
const event = JSON.parse(jsonStr) as { done: boolean; airnode: string; endpointId: string; signature: string };
5959

6060
expect(event.done).toBe(true);
@@ -73,7 +73,7 @@ describe('S31 — SSE streaming', () => {
7373
});
7474

7575
const text = await response.text();
76-
const jsonStr = text.split('data: ')[1]?.split('\n')[0] ?? '';
76+
const jsonStr = text.split('data: ', 2)[1]?.split('\n', 1)[0] ?? '';
7777
const event = JSON.parse(jsonStr) as { data: Hex; timestamp: number };
7878

7979
// WeatherAPI currentTemp has encoding — data should be ABI-encoded

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"eslint-plugin-functional": "^10.0.0",
3939
"eslint-plugin-import-x": "^4.16.2",
4040
"eslint-plugin-promise": "^7.3.0",
41-
"eslint-plugin-unicorn": "^64.0.0",
41+
"eslint-plugin-unicorn": "^65.0.1",
4242
"prettier": "3.8.4",
4343
"prettier-plugin-solidity": "^2.3.1",
4444
"typescript-eslint": "^8.61.0"

src/api/call.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function buildApiRequest(api: Api, endpoint: Endpoint, requestParameters: Record
8787
headers['Cookie'] = existing ? `${existing}; ${cookieString}` : cookieString; // eslint-disable-line functional/immutable-data
8888
}
8989

90-
const hasBody = endpoint.method === 'POST' || endpoint.method === 'PUT' || endpoint.method === 'PATCH';
90+
const hasBody = ['POST', 'PUT', 'PATCH'].includes(endpoint.method);
9191
const body = hasBody && Object.keys(bodyParameters).length > 0 ? JSON.stringify(bodyParameters) : undefined;
9292

9393
if (body && !headers['Content-Type']) {

src/api/process.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function castToUint256(raw: JsonValue, multiply: string | undefined): bigint {
116116
}
117117

118118
function castToBool(raw: JsonValue): boolean {
119-
return raw === true || raw === 'true' || raw === 1 || raw === '1';
119+
return ([true, 'true', 1, '1'] as JsonValue[]).includes(raw);
120120
}
121121

122122
function castToBytes32(raw: JsonValue): Hex {

src/logger.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ describe('text format', () => {
9191
logger.info('short');
9292
});
9393
const output = lastCall(infoMock);
94-
const afterLevel = output.split(' INFO ')[1] ?? '';
95-
const beforeMeta = afterLevel.split('requestId=')[0] ?? '';
94+
const afterLevel = output.split(' INFO ', 2)[1] ?? '';
95+
const beforeMeta = afterLevel.split('requestId=', 1)[0] ?? '';
9696
expect(beforeMeta.length).toBeGreaterThanOrEqual(80);
9797
});
9898

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function parseRequestRoute(pathname: string): string | undefined {
8686
// entry — the originating client — instead.
8787
function resolveClientIp(request: Request, peerAddress: string | undefined, trustForwardedFor: boolean): string {
8888
if (trustForwardedFor) {
89-
const forwarded = request.headers.get('X-Forwarded-For')?.split(',')[0]?.trim();
89+
const forwarded = request.headers.get('X-Forwarded-For')?.split(',', 1)[0]?.trim();
9090
if (forwarded) return forwarded;
9191
}
9292
return peerAddress ?? 'unknown';

0 commit comments

Comments
 (0)