Skip to content

Commit

Permalink
fix(setupWorker): remove left-over console.log() (#2099)
Browse files Browse the repository at this point in the history
  • Loading branch information
kettanaito committed Mar 18, 2024
1 parent a33d9e5 commit cf97991
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 29 deletions.
9 changes: 5 additions & 4 deletions .eslintignore
@@ -1,4 +1,5 @@
lib
node
native
test/typings
/lib
/node
/native
/config
/test
7 changes: 7 additions & 0 deletions .eslintrc.js
Expand Up @@ -9,6 +9,13 @@ module.exports = {
'plugin:prettier/recommended',
],
rules: {
// Forbid "console.debug()" statements.
'no-console': [
'error',
{
allow: ['log', 'warn', 'error', 'group', 'groupCollapsed', 'groupEnd'],
},
],
'@typescript-eslint/prefer-ts-expect-error': 2,
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
Expand Down
2 changes: 0 additions & 2 deletions src/browser/setupWorker/start/createResponseListener.ts
Expand Up @@ -21,8 +21,6 @@ export function createResponseListener(context: SetupWorkerInternalContext) {
const request = context.requests.get(requestId)!
context.requests.delete(requestId)

console.log('RESPONSE LISTENER', responseJson, context.requests)

/**
* CORS requests with `mode: "no-cors"` result in "opaque" responses.
* That kind of responses cannot be manipulated in JavaScript due
Expand Down
20 changes: 10 additions & 10 deletions src/core/typeUtils.ts
Expand Up @@ -8,13 +8,13 @@ export type RequiredDeep<
> = Type extends Fn
? Type
: /**
* @note The "Fn" type satisfies the predicate below.
* It must always come first, before the Record check.
*/
Type extends Record<string, any>
? {
[Key in keyof Type]-?: NonNullable<Type[Key]> extends NonNullable<U>
? NonNullable<Type[Key]>
: RequiredDeep<NonNullable<Type[Key]>, U>
}
: Type
* @note The "Fn" type satisfies the predicate below.
* It must always come first, before the Record check.
*/
Type extends Record<string, any>
? {
[Key in keyof Type]-?: NonNullable<Type[Key]> extends NonNullable<U>
? NonNullable<Type[Key]>
: RequiredDeep<NonNullable<Type[Key]>, U>
}
: Type
29 changes: 16 additions & 13 deletions src/core/utils/internal/mergeRight.ts
Expand Up @@ -8,20 +8,23 @@ export function mergeRight(
left: Record<string, any>,
right: Record<string, any>,
) {
return Object.entries(right).reduce((result, [key, rightValue]) => {
const leftValue = result[key]
return Object.entries(right).reduce(
(result, [key, rightValue]) => {
const leftValue = result[key]

if (Array.isArray(leftValue) && Array.isArray(rightValue)) {
result[key] = leftValue.concat(rightValue)
return result
}
if (Array.isArray(leftValue) && Array.isArray(rightValue)) {
result[key] = leftValue.concat(rightValue)
return result
}

if (isObject(leftValue) && isObject(rightValue)) {
result[key] = mergeRight(leftValue, rightValue)
return result
}
if (isObject(leftValue) && isObject(rightValue)) {
result[key] = mergeRight(leftValue, rightValue)
return result
}

result[key] = rightValue
return result
}, Object.assign({}, left))
result[key] = rightValue
return result
},
Object.assign({}, left),
)
}

0 comments on commit cf97991

Please sign in to comment.