Skip to content

Commit 508065e

Browse files
committed
docs: add null-prototype object pattern guidelines to CLAUDE.md
1 parent 2a9f7ce commit 508065e

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ Programmatic access to Socket.dev's security analysis capabilities.
124124
- **Semicolons**: Use semicolons (unlike other Socket projects that omit them)
125125
- **Type safety**: 🚨 FORBIDDEN - Avoid `any` type; prefer `unknown` or specific types
126126
- **Type imports**: Always use `import type` for better tree-shaking
127+
- **Null-prototype objects**:
128+
- ✅ CORRECT: `{ __proto__: null, key: 'value' }` (object literal with properties)
129+
- ✅ CORRECT: `{ __proto__: null, ...options }` (spread pattern)
130+
- ✅ CORRECT: `const obj = Object.create(null)` (empty object, populate separately)
131+
- ❌ WRONG: `const obj = { __proto__: null }` (empty object literal - use `Object.create(null)` instead)
132+
- **Rationale**: Use `Object.create(null)` only for empty null-prototype objects; object literals with `__proto__: null` are fine when they have properties
127133

128134
### Comprehensive Sorting Standards (MANDATORY)
129135
All code elements MUST be sorted:

0 commit comments

Comments
 (0)