Skip to content

Add no-sync-fs rule#44

Merged
arnavsurve merged 3 commits intomainfrom
no-sync-fs
Feb 25, 2026
Merged

Add no-sync-fs rule#44
arnavsurve merged 3 commits intomainfrom
no-sync-fs

Conversation

@create-inc-service-account
Copy link
Contributor

Summary

  • Flags synchronous fs methods (readFileSync, writeFileSync, existsSync, etc.) and suggests fs.promises or fs/promises instead
  • Detects both fs.xSync() member calls and destructured imports from 'fs'/'node:fs'
  • Uses endsWith('Sync') instead of a hardcoded method list — future-proof against new Node.js fs additions
  • Tagged as backend platform only
  • Codifies the code style preference from our escher CLAUDE.md: "Always use fs.promises.* instead of sync variants"

Test plan

Scenario Expected
npm test All 350 tests pass (14 new for this rule)
fs.readFileSync(...) Flagged with suggestion to use fs.promises.readFile
import { writeFileSync } from 'fs' then writeFileSync(...) Flagged
import fs from 'node:fs' then fs.existsSync(...) Flagged
await fs.promises.readFile(...) Allowed
import { readFile } from 'fs/promises' Allowed
someObj.readFileSync(...) Allowed (not an fs import)

🤖 Generated with Claude Code

arnavsurve and others added 3 commits February 24, 2026 20:37
Flag synchronous fs methods (readFileSync, writeFileSync, etc.) and
suggest using fs.promises or fs/promises instead. Detects both
fs.xSync() member calls and destructured imports from 'fs'/'node:fs'.
Scoped to backend platform.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@arnavsurve arnavsurve force-pushed the no-sync-fs branch 2 times, most recently from 29ea132 to cf7a4d8 Compare February 25, 2026 04:38
@arnavsurve arnavsurve merged commit 766ae00 into main Feb 25, 2026
7 checks passed
@arnavsurve arnavsurve deleted the no-sync-fs branch February 25, 2026 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants