Skip to content

Commit

Permalink
refactor: remove useless parameters from the catch statement (#8583)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Sep 29, 2024
1 parent b7fb704 commit 9797a1e
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion completion/plugin-commands-completion/src/complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export async function complete (
} else if (ctx.completionByCommandName[input.cmd]) {
try {
completions = await ctx.completionByCommandName[input.cmd](input.options, input.params)
} catch (err) {
} catch {
// Ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion config/config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export async function getConfig (opts: {
if (node.toUpperCase() !== process.execPath.toUpperCase()) {
process.execPath = node
}
} catch (err) { } // eslint-disable-line:no-empty
} catch { } // eslint-disable-line:no-empty

if (cliOptions.dir) {
cliOptions.dir = await realpathMissing(cliOptions.dir)
Expand Down
4 changes: 1 addition & 3 deletions config/config/src/readLocalConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export async function readLocalConfig (prefix: string): Promise<LocalConfig> {
if (typeof val === 'string') {
try {
config[envReplace(key, process.env)] = envReplace(val, process.env)
} catch (err) {
// ignore
}
} catch {}
}
}
return config
Expand Down
2 changes: 1 addition & 1 deletion env/plugin-commands-env/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export async function getNodeExecPathAndTargetDir (pnpmHomeDir: string): Promise
let nodeCurrentDir: string | undefined
try {
nodeCurrentDir = await fs.readlink(nodeCurrentDirLink)
} catch (err) {
} catch {
nodeCurrentDir = undefined
}
return { nodePath, nodeLink: nodeCurrentDir ? getNodeExecPathInNodeDir(nodeCurrentDir) : undefined }
Expand Down
2 changes: 1 addition & 1 deletion exec/plugin-commands-script-runners/src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ async function createExecCommandNotFoundHint (
let nearestScript: string | null | undefined
try {
nearestScript = getNearestScript(programName, (await readProjectManifestOnly(opts.dir)).scripts)
} catch (_err) {}
} catch {}
if (nearestScript) {
return `Did you mean "pnpm ${nearestScript}"?`
}
Expand Down
2 changes: 1 addition & 1 deletion fetching/git-fetcher/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function shouldUseShallow (repoUrl: string, allowedHosts: Set<string>): boolean
if (allowedHosts.has(host)) {
return true
}
} catch (e) {
} catch {
// URL might be malformed
}
return false
Expand Down
2 changes: 1 addition & 1 deletion pkg-manager/core/test/install/hoist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ test('should remove aliased hoisted dependencies', async () => {
try {
await resolveLinkTarget('./node_modules/dep')
throw new Error('should have failed')
} catch (e) {}
} catch {}

const modules = project.readModulesManifest()
expect(modules).toBeTruthy()
Expand Down
2 changes: 1 addition & 1 deletion pkg-manager/hoist/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ async function symlinkHoistedDependency (
let existingSymlink!: string
try {
existingSymlink = await resolveLinkTarget(dest)
} catch (err) {
} catch {
hoistLogger.debug({
skipped: dest,
reason: 'a directory is present at the target location',
Expand Down
2 changes: 1 addition & 1 deletion pkg-manager/package-requester/src/equalOrSemverEqual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export function equalOrSemverEqual (version1: string, version2: string): boolean
if (version1 === version2) return true
try {
return semver.eq(version1, version2, { loose: true })
} catch (err) {
} catch {
return false
}
}
2 changes: 1 addition & 1 deletion pnpm/artifacts/exe/scripts/build-artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function build (target: string) {
}
try {
fs.unlinkSync(artifactFile)
} catch (err) {}
} catch {}
execa.sync('pkg', ['../../dist/pnpm.cjs', `--config=../../package-${target}.json`], {
cwd: path.join(__dirname, '..'),
stdio: 'inherit',
Expand Down
2 changes: 1 addition & 1 deletion pnpm/src/checkForUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function checkForUpdates (config: Config): Promise<void> {
let state: State | undefined
try {
state = await loadJsonFile(stateFile)
} catch (err) {}
} catch {}

if (
state?.lastUpdateCheck &&
Expand Down
4 changes: 2 additions & 2 deletions pnpm/src/errorHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ async function killProcesses (status: number): Promise<void> {
for (const pid of descendentProcesses) {
try {
process.kill(pid)
} catch (err) {
} catch {
// ignore error here
}
}
} catch (err) {
} catch {
// ignore error here
}
process.exit(status)
Expand Down
2 changes: 1 addition & 1 deletion pnpm/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export async function main (inputArgv: string[]): Promise<void> {
Target location: ${config.bin}
`)
}
} catch (err) {
} catch {
// if pnpm not found, then ignore
}
}
Expand Down
6 changes: 3 additions & 3 deletions resolving/git-resolver/src/parsePref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function fromHostedGit (hosted: any): Promise<HostedPackageSpec> { // esli
if (response.ok) {
fetchSpec = httpsUrl
}
} catch (e) {
} catch {
// ignore
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ async function isRepoPublic (httpsUrl: string): Promise<boolean> {
try {
const response = await fetch(httpsUrl.replace(/\.git$/, ''), { method: 'HEAD', follow: 0, retry: { retries: 0 } })
return response.ok
} catch (_err) {
} catch {
return false
}
}
Expand All @@ -139,7 +139,7 @@ async function accessRepository (repository: string): Promise<boolean> {
try {
await git(['ls-remote', '--exit-code', repository, 'HEAD'], { retries: 0 })
return true
} catch (err: any) { // eslint-disable-line
} catch { // eslint-disable-line
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion store/server/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ test('disable server upload', async () => {
sideEffectsCacheKey: fakeEngine,
filesIndexFile,
})
} catch (e) {
} catch {
thrown = true
}
expect(thrown).toBeTruthy()
Expand Down
6 changes: 3 additions & 3 deletions store/store-path/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function storePathRelativeToHome (pkgRoot: string, relStore: string, homed
return storeInHomeDir
}
return path.join(mountpoint, '.pnpm-store', STORE_VERSION)
} catch (err) {
} catch {
// this is an unlikely situation but if there is no way to find
// a linkable place on the disk, create the store in homedir
return storeInHomeDir
Expand All @@ -83,7 +83,7 @@ async function canLinkToSubdir (fileToLink: string, dir: string): Promise<boolea
try {
await fs.mkdir(tmpDir, { recursive: true })
result = await canLink(fileToLink, pathTemp(tmpDir))
} catch (err) {
} catch {
result = false
} finally {
await safeRmdir(tmpDir)
Expand All @@ -97,7 +97,7 @@ async function safeRmdir (dir: string): Promise<void> {
// sometimes might not remove the temporary file in time
// and fs.rmdir can only remove an empty directory.
await rimraf(dir)
} catch (err) {
} catch {
// ignore
}
}
Expand Down
2 changes: 1 addition & 1 deletion workspace/find-workspace-dir/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function isFileSystemCaseSensitive () {
try {
fs.realpathSync.native(process.cwd().toUpperCase())
return false
} catch (_) {
} catch {
return true
}
}
Expand Down

0 comments on commit 9797a1e

Please sign in to comment.