Skip to content

refactor(npm): drop void operator from type checks - #1382

Merged
BryanFRD merged 1 commit into
mainfrom
fix/sonar-quick-wins
Nov 9, 2026
Merged

BryanFRD merged 1 commit into
mainfrom
fix/sonar-quick-wins

Conversation

@BryanFRD

@BryanFRD BryanFRD commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Sonar quick win: typescript:S3735 (two occurrences in npm/types-check.ts). The hook bodies now read the context field through console.log; the npm types check still passes.

Skipped:

  • docker:S8431 (Dockerfile tag plus digest): the pin is deliberate, the digest gives reproducible builds and the tag keeps Renovate updates readable.

False positive:

  • javascript:S4036 (scripts/embed-release-data.js): execFileSync resolves gh through PATH in a release script that only runs in CI on a runner with a controlled PATH.

Signed-off-by: BryanFRD <bryanferrando59@gmail.com>
@BryanFRD
BryanFRD enabled auto-merge (squash) November 9, 2026 15:36

@ferrfleet-interne ferrfleet-interne Bot left a comment

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.

Approve. The change replaces void expr with console.log(expr) in the type fixture npm/types-check.ts, and both checks stay meaningful.

Review

  • console resolves through the default DOM lib used by the CI tsc call, and the hook still returns void, so it fits HookFunction.
  • ctx.nope is still an unknown-property error, so the @ts-expect-error directive remains satisfied.
  • tsc was not run locally (npx is unavailable in the runner), so this rests on reading the types.

Suggestions

  • npm/types-check.ts:3 (suggestion): console.log(ctx.newVersion) only checks that the property exists, and Sonar may flag console usage in turn. A typed binding pins newVersion to string and makes the positive check stronger:
    postTag: (ctx) => { const version: string = ctx.newVersion; console.log(version); }

Formal verification

Property Result
none applicable nothing to prove

The only changed file is a compile-time type fixture with no runtime logic, so no harnesses were written. By reading only (no TypeScript compiler in the image), console.log returns void, which fits HookFunction = (ctx: HookContext) => void | Promise<void> (npm/types/hook-context.d.ts:38).

@BryanFRD
BryanFRD merged commit 92d9df8 into main Nov 9, 2026
32 checks passed
@BryanFRD
BryanFRD deleted the fix/sonar-quick-wins branch November 9, 2026 16:08
ferrflow Bot added a commit that referenced this pull request Nov 9, 2026
## [7.35.6] - 2026-11-09

### Refactoring

- refactor(npm): drop void operator from type checks (#1382)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant