Skip to content

Commit

Permalink
refactor: replace catch(_) with catch in try-catch blocks (#3350)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinfoil-knight authored Sep 17, 2021
1 parent 5022c28 commit 23af91f
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const format = (message, styles) => {
styles.forEach((style) => {
func = func[style]
})
} catch (_) {}
} catch {}
return func(message)
}

Expand Down
4 changes: 2 additions & 2 deletions site/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const rimrafAsync = util.promisify(rimraf)
const copyDirRecursiveAsync = async (src, dest) => {
try {
fs.mkdir(dest, { recursive: true })
} catch (_) {
} catch {
// ignore erros for mkdir
}

Expand All @@ -34,7 +34,7 @@ const copyDirRecursiveAsync = async (src, dest) => {
const ensureFilePathAsync = async (filePath) => {
try {
await fs.mkdir(path.dirname(filePath), { recursive: true })
} catch (_) {
} catch {
// ignore any errors with mkdir - it will throw if the path already exists.
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/lm/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LmInfoCommand extends Command {
const tasks = new Listr(steps, { concurrent: true, exitOnError: false })
try {
await tasks.run()
} catch (_) {
} catch {
// an error is already reported when a task fails
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const fileExistsAsync = async (filePath) => {
try {
await accessAsync(filePath, fs.F_OK)
return true
} catch (_) {
} catch {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/functions/runtimes/go/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const checkGoInstallation = async ({ cwd }) => {
await execa('go', ['version'], { cwd })

return true
} catch (_) {
} catch {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/functions/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const buildClientContext = function (headers) {
},
user: jwtDecode(parts[1]),
}
} catch (_) {
} catch {
// Ignore errors - bearer token is not a JWT, probably not intended for us
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class BaseCommand extends TrackedCommand {
try {
await this.netlify.api.getCurrentUser()
return true
} catch (_) {
} catch {
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/get-global-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const getGlobalConfigOnce = async function () {
// Read legacy config if exists
try {
legacyConfig = JSON.parse(await readFileAsync(legacyPath))
} catch (_) {}
} catch {}
// Use legacy config as default values
const defaults = { ...globalConfigDefaults, ...legacyConfig }
const configStore = new Configstore(null, defaults, { configPath })
Expand Down
4 changes: 2 additions & 2 deletions src/utils/get-global-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const tmpConfigBackupPath = path.join(os.tmpdir(), `netlify-config-backup-${Date
test.before('backup current user config if exists', async () => {
try {
await copyFileAsync(configPath, tmpConfigBackupPath)
} catch (_) {}
} catch {}
})

test.after.always('cleanup tmp directory and legacy config', async () => {
Expand All @@ -32,7 +32,7 @@ test.after.always('cleanup tmp directory and legacy config', async () => {
await copyFileAsync(tmpConfigBackupPath, configPath)
// Remove tmp backup if exists
await rmFileAsync(tmpConfigBackupPath)
} catch (_) {}
} catch {}
// Remove legacy config path
await rmdirRecursiveAsync(getLegacyPathInHome([]))
})
Expand Down
2 changes: 1 addition & 1 deletion src/utils/init/config-github.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const hookExists = async ({ deployHook, octokit, repoOwner, repoName }) => {
})
const exists = hooks.some((hook) => hook.config.url === deployHook)
return exists
} catch (_) {
} catch {
// we don't need to fail if listHooks errors out
return false
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/lm/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ const cleanupShell = async function () {
}

await removeConfig(configFile, getInitContent(incFilePath))
} catch (_) {}
} catch {}
}

const uninstall = async function () {
Expand Down
8 changes: 4 additions & 4 deletions tests/serving-functions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ testMatrix.forEach(({ args }) => {
const response = await got(`http://localhost:${port}/.netlify/functions/hello`).text()

return response === 'Hello'
} catch (_) {
} catch {
return false
}
},
Expand Down Expand Up @@ -429,7 +429,7 @@ export { handler }
const response = await got(`http://localhost:${port}/.netlify/functions/hello`).text()

return response === 'Modern Web Development on the Jamstack'
} catch (_) {
} catch {
return false
}
},
Expand Down Expand Up @@ -539,7 +539,7 @@ export { handler }
const response = await got(`http://localhost:${port}/.netlify/functions/hello`).text()

return response === 'Internal updated'
} catch (_) {
} catch {
return false
}
},
Expand Down Expand Up @@ -613,7 +613,7 @@ export { handler }
const response = await got(`http://localhost:${port}/.netlify/functions/hello`).text()

return response === 'User updated'
} catch (_) {
} catch {
return false
}
},
Expand Down

1 comment on commit 23af91f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 352 MB

Please sign in to comment.