Skip to content

Commit d401472

Browse files
authored
docs: enhance JSDoc standards and document package structure (#7182)
CONTRIBUTING.md - Add guideline to never use 'any' type in JSDoc annotations AGENTS.md - Add package structure section explaining src/test directory layout - Add guideline to never use 'any' type in JSDoc annotations - Remove redundant Node.js core module prefix bullet point
1 parent 2681a5e commit d401472

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

AGENTS.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ dd-trace is the Datadog client library for Node.js.
2424
- `integration-tests/` - E2E integration tests
2525
- `benchmark/` - Performance benchmarks
2626

27+
**Package Structure:**
28+
29+
Each package follows a consistent structure:
30+
- `src/` - Source code for the package
31+
- `test/` - Unit tests for the package
32+
- Unit test files always follow the `*.spec.js` naming convention
33+
- Test directories may also contain helper files (e.g., `naming.js`, `helpers.js`, `suite.js`) and integration test subdirectories
34+
2735
## Testing Instructions
2836

2937
### Testing Workflow
@@ -113,7 +121,10 @@ assertObjectContains(response, { status: 200, body: { user: { name: 'Alice' } }
113121
### Linting & Naming
114122
- Lint: `yarn lint` / `yarn lint:fix`
115123
- Files: kebab-case
116-
- JSDoc: TypeScript-compatible syntax (`@param {string}`, `@returns {Promise<void>}`, `@typedef`)
124+
125+
### JSDoc
126+
- Use TypeScript-compatible syntax (`@param {string}`, `@returns {Promise<void>}`, `@typedef`)
127+
- Never use `any` (be specific or use `unknown` if type is truly unknown)
117128

118129
### Import Ordering
119130

@@ -143,7 +154,6 @@ const log = require('../log')
143154
const { NODE_MAJOR } = require('./version')
144155
if (NODE_MAJOR >= 20) { /* Use Node.js 20+ API */ }
145156
```
146-
- **Prefix Node.js core modules with `node:`** (e.g., `require('node:assert')`)
147157

148158
### Performance and Memory
149159

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ DD_TRACE_DEBUG=true node your-app.js
240240
DD_TRACE_DEBUG=true yarn test:debugger
241241
```
242242

243-
### Documentation
243+
### JSDoc
244244

245245
Document all APIs with TypeScript-compatible JSDoc to ensure proper types without using TypeScript. This enables type checking and IDE autocompletion while maintaining the JavaScript codebase. Use TypeScript type syntax in JSDoc annotations (e.g., `@param {string}`, `@returns {Promise<void>}`).
246246

247+
Never use the type `any` - be specific.
248+
247249
## Adding New Configuration Options
248250

249251
To add a new configuration option:

0 commit comments

Comments
 (0)