Documentation
Shared Deno Configuration
This repository uses a centralized Deno configuration pattern to ensure consistency across all Deno-based projects.
Overview
Similar to how .NET projects use Directory.Build.props and Rust projects use a workspace Cargo.toml, all Deno projects in this repository extend a shared base configuration file.
Configuration Files
Base Configuration: deno.base.json
Located at the repository root (/deno.base.json), this file contains shared settings that apply to all Deno projects:
- Compiler Options: Strict TypeScript settings with DOM and Deno APIs
- Formatting Rules: Consistent code formatting (2-space indents, 100-char line width, single quotes)
- Linting Rules: Recommended rules enabled by default
- Node Modules: Automatic node_modules directory management
Project-Specific Configurations
Each Deno project has its own deno.json file that extends the base configuration:
src/adguard-api-typescript/deno.json- AdGuard API TypeScript SDKsrc/linear/deno.json- Linear import toolsrc/rules-compiler-typescript/deno.json- Rules compiler
These files only contain:
- Project metadata (
name,version) - Project-specific exports
- Project-specific tasks
- Project-specific dependencies (imports)
- Project-specific overrides (e.g., additional lint exclusions)
How It Works
Each project's deno.json file uses the "extends" field to inherit settings from the base configuration:
{
"extends": "../../deno.base.json",
"name": "@your-project/name",
"version": "1.0.0",
...
}
Settings in the project-specific file override or merge with the base configuration:
- Merging:
lint.rules.excludearrays are merged (base + project-specific) - Overriding: Other fields like
name,version,exportsreplace base settings
Benefits
- Single Source of Truth: Compiler options, formatting, and linting rules defined once
- Consistency: All projects use identical TypeScript strict mode, formatting, and linting
- Easy Updates: Change base configuration once to update all projects
- Reduced Duplication: Each project file is smaller and focused on project-specific settings
- Familiar Pattern: Mirrors
.NET'sDirectory.Build.propsand Rust's workspace pattern
Shared Settings
The following settings are shared across all Deno projects:
Compiler Options
{
"lib": ["deno.ns", "deno.unstable", "dom"],
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true
}
Formatting
{
"indentWidth": 2,
"lineWidth": 100,
"singleQuote": true
}
Linting
{
"rules": {
"tags": ["recommended"]
}
}
Node Modules
{
"nodeModulesDir": "auto"
}
Adding a New Deno Project
When creating a new Deno project in this repository:
- Create your project directory under
src/ - Create a
deno.jsonfile with:{ "extends": "../../deno.base.json", "name": "@your-scope/your-project", "version": "1.0.0", "exports": "./src/index.ts", "tasks": { // Your project-specific tasks }, "imports": { // Your project-specific dependencies } } - The base configuration will automatically apply
Modifying Shared Settings
To change settings that affect all Deno projects:
- Edit
/deno.base.json - The change will automatically apply to all projects that extend it
- Test all projects to ensure compatibility
To override a shared setting for a specific project:
- Add the setting to the project's
deno.json - The project-specific setting will override the base setting
Related Patterns
This configuration pattern follows the same philosophy as:
.NET:Directory.Build.propsandDirectory.Packages.props- Rust: Workspace
Cargo.tomlwith member packages - TypeScript:
tsconfig.base.jsonwith project-specifictsconfig.jsonfiles extending it
Schema Validation
All Deno configuration files use the official Deno schema for validation and IDE autocomplete:
{
"$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json"
}
Note: The $schema field is only included in deno.base.json and inherited by all projects.