manually applying the lint fixes that get applied in GitHub actions

This commit is contained in:
Keith Stevens
2023-01-28 20:53:02 +09:00
parent 4709223e93
commit 656d44529b
+13 -12
View File
@@ -98,7 +98,7 @@ self.addEventListener('fetch', function (event) {
return return
} }
// Opening the DevTools triggers the 'only-if-cached' request // Opening the DevTools triggers the "only-if-cached" request
// that cannot be handled by the worker. Bypass such requests. // that cannot be handled by the worker. Bypass such requests.
if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') { if (request.cache === 'only-if-cached' && request.mode !== 'same-origin') {
return return
@@ -118,9 +118,9 @@ self.addEventListener('fetch', function (event) {
handleRequest(event, requestId).catch((error) => { handleRequest(event, requestId).catch((error) => {
if (error.name === 'NetworkError') { if (error.name === 'NetworkError') {
console.warn( console.warn(
'[MSW] Successfully emulated a network error for the '%s %s' request.', '[MSW] Successfully emulated a network error for the "%s %s" request.',
request.method, request.method,
request.url request.url,
) )
return return
} }
@@ -128,12 +128,12 @@ self.addEventListener('fetch', function (event) {
// At this point, any exception indicates an issue with the original request/response. // At this point, any exception indicates an issue with the original request/response.
console.error( console.error(
`\ `\
[MSW] Caught an exception from the '%s %s' request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`, [MSW] Caught an exception from the "%s %s" request (%s). This is probably not a problem with Mock Service Worker. There is likely an additional logging output above.`,
request.method, request.method,
request.url, request.url,
`${error.name}: ${error.message}` `${error.name}: ${error.message}`,
) )
}) }),
) )
}) })
@@ -141,7 +141,7 @@ async function handleRequest(event, requestId) {
const client = await resolveMainClient(event) const client = await resolveMainClient(event)
const response = await getResponse(event, client, requestId) const response = await getResponse(event, client, requestId)
// Send back the response clone for the 'response:*' life-cycle events. // Send back the response clone for the "response:*" life-cycle events.
// Ensure MSW is active and ready to handle the message, otherwise // Ensure MSW is active and ready to handle the message, otherwise
// this message will pend indefinitely. // this message will pend indefinitely.
if (client && activeClientIds.has(client.id)) { if (client && activeClientIds.has(client.id)) {
@@ -155,7 +155,8 @@ async function handleRequest(event, requestId) {
ok: clonedResponse.ok, ok: clonedResponse.ok,
status: clonedResponse.status, status: clonedResponse.status,
statusText: clonedResponse.statusText, statusText: clonedResponse.statusText,
body: clonedResponse.body === null ? null : await clonedResponse.text(), body:
clonedResponse.body === null ? null : await clonedResponse.text(),
headers: Object.fromEntries(clonedResponse.headers.entries()), headers: Object.fromEntries(clonedResponse.headers.entries()),
redirected: clonedResponse.redirected, redirected: clonedResponse.redirected,
}, },
@@ -204,7 +205,7 @@ async function getResponse(event, client, requestId) {
// Remove MSW-specific request headers so the bypassed requests // Remove MSW-specific request headers so the bypassed requests
// comply with the server's CORS preflight check. // comply with the server's CORS preflight check.
// Operate with the headers as an object because request 'Headers' // Operate with the headers as an object because request "Headers"
// are immutable. // are immutable.
delete headers['x-msw-bypass'] delete headers['x-msw-bypass']
@@ -218,14 +219,14 @@ async function getResponse(event, client, requestId) {
// Bypass initial page load requests (i.e. static assets). // Bypass initial page load requests (i.e. static assets).
// The absence of the immediate/parent client in the map of the active clients // The absence of the immediate/parent client in the map of the active clients
// means that MSW hasn't dispatched the 'MOCK_ACTIVATE' event yet // means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
// and is not ready to handle requests. // and is not ready to handle requests.
if (!activeClientIds.has(client.id)) { if (!activeClientIds.has(client.id)) {
return passthrough() return passthrough()
} }
// Bypass requests with the explicit bypass header. // Bypass requests with the explicit bypass header.
// Such requests can be issued by 'ctx.fetch()'. // Such requests can be issued by "ctx.fetch()".
if (request.headers.get('x-msw-bypass') === 'true') { if (request.headers.get('x-msw-bypass') === 'true') {
return passthrough() return passthrough()
} }
@@ -266,7 +267,7 @@ async function getResponse(event, client, requestId) {
const networkError = new Error(message) const networkError = new Error(message)
networkError.name = name networkError.name = name
// Rejecting a 'respondWith' promise emulates a network error. // Rejecting a "respondWith" promise emulates a network error.
throw networkError throw networkError
} }
} }