feat: add codemod for DEP0162 fs write coercion#416
Open
syhstanley wants to merge 5 commits intonodejs:mainfrom
Open
feat: add codemod for DEP0162 fs write coercion#416syhstanley wants to merge 5 commits intonodejs:mainfrom
syhstanley wants to merge 5 commits intonodejs:mainfrom
Conversation
Add explicit String() conversion for objects passed as the data parameter to fs.writeFile(), fs.writeFileSync(), fs.appendFile(), fs.appendFileSync(), fs.write(), and their promises variants. Closes nodejs#412 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add missing README.md (required per CONTRIBUTING.md) - Add yaml-language-server schema comment to workflow.yaml - Sort include file patterns alphabetically - Fix isSafeType: remove dead template literal check, tighten String() match - Add isLikelyBufferOverload guard for fs.write() buffer overload - Support float numeric literals in isSafeType - Normalize test file naming (file-02 → file-2) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Member
AugustinMauroy
left a comment
There was a problem hiding this comment.
not too bad but:
for you info you have to use this structure of testing
Codemod leverages a before ("input") + after ("expected") snapshot comparison. Codemod supports 2 options:
- 👍 Single-file fixtures
tests/ some-test-case-description/ input.ts expected.ts another-test-case-description/ input.ts expected.ts - 👎 Directory snapshot fixtures
tests/ input/ some-test-case-description.ts another-test-case-description.ts expected some-test-case-description.ts another-test-case-description.ts
Use the Single-file fixtures option.
- Migrate tests to single-file fixture structure (input.ts + expected.ts per case) - Use getModuleDependencies utility instead of separate import/require helpers - Remove unnecessary escapeRegex() wrapper for identifier matching Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
|
Thanks for your review! Please check the new commits. |
Change test fixture path from ./ to ./tests to match single-file fixture structure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a codemod for DEP0162 — implicit coercion of objects in
fs.write()andfs.writeFileSync().String()forfs.writeFile(),fs.writeFileSync(),fs.appendFile(),fs.appendFileSync(),fs.write(), and theirfs/promisesvariantsBuffer.from(),new Uint8Array(),.toString(),String()wrappersrequire('fs')and ESMimport { writeFile } from 'node:fs/promises'Test plan
fs.write()andfs.writeFileSync()coercion to string #412npx codemod jssg testCloses #412
🤖 Generated with Claude Code