Conversation
- Move lazy require() of error_helpers.cjs to top-level import - Simplify toSnakeCase() using Object.fromEntries + flatMap (avoids duplicate entries for already-snake_case keys) - Add comprehensive test file messages_core.test.cjs with 17 tests covering renderTemplate, toSnakeCase, and getMessages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
🤖 Contribution Check — Nice work on this cleanup! The Checklist summary:
Verdict: 🟢 Aligned — this PR looks ready for maintainer review!
|
There was a problem hiding this comment.
Pull request overview
Cleans up messages_core.cjs by hoisting a lazy require() to the module top level and simplifying toSnakeCase() using Object.fromEntries/flatMap, while also fixing a subtle duplicate-entry bug for already-snake_case keys. A comprehensive test suite is added.
Changes:
- Moved
require("./error_helpers.cjs")from insidegetMessages()to the top of the module. - Rewrote
toSnakeCase()as a functional one-liner that avoids duplicate entries for keys already in snake_case. - Added 17 new tests covering
renderTemplate,toSnakeCase, andgetMessages.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
actions/setup/js/messages_core.cjs |
Hoisted import; simplified toSnakeCase(); updated JSDoc comments. |
actions/setup/js/messages_core.test.cjs |
New test suite covering all three exported functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Summary
Cleaned
actions/setup/js/messages_core.cjsand added a comprehensive test suite.Context type: github-script (uses
coreglobal)Changes
messages_core.cjsMoved lazy
require()to top-level import —error_helpers.cjswas required insidegetMessages()on every call. There's no circular dependency, so it belongs at the module top level like all other imports.Simplified
toSnakeCase()withObject.fromEntries+flatMap— replaced the imperativeforloop + two assignments with a functional one-liner. The new version also avoids duplicate entries when a key is already in snake_case (e.g.run_urlpreviously got assigned twice):messages_core.test.cjs(new file)Added 17 tests covering all three exported functions:
renderTemplatetoSnakeCasegetMessagesValidation ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npm run test:js✓ (all 17 new tests pass; existing failures are pre-existing environment issues unrelated to this change)Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.