Skip to content

Commit 397fc3e

Browse files
chore(minor-deps): update dependency @scaleway/eslint-config-react to ^3.10.0 (#238)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Vincent Germain <[email protected]>
1 parent df411ac commit 397fc3e

25 files changed

+246
-91
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"@rollup/plugin-commonjs": "^23.0.2",
7979
"@rollup/plugin-inject": "^5.0.2",
8080
"@rollup/plugin-node-resolve": "^15.0.1",
81-
"@scaleway/eslint-config-react": "^3.8.3",
81+
"@scaleway/eslint-config-react": "^3.10.0",
8282
"@types/jest": "^29.2.3",
8383
"babel-plugin-annotate-pure-calls": "^0.4.0",
8484
"cross-env": "^7.0.3",

packages/clients/src/api/.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"max-classes-per-file": "off",
77
"tsdoc/syntax": "off",
88
"no-underscore-dangle": ["error", { "allowAfterThis": true }],
9-
"deprecation/deprecation": "off"
9+
"deprecation/deprecation": "off",
10+
"no-restricted-syntax": "off"
1011
}
1112
}

packages/clients/src/helpers/marshalling.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const unmarshalMapOfObject = <T, B extends boolean>(
145145
: Record<string, T>
146146
}
147147

148-
return Object.entries(data || {}).reduce(
148+
return Object.entries(data).reduce(
149149
(acc, [key, value]) => ({
150150
...acc,
151151
[key]: unmarshaller(value),

packages/clients/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ export {
1717
} from './scw/client-ini-factory'
1818
export type { ClientConfig } from './scw/client-ini-factory'
1919
export type { Money, ScwFile, TimeSeries } from './scw/custom-types'
20+
/* eslint-disable import/export,no-restricted-syntax */
2021
export * as Errors from './scw/errors/standard'
2122
export type { Region, Zone } from './scw/locality'
22-
/* eslint-disable import/export */
2323
export * from './internals'
2424
export * from './api'
25-
/* eslint-enable import/export */
25+
/* eslint-enable import/export,no-restricted-syntax */

packages/clients/src/internal/logger/console-logger.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ export class ConsoleLogger implements Logger {
2424

2525
private makeMethod(method: 'debug' | 'info' | 'warn' | 'error') {
2626
return (message: string) => {
27-
if (shouldLog(this.level, method))
27+
if (shouldLog(this.level, method)) {
2828
this.output[method](this.prefix ? `${this.prefix} ${message}` : message)
29+
}
2930
}
3031
}
3132

packages/clients/src/scw/client-ini-factory.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,27 @@ export const withProfile =
2424
(profile: Readonly<Profile>) =>
2525
(settings: Readonly<Settings>): Settings => {
2626
const newSettings = { ...settings }
27-
if (profile.apiURL) newSettings.apiURL = profile.apiURL
28-
if (profile.defaultOrganizationId)
27+
if (profile.apiURL) {
28+
newSettings.apiURL = profile.apiURL
29+
}
30+
if (profile.defaultOrganizationId) {
2931
newSettings.defaultOrganizationId = profile.defaultOrganizationId
30-
if (profile.defaultProjectId)
32+
}
33+
if (profile.defaultProjectId) {
3134
newSettings.defaultProjectId = profile.defaultProjectId
32-
if (profile.defaultRegion) newSettings.defaultRegion = profile.defaultRegion
33-
if (profile.defaultZone) newSettings.defaultZone = profile.defaultZone
34-
if (hasAuthenticationSecrets(profile))
35+
}
36+
if (profile.defaultRegion) {
37+
newSettings.defaultRegion = profile.defaultRegion
38+
}
39+
if (profile.defaultZone) {
40+
newSettings.defaultZone = profile.defaultZone
41+
}
42+
if (hasAuthenticationSecrets(profile)) {
3543
newSettings.requestInterceptors = [
3644
authenticateWithSecrets(profile),
3745
...settings.requestInterceptors,
3846
]
47+
}
3948

4049
return newSettings
4150
}

packages/clients/src/scw/client-ini-profile.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,19 @@ export const hasAuthenticationSecrets = (
9797
export function assertValidAuthenticationSecrets(
9898
obj: Partial<AuthenticationSecrets>,
9999
): asserts obj is AuthenticationSecrets {
100-
if (!(obj.accessKey && obj.secretKey))
100+
if (!(obj.accessKey && obj.secretKey)) {
101101
throw new Error(
102102
`Invalid secrets, accessKey & secretKey must be defined. See https://www.scaleway.com/docs/console/my-project/how-to/generate-api-key`,
103103
)
104-
if (!isAccessKey(obj.accessKey))
104+
}
105+
if (!isAccessKey(obj.accessKey)) {
105106
throw new Error(
106107
`Invalid access key format '${obj.accessKey}', expected SCWXXXXXXXXXXXXXXXXX format. See https://www.scaleway.com/docs/console/my-project/how-to/generate-api-key`,
107108
)
108-
if (!isSecretKey(obj.secretKey))
109+
}
110+
if (!isSecretKey(obj.secretKey)) {
109111
throw new Error(
110112
`Invalid secret key format '${obj.secretKey}', expected a UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. See https://www.scaleway.com/docs/console/my-project/how-to/generate-api-key`,
111113
)
114+
}
112115
}

packages/clients/src/scw/client-settings.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,36 +91,45 @@ export const assertValidSettings = (obj: Readonly<Settings>): void => {
9191
}
9292

9393
// Default Region.
94-
if (obj.defaultRegion && !isRegion(obj.defaultRegion))
94+
if (obj.defaultRegion && !isRegion(obj.defaultRegion)) {
9595
throw new Error(`Invalid default region format '${obj.defaultRegion}'`)
96+
}
9697

9798
// Default Zone.
98-
if (obj.defaultZone && !isZone(obj.defaultZone))
99+
if (obj.defaultZone && !isZone(obj.defaultZone)) {
99100
throw new Error(`Invalid default zone format '${obj.defaultZone}'`)
101+
}
100102

101103
// API URL.
102-
if (!isURL(obj.apiURL)) throw new Error(`Invalid URL ${obj.apiURL}`)
104+
if (!isURL(obj.apiURL)) {
105+
throw new Error(`Invalid URL ${obj.apiURL}`)
106+
}
103107

104-
if (obj.apiURL.slice(-1) === '/')
108+
if (obj.apiURL.slice(-1) === '/') {
105109
throw new Error(
106110
`Invalid URL ${obj.apiURL}: it should not have a trailing slash`,
107111
)
112+
}
108113

109114
// HTTP Client.
110-
if (typeof obj.httpClient !== typeof fetch)
115+
if (typeof obj.httpClient !== typeof fetch) {
111116
throw new Error(`Invalid HTTP Client`)
117+
}
112118

113119
// Default Page Size.
114120
if (
115121
obj.defaultPageSize !== undefined &&
116122
(typeof obj.defaultPageSize !== 'number' ||
117123
Number.isNaN(obj.defaultPageSize) ||
118124
obj.defaultPageSize <= 0)
119-
)
125+
) {
120126
throw new Error(
121127
`Invalid defaultPageSize ${obj.defaultPageSize}: it should be a number above 0`,
122128
)
129+
}
123130

124131
// User Agent.
125-
if (typeof obj.userAgent !== 'string') throw new Error(`Invalid User-Agent`)
132+
if (typeof obj.userAgent !== 'string') {
133+
throw new Error(`Invalid User-Agent`)
134+
}
126135
}

packages/clients/src/scw/errors/non-standard/invalid-request-mapper.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ export class InvalidRequestMapper {
1717
if (
1818
typeof obj.message === 'string' &&
1919
obj.message.toLowerCase().includes('quota exceeded for this resource')
20-
)
20+
) {
2121
return new QuotasExceededError(status, obj, [
2222
{
2323
current: 0,
2424
quota: 0,
2525
resource: typeof obj.resource === 'string' ? obj.resource : '',
2626
},
2727
])
28+
}
2829

2930
const fields =
3031
obj.fields && isRecordOfStringArray(obj.fields) ? obj.fields : {}
3132
const fieldsMessages = Object.entries(fields)
32-
if (fieldsMessages.length)
33+
if (fieldsMessages.length) {
3334
return new InvalidArgumentsError(
3435
status,
3536
obj,
@@ -43,6 +44,7 @@ export class InvalidRequestMapper {
4344
)
4445
.flat(),
4546
)
47+
}
4648

4749
return new ScalewayError(status, obj)
4850
}

packages/clients/src/scw/errors/non-standard/unknown-resource-mapper.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class UnknownResourceMapper {
1818
// Examples: `"111..." not found` or `Security Group '111...' not found`
1919
const messageParts =
2020
typeof obj.message === 'string' ? obj.message.split(/"|'/) : []
21-
if (messageParts.length === 3 && isUUID(messageParts[1]))
21+
if (messageParts.length === 3 && isUUID(messageParts[1])) {
2222
return new ResourceNotFoundError(
2323
status,
2424
obj,
@@ -28,6 +28,7 @@ export class UnknownResourceMapper {
2828
messageParts[0].trim().toLowerCase().split(' ').join('_'),
2929
messageParts[1],
3030
)
31+
}
3132

3233
return new ScalewayError(status, obj)
3334
}

0 commit comments

Comments
 (0)