Skip to content

Commit

Permalink
chore: fix eslint in cache-dir/loader (#9002)
Browse files Browse the repository at this point in the history
# Overview
I've tried fixing #6300, I  encountered 2 ESLInt error.
In original Google Translate Issue, I'm considering how approach to fix馃

<img width="1241" alt="screen shot 2018-10-11 at 2 15 14" src="https://user-images.githubusercontent.com/5501268/46754799-5125ee80-ccfe-11e8-81dd-646a3bd74dee.png">
  • Loading branch information
ryota-murakami authored and pieh committed Oct 22, 2018
1 parent 8e27d72 commit 58317b7
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions packages/gatsby/cache-dir/loader.js
Expand Up @@ -166,13 +166,6 @@ const onPostPrefetchPathname = pathname => {
// let pathArray = []
// let pathCount = {}

let resourcesCount = Object.create(null)
const sortResourcesByCount = (a, b) => {
if (resourcesCount[a] > resourcesCount[b]) return 1
else if (resourcesCount[a] < resourcesCount[b]) return -1
else return 0
}

let findPage
let pathScriptsCache = {}
let prefetchTriggered = {}
Expand Down Expand Up @@ -290,7 +283,8 @@ const queue = {
path,
`Previously detected load failure for "${path}"`
)
return reject()
reject()
return
}
const page = findPage(path)

Expand All @@ -303,20 +297,23 @@ const queue = {
) {
// If page wasn't found check and we didn't fetch resources map for
// all pages, wait for fetch to complete and try to get resources again
return fetchPageResourceMap().then(() =>
fetchPageResourceMap().then(() =>
resolve(queue.getResourcesForPathname(path))
)
return
}

if (!page) {
console.log(`A page wasn't found for "${path}"`)

// Preload the custom 404 page
if (path !== `/404.html`) {
return resolve(queue.getResourcesForPathname(`/404.html`))
resolve(queue.getResourcesForPathname(`/404.html`))
return
}

return resolve()
resolve()
return
}

// Use the path from the page so the pathScriptsCache uses
Expand All @@ -329,7 +326,8 @@ const queue = {
page,
pageResources: pathScriptsCache[path],
})
return resolve(pathScriptsCache[path])
resolve(pathScriptsCache[path])
return
}

// Nope, we need to load resource(s)
Expand Down

0 comments on commit 58317b7

Please sign in to comment.