48 lines
1.5 KiB
Markdown
48 lines
1.5 KiB
Markdown
# Code Style and Conventions
|
|
|
|
## Naming Conventions
|
|
- **Interfaces**: Prefix with `I` (e.g., `IDenoRelease`, `IAsset`)
|
|
- **Types**: Prefix with `T` (not heavily used in this codebase)
|
|
- **Classes**: PascalCase (e.g., `SmartDeno`, `DenoDownloader`)
|
|
- **Files**: Lowercase, hyphenated (e.g., `classes.smartdeno.ts`, `classes.denodownloader.ts`)
|
|
- **Methods/Properties**: camelCase
|
|
|
|
## File Organization
|
|
- **Source**: `ts/` directory
|
|
- **Tests**: `test/` directory
|
|
- **Compiled Output**: `dist_ts/` (excluded from git)
|
|
- **Temporary Files**: `.nogit/` directory (excluded from git)
|
|
|
|
## File Naming Patterns
|
|
- Classes: `classes.<name>.ts` (e.g., `classes.smartdeno.ts`)
|
|
- Entry point: `index.ts`
|
|
- Plugin/dependency imports: `plugins.ts`
|
|
- Path configurations: `paths.ts`
|
|
|
|
## Import Patterns
|
|
1. **All module dependencies** imported in `ts/plugins.ts`
|
|
2. **References use full path**: `plugins.moduleName.className()`
|
|
3. **Local imports** use `.js` extension (for ESM compatibility)
|
|
|
|
Example from plugins.ts:
|
|
```typescript
|
|
import * as smartfile from '@push.rocks/smartfile';
|
|
export { smartfile };
|
|
```
|
|
|
|
Usage:
|
|
```typescript
|
|
import * as plugins from './plugins.js';
|
|
plugins.smartfile.fs.writeFile(...);
|
|
```
|
|
|
|
## Class Patterns
|
|
- Private properties for internal state
|
|
- Public async methods for API
|
|
- Dependency injection where appropriate
|
|
- JSDoc comments for public methods
|
|
|
|
## Module Resolution
|
|
- Always use `.js` extension in imports (even for `.ts` files)
|
|
- This is required for ESM compatibility with NodeNext resolution
|