Skip to content

Commit d1bbbba

Browse files
committed
Add GitHub utilities and update scripts
1 parent dc181fb commit d1bbbba

8 files changed

Lines changed: 687 additions & 193 deletions

File tree

CLAUDE.md

Lines changed: 21 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,8 @@ When working in any Socket repository, check for updates and patterns in other c
2323

2424
### Cross-Project Learning
2525
- When discovering generally applicable patterns or guidelines, update CLAUDE.md files in other socket- projects
26-
- Examples: c8 comment formatting, error handling patterns, code style rules, test organization patterns, workflow patterns
2726
- This ensures consistency across the Socket ecosystem
2827

29-
### Recent Learnings Applied
30-
- **Test Organization**: Modular test files improve maintainability across all projects
31-
- **Error Message Consistency**: Use consistent error message patterns across all Socket projects
32-
- **Safe File Removal**: Use safeRemove utility consistently across projects for CI optimization
33-
- **Cross-Platform Support**: Enhanced cross-platform compatibility measures
34-
- **TypeScript Strict Mode**: All projects should use strict TypeScript configuration
35-
- **Import Organization**: Separate type imports from runtime imports for better tree-shaking
36-
3728
## 🎯 Your Role
3829
You are a **Principal Software Engineer** responsible for:
3930
- Writing production-quality, maintainable code
@@ -232,45 +223,7 @@ Use these standardized patterns for consistency across all Socket projects:
232223
- **fs imports**: Use pattern `import { syncMethod, promises as fs } from 'node:fs'`
233224

234225
#### Import Statement Sorting
235-
- **🚨 MANDATORY**: Sort imports in this exact order with blank lines between groups (enforced by ESLint import-x/order):
236-
1. Node.js built-in modules (with `node:` prefix) - sorted alphabetically
237-
2. External third-party packages - sorted alphabetically
238-
3. Internal Socket packages (`@socketsecurity/*`) - sorted alphabetically
239-
4. Local/relative imports (parent, sibling, index) - sorted alphabetically
240-
5. **Type imports LAST as separate group** - sorted alphabetically (all `import type` statements together at the end)
241-
- **Within each group**: Sort alphabetically by module name
242-
- **Named imports**: Sort named imports alphabetically within the import statement (enforced by sort-imports)
243-
- **Type import placement**: Type imports must come LAST, after all runtime imports, as a separate group with blank line before
244-
- **Examples**:
245-
- ✅ CORRECT:
246-
```typescript
247-
import { readFile } from 'node:fs'
248-
import path from 'node:path'
249-
import { promisify } from 'node:util'
250-
251-
import axios from 'axios'
252-
import semver from 'semver'
253-
254-
import { readPackageJson } from '@socketsecurity/registry/lib/packages'
255-
import { spawn } from '@socketsecurity/registry/lib/spawn'
256-
257-
import { API_BASE_URL } from './constants'
258-
import { formatError, parseResponse } from './utils'
259-
260-
import type { ClientRequest, IncomingMessage } from 'node:http'
261-
import type { PackageJson } from '@socketsecurity/registry/lib/packages'
262-
import type { Config } from './types'
263-
```
264-
-WRONG:
265-
```typescript
266-
import { formatError, parseResponse } from './utils'
267-
import axios from 'axios'
268-
import type { Config } from './types'
269-
import { readFile } from 'node:fs'
270-
import { spawn } from '@socketsecurity/registry/lib/spawn'
271-
import semver from 'semver'
272-
import type { PackageJson } from '@socketsecurity/registry/lib/packages'
273-
```
226+
- **🚨 MANDATORY**: Sort imports: 1) Node.js built-ins (`node:` prefix), 2) External packages, 3) Internal Socket packages (`@socketsecurity/*`), 4) Local/relative imports, 5) Type imports LAST. Blank lines between groups. Alphabetical within groups. Enforced by ESLint import-x/order and sort-imports.
274227

275228
### 🏗️ Code Structure & Patterns
276229

@@ -461,69 +414,19 @@ Follow the [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) format:
461414
## 🔧 Git & Workflow
462415

463416
### GitHub Actions Guidelines
464-
- **🚨 MANDATORY**: All GitHub Actions MUST reference commit SHAs, not version tags
465-
- **Security requirement**: SocketDev repositories require pinned commit hashes for supply chain security
466-
- **🚨 MANDATORY**: Reusable workflows MUST be created in `socket-registry/.github/workflows/`, NOT in individual project repositories
467-
- **Workflow location**: Individual projects should reference workflows from `SocketDev/socket-registry/.github/workflows/`
468-
- **Standard action SHAs** (keep these updated across all Socket projects):
469-
- `actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8` (v5.0.0)
470-
- `pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda` (v4.1.0)
471-
- `actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444` (v5.0.0)
472-
- `actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874` (v4.4.0)
473-
- **Format**: Always include version comment: `uses: owner/repo@sha # vX.Y.Z`
474-
- **Examples**:
475-
- ✅ CORRECT: `uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0`
476-
- ✅ CORRECT: `uses: SocketDev/socket-registry/.github/workflows/test.yml@main`
477-
- ❌ FORBIDDEN: `uses: actions/checkout@v4` or `uses: actions/checkout@v5`
478-
- ❌ FORBIDDEN: `uses: ./.github/workflows/_reusable-test.yml` (reusable workflows belong in socket-registry)
479-
- **Allowed actions**: Either SocketDev-owned or pinned by SHA from trusted sources
480-
- **Cross-project consistency**: Maintain identical SHAs across all Socket projects
417+
- **🚨 MANDATORY**: All actions MUST reference commit SHAs, not tags. Format: `uses: owner/repo@sha # vX.Y.Z`
418+
- **Reusable workflows**: Create in `socket-registry/.github/workflows/`, reference from other projects
419+
- **Standard SHAs**: `actions/checkout@08c6903...5dd907a8` (v5.0.0), `pnpm/action-setup@a7487c7...0d66ddda` (v4.1.0), `actions/setup-node@a0853c24...8a591444` (v5.0.0), `actions/upload-artifact@50769540...35e0d6874` (v4.4.0)
481420

482421
### CI Workflow Strategy
483-
- **🚨 MANDATORY**: Use the centralized `ci.yml` reusable workflow from socket-registry
484-
- **Workflow location**: `SocketDev/socket-registry/.github/workflows/ci.yml@main`
485-
- **Benefits**: Consistent CI strategy across all Socket projects, parallel execution of lint/type-check/test/coverage
486-
- **Configuration**: Customize via workflow inputs (scripts, node versions, OS versions, timeouts, etc.)
487-
- **Standard configuration pattern**:
488-
```yaml
489-
jobs:
490-
ci:
491-
name: Run CI Pipeline
492-
uses: SocketDev/socket-registry/.github/workflows/ci.yml@main
493-
with:
494-
coverage-script: 'pnpm run test:unit:coverage'
495-
coverage-report-script: 'pnpm run coverage:percent --json'
496-
fail-fast: false
497-
lint-script: 'pnpm run lint-ci'
498-
node-versions: '[20, 22, 24]'
499-
os-versions: '["ubuntu-latest", "windows-latest"]'
500-
test-script: 'pnpm run test-ci'
501-
test-setup-script: 'pnpm run build'
502-
type-check-script: 'pnpm run type-ci'
503-
type-check-setup-script: 'pnpm run build'
504-
```
505-
- **Orchestration**: CI workflow orchestrates lint.yml, types.yml, test.yml, and coverage reporting
506-
- **Individual workflows**: Keep lint.yml, types.yml, test.yml for targeted runs; ci.yml runs all together
507-
- **Cross-project consistency**: All Socket projects should use identical CI orchestration pattern
422+
- **🚨 MANDATORY**: Use `SocketDev/socket-registry/.github/workflows/ci.yml@main`
423+
- **Benefits**: Consistent CI, parallel execution of lint/type-check/test/coverage
424+
- **Configuration**: Customize via inputs (lint-script, test-script, type-check-script, node-versions, os-versions, etc.)
508425

509426
#### CI Script Naming Convention (MANDATORY)
510-
All Socket projects MUST use these standardized script names in package.json:
511-
- **lint-ci**: Linting for CI environments
512-
- Format: `"lint-ci": "pnpm run check:lint"`
513-
- Purpose: Run linting checks without fixing, optimized for CI
514-
- **test-ci**: Testing for CI environments
515-
- Format: `"test-ci": "dotenvx -q run -f .env.test -- vitest run"`
516-
- Purpose: Run tests without watch mode, optimized for CI
517-
- MUST NOT include linting or building (handled separately)
518-
- **type-ci**: Type checking for CI environments
519-
- Format: `"type-ci": "pnpm run check:tsc"`
520-
- Purpose: Run TypeScript type checking without emitting files
521-
522-
**Why standardized names:**
523-
- Consistent CI configuration across all Socket projects
524-
- Clear separation of concerns (lint/test/type-check run independently)
525-
- Easier to maintain and update CI workflows
526-
- Reduces duplicate work (no linting in test-ci, no building twice)
427+
- **lint-ci**: `"pnpm run check:lint"` - Linting without fixing
428+
- **test-ci**: `"dotenvx -q run -f .env.test -- vitest run"` - Tests without watch mode (no linting/building)
429+
- **type-ci**: `"pnpm run check:tsc"` - Type checking without emitting files
527430

528431
## Architecture
529432

@@ -662,84 +565,19 @@ When working in any Socket repository, check CLAUDE.md files in other Socket pro
662565
### 🚨 MANDATORY Dependency Management
663566
All Socket projects MUST maintain alignment on these core dependencies. Use `taze` for version management - run `pnpm run taze` to check for and apply dependency updates.
664567

665-
#### Core Build Tools & TypeScript
666-
- **@typescript/native-preview** (tsgo - NEVER use standard tsc)
667-
- **@types/node** (latest LTS types)
668-
- **typescript-eslint** (unified package - do NOT use separate @typescript-eslint/* packages)
669-
670-
#### Essential DevDependencies
671-
- **@biomejs/biome**
672-
- **@dotenvx/dotenvx**
673-
- **@eslint/compat**
674-
- **@eslint/js**
675-
- **@vitest/coverage-v8**
676-
- **eslint**
677-
- **eslint-plugin-import-x**
678-
- **eslint-plugin-n**
679-
- **eslint-plugin-sort-destructure-keys**
680-
- **eslint-plugin-unicorn**
681-
- **globals**
682-
- **husky**
683-
- **knip**
684-
- **lint-staged**
685-
- **npm-run-all2**
686-
- **oxlint**
687-
- **taze**
688-
- **trash**
689-
- **type-coverage**
690-
- **vitest**
691-
- **yargs-parser**
692-
- **yoctocolors-cjs**
693-
694-
### 🔧 TypeScript Compiler Standardization
695-
- **🚨 MANDATORY**: ALL Socket projects MUST use `tsgo` instead of `tsc`
696-
- **Package**: `@typescript/native-preview`
697-
- **Scripts**: Replace `tsc` with `tsgo` in all package.json scripts
698-
- **Benefits**: Enhanced performance, better memory management, faster compilation
699-
700-
#### Script Examples:
701-
```json
702-
{
703-
"build": "tsgo",
704-
"check:tsc": "tsgo --noEmit",
705-
"build:types": "tsgo --project tsconfig.dts.json"
706-
}
707-
```
568+
#### Core Dependencies (MANDATORY Alignment)
569+
**Build/TypeScript**: @typescript/native-preview (tsgo), @types/node, typescript-eslint (unified only)
570+
**DevDeps**: @biomejs/biome, @dotenvx/dotenvx, @eslint/compat, @eslint/js, @vitest/coverage-v8, eslint, eslint-plugin-import-x, eslint-plugin-n, eslint-plugin-sort-destructure-keys, eslint-plugin-unicorn, globals, husky, knip, lint-staged, npm-run-all2, oxlint, taze, trash, type-coverage, vitest, yargs-parser, yoctocolors-cjs
708571

709-
### 🛠️ ESLint Configuration Standardization
710-
- **🚨 FORBIDDEN**: Do NOT use separate `@typescript-eslint/eslint-plugin` and `@typescript-eslint/parser` packages
711-
- **✅ REQUIRED**: Use unified `typescript-eslint` package only
712-
- **Migration**: Remove separate packages, add unified package
713-
714-
#### Migration Commands:
715-
```bash
716-
pnpm remove @typescript-eslint/eslint-plugin @typescript-eslint/parser
717-
pnpm add -D typescript-eslint --save-exact
718-
```
572+
### 🔧 TypeScript & ESLint Standardization
573+
- **🚨 MANDATORY**: Use `tsgo` from `@typescript/native-preview` (not `tsc`)
574+
- **🚨 FORBIDDEN**: Use unified `typescript-eslint` package only (not separate @typescript-eslint/* packages)
719575
720-
### 📋 Dependency Update Requirements
721-
When updating dependencies across Socket projects:
722-
723-
1. **Use taze first**: Run `pnpm run taze` to check for and apply dependency updates
724-
2. **Version Consistency**: All projects MUST use identical versions for shared dependencies
725-
3. **Exact Versions**: Always use `--save-exact` flag to prevent version drift
726-
4. **Batch Updates**: Update all Socket projects simultaneously to maintain alignment
727-
5. **Testing**: Run full test suites after dependency updates to ensure compatibility
728-
6. **Documentation**: Update CLAUDE.md files when standard versions change
729-
730-
### 🔄 Regular Maintenance
731-
- **Monthly Audits**: Review dependency versions across all Socket projects
732-
- **Security Updates**: Apply security patches immediately across all projects
733-
- **Major Version Updates**: Coordinate across projects, test thoroughly
734-
- **Legacy Cleanup**: Remove unused dependencies during regular maintenance
735-
736-
### 🚨 Enforcement Rules
737-
- **Pre-commit Hooks**: Configure to prevent commits with misaligned dependencies
738-
- **CI/CD Integration**: Fail builds on version mismatches
739-
- **Code Reviews**: Always verify dependency alignment in PRs
740-
- **Documentation**: Keep this section updated with current standard versions
741-
742-
This standardization ensures consistency, reduces maintenance overhead, and prevents dependency-related issues across the Socket ecosystem.
576+
### 📋 Dependency Update Protocol
577+
1. Run `pnpm run taze` to check/apply updates
578+
2. Use `--save-exact` for all dependencies (no `^` or `~`)
579+
3. Update all Socket projects simultaneously
580+
4. Test thoroughly after updates
743581
744582
## Notes
745583

perf/npm/json-stable-stringify.perf.mts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ import assert from 'node:assert/strict'
22
import path from 'node:path'
33

44
import fastJsonStableStringify from 'fast-json-stable-stringify'
5-
// eslint-disable-next-line import-x/no-duplicates
65
import origJsonStableStringify from 'json-stable-stringify'
76
import { Bench } from 'tinybench'
87

9-
// eslint-disable-next-line import-x/no-duplicates
108
import overrideJsonStableStringify from '@socketregistry/json-stable-stringify'
119
import { logger } from '@socketsecurity/registry/lib/logger'
1210

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default '.github'

0 commit comments

Comments
 (0)