Skip to content

Commit 4c88c21

Browse files
author
Eric Wheeler
committed
docs: add rules for using safeWriteJson
Add concise rules for using safeWriteJson instead of JSON.stringify with file operations to ensure atomic writes and prevent data corruption. Signed-off-by: Eric Wheeler <[email protected]>
1 parent 26440d9 commit 4c88c21

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# JSON File Writing Must Be Atomic
2+
3+
- MUST ALWAYS use `safeWriteJson(filePath: string, data: any): Promise<void>` from `src/utils/safeWriteJson.ts` instead of `JSON.stringify` with file-write operations
4+
- `safeWriteJson` prevents data corruption via atomic writes with locking and streams the write to minimize memory footprint
5+
- Test files are exempt from this rule

0 commit comments

Comments
 (0)