Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@socketregistry/is-interactive": "1.0.5",
"@socketregistry/packageurl-js": "1.0.6",
"@socketsecurity/config": "2.1.3",
"@socketsecurity/registry": "1.0.183",
"@socketsecurity/registry": "1.0.184",
"@socketsecurity/sdk": "1.4.36",
"@types/blessed": "0.1.25",
"@types/cmd-shim": "5.0.2",
Expand Down
16 changes: 13 additions & 3 deletions src/commands/fix/npm-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,14 @@ export async function npmFix(
const sortedInfoEntries = [...infoByPkgName.entries()].sort((a, b) =>
naturalCompare(a[0], b[0])
)
infoEntriesLoop: for (const { 0: name, 1: infos } of sortedInfoEntries) {
infoEntriesLoop: for (
let i = 0, { length } = sortedInfoEntries;
i < length;
i += 1
) {
Comment on lines +141 to +144
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider separating the variable declarations for better readability. The current statement let i = 0, { length } = sortedInfoEntries; combines multiple declarations in a single line. Following standard practice, each variable should be declared separately:

let i = 0;
const { length } = sortedInfoEntries;

This makes the code more maintainable and follows common JavaScript style guidelines.

Suggested change
let i = 0, { length } = sortedInfoEntries;
i < length;
i += 1
) {
let i = 0, { length } = sortedInfoEntries;
i < length;
i += 1
) {

Spotted by Diamond (based on custom rules)

Is this helpful? React 👍 or 👎 to let us know.

const { 0: name, 1: infos } = sortedInfoEntries[i]!
const isLastInfoEntry = i === length - 1

logger.log(`Processing vulnerable package: ${name}`)
logger.indent()
spinner?.indent()
Expand Down Expand Up @@ -166,6 +173,7 @@ export async function npmFix(
: path.relative(rootPath, pkgPath)

logger.log(`Checking workspace: ${workspaceName}`)
const workspaceLogCallCount = logger.logCallCount

// eslint-disable-next-line no-await-in-loop
actualTree = await install(arb, { cwd })
Expand Down Expand Up @@ -389,13 +397,15 @@ export async function npmFix(
}
}
}
logger.log('')
if (logger.logCallCount > workspaceLogCallCount) {
logger.log('')
}
}

for (const warningText of warningsForAfter) {
logger.warn(warningText)
}
if (warningsForAfter.size) {
if (!isLastInfoEntry) {
logger.log('')
}

Expand Down
16 changes: 13 additions & 3 deletions src/commands/fix/pnpm-fix.mts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,14 @@ export async function pnpmFix(
const sortedInfoEntries = [...infoByPkgName.entries()].sort((a, b) =>
naturalCompare(a[0], b[0])
)
infoEntriesLoop: for (const { 0: name, 1: infos } of sortedInfoEntries) {
infoEntriesLoop: for (
let i = 0, { length } = sortedInfoEntries;
i < length;
i += 1
) {
const { 0: name, 1: infos } = sortedInfoEntries[i]!
const isLastInfoEntry = i === length - 1

logger.log(`Processing vulnerable package: ${name}`)
logger.indent()
spinner?.indent()
Expand Down Expand Up @@ -226,6 +233,7 @@ export async function pnpmFix(
: path.relative(rootPath, pkgPath)

logger.log(`Checking workspace: ${workspaceName}`)
const workspaceLogCallCount = logger.logCallCount

// eslint-disable-next-line no-await-in-loop
actualTree = await install(pkgEnvDetails, { cwd, spinner })
Expand Down Expand Up @@ -488,13 +496,15 @@ export async function pnpmFix(
}
}
}
logger.log('')
if (logger.logCallCount > workspaceLogCallCount) {
logger.log('')
}
}

for (const warningText of warningsForAfter) {
logger.warn(warningText)
}
if (warningsForAfter.size) {
if (!isLastInfoEntry) {
logger.log('')
}

Expand Down