Skip to content

Commit 15e6e55

Browse files
committed
fix: resolve all non-breaking lint errors in handwritten code
1 parent 1e1c52e commit 15e6e55

File tree

28 files changed

+250
-181
lines changed

28 files changed

+250
-181
lines changed

biome.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,58 @@
112112
}
113113
},
114114
"overrides": [
115+
{
116+
"includes": ["**/dist/**"],
117+
"linter": {
118+
"enabled": false
119+
}
120+
},
121+
{
122+
"includes": ["coverage/**"],
123+
"linter": {
124+
"enabled": false
125+
}
126+
},
127+
{
128+
"includes": ["**/vite.config.ts", "**/vitest.config.ts"],
129+
"linter": {
130+
"rules": {
131+
"style": {
132+
"noDefaultExport": "off"
133+
}
134+
}
135+
}
136+
},
137+
{
138+
"includes": ["packages/client/src/internal/logger/level-resolver.ts"],
139+
"linter": {
140+
"rules": {
141+
"style": {
142+
"useNamingConvention": "off"
143+
}
144+
}
145+
}
146+
},
147+
{
148+
"includes": ["scripts/**/*.ts"],
149+
"linter": {
150+
"rules": {
151+
"style": {
152+
"useNamingConvention": "off"
153+
}
154+
}
155+
}
156+
},
157+
{
158+
"includes": ["packages/sdk/src/index.gen.ts"],
159+
"linter": {
160+
"rules": {
161+
"suspicious": {
162+
"noShadowRestrictedNames": "off"
163+
}
164+
}
165+
}
166+
},
115167
{
116168
"includes": [
117169
"packages/client/src/internal/interceptors/types.ts"
@@ -131,6 +183,9 @@
131183
"rules": {
132184
"correctness": {
133185
"noUnusedVariables": "off"
186+
},
187+
"style": {
188+
"useNamingConvention": "off"
134189
}
135190
}
136191
}

examples/nodejs-minimal/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
44
import { Registry } from '@scaleway/sdk'
55
import { createClient } from '@scaleway/sdk-client'
6-
import * as http from 'http'
6+
import * as http from 'node:http'
77

88
const hostname = '127.0.0.1'
99
const port = 3000

examples/serverless-function-minimal/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ const buildErrorRes = (error?: unknown) => ({
1818
statusCode: error instanceof Errors.ScalewayError ? error.status : 500,
1919
})
2020

21-
export const list = async (event: any, context: any, callback: any) => {
21+
export const list = async (
22+
_event: unknown,
23+
_context: unknown,
24+
_callback: unknown,
25+
) => {
2226
try {
2327
return buildJsonRes(await api.listNamespaces().all())
2428
} catch (error) {

package.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"format": "biome check --linter-enabled=false --write .",
2727
"format:check": "biome check --linter-enabled=false .",
2828
"prettier": "prettier --write '**/*.{md,mdx,yml,yaml}'",
29-
"lint": "biome lint packages/*/src scripts/**/*.ts",
29+
"lint": "biome lint .",
3030
"lint:fix": "biome check --write .",
3131
"prepare": "husky",
3232
"test": "vitest run",
@@ -35,17 +35,10 @@
3535
"test:ui": "vitest --ui"
3636
},
3737
"lint-staged": {
38-
"globOptions": {
39-
"ignore": [
40-
"**/*.gen.ts",
41-
"packages_generated/**",
42-
"**/dist/**",
43-
"**/build/**",
44-
"**/coverage/**",
45-
"**/examples/**"
46-
]
47-
},
48-
"*.{ts,tsx,js,jsx}": [
38+
"packages/*/src/**/*.{ts,tsx,js,jsx}": [
39+
"biome check --write --no-errors-on-unmatched --files-ignore-unknown=true"
40+
],
41+
"scripts/**/*.ts": [
4942
"biome check --write --no-errors-on-unmatched --files-ignore-unknown=true"
5043
],
5144
"*.json": [

packages/client/src/helpers/__tests__/json.test.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ describe('isJSON', () => {
99
},
1010
)
1111

12-
test.each([undefined, () => {}, Symbol(42)])(
13-
`rejects %s as a valid JSON value`,
14-
obj => {
15-
expect(isJSON(obj)).toBeFalsy()
12+
test.each([
13+
undefined,
14+
() => {
15+
/* noop */
1616
},
17-
)
17+
Symbol(42),
18+
])(`rejects %s as a valid JSON value`, obj => {
19+
expect(isJSON(obj)).toBeFalsy()
20+
})
1821
})
1922

2023
describe('isJSONObject', () => {
@@ -32,7 +35,9 @@ describe('isJSONObject', () => {
3235
null,
3336
[true, 'two', 3],
3437
undefined,
35-
() => {},
38+
() => {
39+
/* noop */
40+
},
3641
Symbol(42),
3742
])(`rejects %s as a valid JSONObject value`, obj => {
3843
expect(isJSONObject(obj)).toBeFalsy()

packages/client/src/helpers/__tests__/marshalling.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ describe('resolveOneOf', () => {
9494
[{ default: undefined, param: 'my_key', value: '42' }],
9595
true,
9696
),
97+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
9798
).toStrictEqual({ my_key: '42' })
9899
})
99100

@@ -106,6 +107,7 @@ describe('resolveOneOf', () => {
106107
],
107108
true,
108109
),
110+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
109111
).toStrictEqual({ my_key_2: '42' })
110112
})
111113

@@ -118,6 +120,7 @@ describe('resolveOneOf', () => {
118120
],
119121
true,
120122
),
123+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
121124
).toStrictEqual({ my_key_1: '42' })
122125

123126
expect(
@@ -128,6 +131,7 @@ describe('resolveOneOf', () => {
128131
],
129132
true,
130133
),
134+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
131135
).toStrictEqual({ my_key_1: '42' })
132136
})
133137

@@ -168,6 +172,7 @@ describe('resolveOneOf', () => {
168172
],
169173
false,
170174
),
175+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
171176
).toStrictEqual({ my_key_1: false })
172177
})
173178
})
@@ -201,6 +206,7 @@ describe('unmarshalArrayOfObject', () => {
201206
it('unmarshals valid array of object', () => {
202207
expect(
203208
unmarshalArrayOfObject(
209+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
204210
[{ my_number: 42 }, { my_number: 94 }],
205211
unmarshaller,
206212
),
@@ -229,6 +235,7 @@ describe('unmarshalMapOfObject', () => {
229235
it('unmarshals valid array of object', () => {
230236
expect(
231237
unmarshalMapOfObject(
238+
/* biome-ignore lint/style/useNamingConvention: test data uses snake_case intentionally */
232239
{ 'first-key': { my_number: 42 }, 'second-key': { my_number: 94 } },
233240
unmarshaller,
234241
),

packages/client/src/helpers/json.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,14 @@ export const camelizeKeys = <T>(
9595
}
9696

9797
if (obj && typeof obj === 'object' && !(obj instanceof Date)) {
98-
return Object.entries(obj).reduce(
99-
(acc, [key, value]) => ({
100-
...acc,
101-
[camelize(key)]: ignoreKeys.includes(key)
102-
? (value as unknown)
103-
: camelizeKeys(value, ignoreKeys),
104-
}),
105-
{},
106-
) as T
98+
const result: Record<string, unknown> = {}
99+
for (const [key, value] of Object.entries(obj)) {
100+
const outKey = camelize(key)
101+
result[outKey] = ignoreKeys.includes(key)
102+
? (value as unknown)
103+
: camelizeKeys(value, ignoreKeys)
104+
}
105+
return result as T
107106
}
108107

109108
return obj as T

packages/client/src/helpers/marshalling.ts

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,30 @@ type URLParameterValue = string | number | boolean | Date | null
6767
*
6868
* @internal
6969
*/
70+
const toParamString = (v: URLParameterValue): string | null => {
71+
if (v === null) return null
72+
if (v instanceof Date) return v.toISOString()
73+
return v.toString()
74+
}
75+
7076
export const urlParams = (
7177
...paramTuples: Readonly<
7278
[string, URLParameterValue | URLParameterValue[] | undefined]
7379
>[]
7480
) => {
7581
const params = new URLSearchParams()
7682
for (const [key, value] of paramTuples) {
77-
if (typeof key === 'string' && value != null) {
78-
if (Array.isArray(value)) {
79-
for (const innerValue of value) {
80-
if (innerValue !== null) {
81-
params.append(
82-
key,
83-
innerValue instanceof Date
84-
? innerValue.toISOString()
85-
: innerValue.toString(),
86-
)
87-
}
88-
}
89-
} else {
90-
params.append(
91-
key,
92-
value instanceof Date ? value.toISOString() : value.toString(),
93-
)
83+
if (typeof key !== 'string' || value == null) continue
84+
if (Array.isArray(value)) {
85+
for (const inner of value) {
86+
const s = toParamString(inner)
87+
if (s !== null) params.append(key, s)
9488
}
89+
continue
9590
}
91+
const s = toParamString(value)
92+
if (s !== null) params.append(key, s)
9693
}
97-
9894
return params
9995
}
10096

@@ -155,11 +151,9 @@ export const unmarshalMapOfObject = <T, B extends boolean>(
155151
: Record<string, T>
156152
}
157153

158-
return Object.entries(data).reduce(
159-
(acc, [key, value]) => ({
160-
...acc,
161-
[key]: unmarshaller(value),
162-
}),
163-
{},
164-
)
154+
const out: Record<string, T> = {}
155+
for (const [key, value] of Object.entries(data)) {
156+
out[key] = unmarshaller(value)
157+
}
158+
return out
165159
}

packages/client/src/internal/async/__tests__/interval-retrier.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ const mockLogic = (iterations: number, workingTime: number) => {
9797
done: counter >= iterations,
9898
value: {
9999
doneIterations: counter,
100-
totalDuration: new Date().getTime() - startDate.getTime(),
100+
totalDuration: Date.now() - startDate.getTime(),
101101
},
102102
}
103103
}

packages/client/src/internal/async/__tests__/sleep.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ afterAll(() => {
1313
describe('sleep', () => {
1414
it('delays the proper amount of time', () => {
1515
const delay = 50 // 0.05s
16-
sleep(delay).catch(() => {})
16+
sleep(delay).catch(() => {
17+
/* noop */
18+
})
1719
expect(setTimeout).toHaveBeenCalledTimes(1)
1820
expect(setTimeout).toHaveBeenLastCalledWith(expect.any(Function), delay)
1921
})

0 commit comments

Comments
 (0)