feat(DEP0164): handle non-integer codes passed to process.exit & process.exitCode#413
Conversation
process.exit & process.exitCode
|
Given the mere moments between opening this PR and your #405 (comment), it's fairly clear this was fully AI-generated. Could you please confirm what you used to generate it, how much of it, and which specific pieces you reviewed of the generated code. |
|
Thanks for calling this out, yes, I used AI assistance (GitHub Copilot Chat in VS Code) to speed up drafting. What was AI-assisted: What I manually reviewed and adjusted: You are right that I should have disclosed this in the PR description from the start. |
|
aslo for you info you have to use this structure of testing Codemod leverages a
Use the Single-file fixtures option. |
|
AugustinMauroy
left a comment
There was a problem hiding this comment.
Better but still something to improve
| return /^-?\d+$/.test(value); | ||
| } | ||
|
|
||
| function getStringLiteralValue(node: SgNode<JS>): string | null { |
There was a problem hiding this comment.
kind "string_fragment" exist so when you have node you can find() with rule that catch kind string_fragment
|
|
||
| if (kind === 'object') return coerceFromObjectLiteral(node, mode); | ||
|
|
||
| if (node.kind() === 'identifier') { |
There was a problem hiding this comment.
here var naming is complex it's difficult to make diff between node.kind and kind from inferIdentifierKind
| const processDependencies = [ | ||
| ...getNodeImportStatements(root, 'process'), | ||
| ...getNodeRequireCalls(root, 'process'), | ||
| ]; |
| const exitBindings = new Set<string>(['process.exit']); | ||
| const exitCodeBindings = new Set<string>(['process.exitCode']); | ||
|
|
||
| const processDependencies = [ |
There was a problem hiding this comment.
we have an utility for that read utils/readme to know which one you should use
| } | ||
|
|
||
| if (!edits.length) return null; | ||
| return rootNode.commitEdits(edits); |
There was a problem hiding this comment.
| return rootNode.commitEdits(edits); | |
| return rootNode.commitEdits(edits); |
Summary
This PR adds a new codemod recipe to handle DEP0164 by coercing unsupported values passed to process.exit(code) and assigned to process.exitCode into integer-compatible values.
Closes #405.
What this adds
Transformation behavior
The codemod applies explicit and safe coercions aligned with the issue requirements:
Safety and scope
Tests
Added fixture coverage for the 10 scenarios from the issue plus additional edge cases:
Validation run: