Skip to content

[jsweep] Clean substitute_placeholders.cjs#19315

Merged
pelikhan merged 6 commits intomainfrom
jsweep/clean-substitute-placeholders-b7e9f3579dc8f721
Mar 3, 2026
Merged

[jsweep] Clean substitute_placeholders.cjs#19315
pelikhan merged 6 commits intomainfrom
jsweep/clean-substitute-placeholders-b7e9f3579dc8f721

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Mar 3, 2026

Cleaned actions/setup/js/substitute_placeholders.cjs as part of the jsweep unbloat initiative.

Context type: github-script (uses core.info() for logging)

Changes

substitute_placeholders.cjs

  • Added @ts-check with /// (reference types="@actions/github-script" /) for full type safety
  • Added JSDoc type annotations for the function parameters (file: string, substitutions: Record(string, string | null | undefined)) and return type (Promise(string))
  • Imported shim.cjs — ensures core is always available as a global even when running outside github-script context, replacing the typeof core !== "undefined" guard pattern
  • Removed log() helper — uses core.info() directly (guaranteed by shim), with logging reduced to a single summary line per invocation instead of 20+ verbose diagnostic lines
  • Fixed yoda condition"object" != typeof substitutionstypeof substitutions !== "object"
  • Simplified null checkvalue === undefined || value === null ? ""value == null ? "" (idiomatic JS)

substitute_placeholders.test.cjs

  • Added vitest importsimport { afterEach, beforeEach, describe, expect, it } from "vitest" (matches codebase pattern)
  • Removed comma-operator anti-pattern — rewrote all test cases as proper standalone it() calls instead of comma-chained expressions
  • Preserved all 12 test cases — same coverage, cleaner structure

Test Coverage

All 12 existing tests pass with no regressions. Tests cover:

  • Single/multiple placeholder substitution
  • Special characters handling
  • Multiple occurrences of same placeholder
  • Unmatched placeholders left unchanged
  • Empty string values
  • undefined/null values treated as empty strings
  • Mixed defined/undefined/null values
  • Error cases: missing file param, missing substitutions param, nonexistent file

Validation ✅

All checks passed:

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js -- --no-file-parallelism substitute_placeholders ✓ (12/12 passed)

Generated by jsweep - JavaScript Unbloater

  • expires on Mar 5, 2026, 3:18 AM UTC

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


[jsweep] Clean substitute_placeholders.cjs

Cleaned actions/setup/js/substitute_placeholders.cjs as part of the jsweep unbloat initiative.

Context type: github-script (uses core.info() for logging)

Changes

substitute_placeholders.cjs

  • Added @ts-check with /// (reference types="@actions/github-script" /) for full type safety
  • Added JSDoc type annotations for the function parameters (file: string, substitutions: Record(string, string | null | undefined)) and return type (Promise(string))
  • Imported shim.cjs — ensures core is always available as a global even when running outside github-script context, replacing the typeof core !== "undefined" guard pattern
  • Removed log() helper — uses core.info() directly (guaranteed by shim), with logging reduced to a single summary line per invocation instead of 20+ verbose diagnostic lines
  • Fixed yoda condition"object" != typeof substitutionstypeof substitutions !== "object"
  • Simplified null checkvalue === undefined || value === null ? ""value == null ? "" (idiomatic JS)

substitute_placeholders.test.cjs

  • Added vitest importsimport { afterEach, beforeEach, describe, expect, it } from "vitest" (matches codebase pattern)
  • Removed comma-operator anti-pattern — rewrote all test cases as proper standalone it() calls instead of comma-chained expressions
  • Preserved all 12 test cases — same coverage, cleaner structure

Test Coverage

All 12 existing tests pass with no regressions. Tests cover:

  • Single/multiple placeholder substitution
  • Special characters handling
  • Multiple occurrences of same placeholder
  • Unmatched placeholders left unchanged
  • Empty string values
  • undefined/null values treated as empty strings
  • Mixed defined/undefined/null values
  • Error cases: missing file param, missing substitutions param, nonexistent file

Validation ✅

All checks passed:

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: npm run test:js -- --no-file-parallelism substitute_placeholders ✓ (12/12 passed)

Generated by (a href="https://github.com/github/gh-aw/actions/runs/22606517038")jsweep - JavaScript Unbloater(/a)

  • expires on Mar 5, 2026, 3:18 AM UTC

✨ Let Copilot coding agent [set things up for you](https://github.com/github/gh-aw/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repo%5D(gh.io/redacted) — coding agent works faster and does higher quality work when set up for your repo.

Changeset

  • Type: patch
  • Description: Documented the substitute placeholder cleanup (ts-check, shim import, logging simplification, and test cleanup).

Generated by Changeset Generator for issue #19315

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • codeload.github.com
  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "codeload.github.com"
    - "github.com"

See Network Configuration for more information.



✨ PR Review Safe Output Test - Run 22607233572

💥 [THE END] — Illustrated by Smoke Claude

- Add @ts-check and /// <reference types="@actions/github-script" /> for type safety
- Add JSDoc type annotations for function parameters and return type
- Extract log() helper to eliminate 20+ repeated typeof core checks
- Fix yoda condition: "object" != typeof → typeof !== "object"
- Simplify null check: value === undefined || value === null → value == null
- Refactor test file: add vitest imports, remove comma-operator anti-pattern

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

pelikhan commented Mar 3, 2026

@copilot

  • import shim.cjs to ensure core
  • make logging more lightweight,

Copilot AI and others added 2 commits March 3, 2026 03:31
…rs.cjs

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor

Copilot AI commented Mar 3, 2026

@copilot

  • import shim.cjs to ensure core
  • make logging more lightweight,

Done in d43c555. Imported shim.cjs to ensure core is always available, removed the log wrapper helper, and replaced the 20+ verbose log lines with a single core.info() summary line per invocation.

@pelikhan pelikhan marked this pull request as ready for review March 3, 2026 03:41
Copilot AI review requested due to automatic review settings March 3, 2026 03:41
@pelikhan pelikhan added the smoke label Mar 3, 2026
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

🌑 The shadows whisper... Smoke Codex failed. The oracle requires further meditation...

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

🎬 THE ENDSmoke Claude MISSION: ACCOMPLISHED! The hero saves the day! ✨

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

📰 BREAKING: Smoke Copilot is now investigating this pull request. Sources say the story is developing...

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

📰 DEVELOPING STORY: Smoke Copilot reports failed. Our correspondents are investigating the incident...

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

Agent Container Tool Check

Tool Status Version
bash 5.2.21
sh available
git 2.53.0
jq 1.7
yq v4.52.4
curl 8.5.0
gh 2.87.3
node v20.20.0
python3 3.12.3
go 1.24.13
java 10.0.102
dotnet 10.0.102

Result: 12/12 tools available ✅

Overall Status: PASS

🔧 Tool validation by Agent Container Smoke Test

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Cleans up the substitute_placeholders helper and its test suite as part of the jsweep unbloat effort, improving type-safety and reducing verbose logging.

Changes:

  • Added // @ts-check + @actions/github-script type references and JSDoc typing for substitutePlaceholders.
  • Ensured core is always available by requiring shim.cjs, and reduced logging to a single summary line per invocation.
  • Refactored the test file to use standard Vitest imports and explicit it() blocks (removing the comma-operator chaining).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
actions/setup/js/substitute_placeholders.cjs Adds TS checking/JSDoc types, uses shim-provided core, and simplifies logging + null handling.
actions/setup/js/substitute_placeholders.test.cjs Refactors tests into conventional Vitest structure and adds basic JSDoc types for local variables.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

Commit pushed: d903fc3

Generated by Changeset Generator

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 3, 2026

Smoke Test Results — Run §22607233572 | Status: PARTIAL ⚠️

Core tests #1–10: ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
PR review tests #11–17: ✅ ✅ ✅ ✅ ✅ ✅ ⚠️ (17 skipped — no safe PR to close)

💥 [THE END] — Illustrated by Smoke Claude

Copy link
Contributor Author

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

💥 Automated smoke test review - all systems nominal! The cleanup of substitute_placeholders.cjs is clean and well-executed. The removal of verbose conditional core.info guards in favor of the shim.cjs approach reduces code by ~60 lines while maintaining functionality. Test structure improvements in substitute_placeholders.test.cjs are also a significant readability win.

💥 [THE END] — Illustrated by Smoke Claude

@pelikhan pelikhan merged commit 3cc524a into main Mar 3, 2026
46 checks passed
@pelikhan pelikhan deleted the jsweep/clean-substitute-placeholders-b7e9f3579dc8f721 branch March 3, 2026 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants