From 8a9c3a08db4fc0989d7e63f9b3b8d01da22af0f4 Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Thu, 21 Dec 2023 17:24:49 +0100 Subject: [PATCH] refactor: remove outdated comments Mostly - Commented out code - Eslint commands that don't do anything - Type descriptions which are now handled through TS --- src/cmd-add.ts | 1 - src/cmd-search.ts | 5 ----- src/registry-client.ts | 22 ++++------------------ src/utils/env.ts | 2 -- 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/cmd-add.ts b/src/cmd-add.ts index 98abf0a2..098b3441 100644 --- a/src/cmd-add.ts +++ b/src/cmd-add.ts @@ -77,7 +77,6 @@ export const add = async function ( } // verify version const versions = Object.keys(pkgInfo.versions) as SemanticVersion[]; - // eslint-disable-next-line require-atomic-updates if (!version || version === "latest") version = tryGetLatestVersion(pkgInfo); if (versions.filter((x) => x === version).length <= 0) { diff --git a/src/cmd-search.ts b/src/cmd-search.ts index 8dbc2a84..003b7bbc 100644 --- a/src/cmd-search.ts +++ b/src/cmd-search.ts @@ -134,11 +134,6 @@ export async function search( results = (await searchOld(env.registry, keyword)) || []; } // search upstream - // if (env.upstream) { - // const upstreamResults = - // (await searchEndpoint(keyword, env.upstreamRegistry)) || []; - // results.push(...upstreamResults); - // } if (results && results.length) { results.forEach((x) => table.push(x.slice(0, -1))); console.log(table.toString()); diff --git a/src/registry-client.ts b/src/registry-client.ts index f1bf8396..65040465 100644 --- a/src/registry-client.ts +++ b/src/registry-client.ts @@ -121,22 +121,12 @@ export const fetchPackageInfo = async function ( const client = getNpmClient(); try { return await client.get(pkgPath, { auth: registry.auth || undefined }); - // eslint-disable-next-line no-empty - } catch (err) {} + } catch (err) { + /* empty */ + } }; -/* Fetch package [valid dependencies, invalid dependencies] with a structure of - [ - { - name, - version, - upstream, // whether belongs to upstream registry - self, // whether is the source package - internal, // whether is an internal package - reason // invalid reason of "version404", "package404" - }, ... - ] - */ +// Fetch package dependencies export const fetchPackageDependencies = async function ( registry: Registry, upstreamRegistry: Registry, @@ -221,7 +211,6 @@ export const fetchPackageDependencies = async function ( if (!entry.version || entry.version == "latest") { const latestVersion = tryGetLatestVersion(pkgInfo); assert(latestVersion !== undefined); - // eslint-disable-next-line require-atomic-updates depObj.version = entry.version = latestVersion; } // handle version not exist @@ -234,9 +223,6 @@ export const fetchPackageDependencies = async function ( )} is not a valid choice of ${versions.reverse().join(", ")}` ); depObj.reason = "version404"; - // eslint-disable-next-line require-atomic-updates - // depObj.version = entry.version = getLatestVersion(pkgInfo); - // log.warn("notarget", `fallback to ${entry.name}@${entry.version}`); depsInvalid.push(depObj); continue; } diff --git a/src/utils/env.ts b/src/utils/env.ts index 2934d49e..4827d5d7 100644 --- a/src/utils/env.ts +++ b/src/utils/env.ts @@ -127,8 +127,6 @@ export const parseEnv = async function ( env.registry.auth = tryGetAuthForRegistry(env.registry.url); env.upstreamRegistry.auth = tryGetAuthForRegistry(env.upstreamRegistry.url); } - // log.verbose("env.npmAuth", env.npmAuth); - // log.verbose("env.auth", env.auth); // return if no need to check path if (!checkPath) return env; // cwd