@mettlecast/eslint-plugin-domain-module
v0.2.54
Published
ESLint plugin enforcing TIB Domain Module framework usage patterns. Prevents accidental AWS SDK, HTTP server, and cross-domain violations.
Readme
@mettlecast/eslint-plugin-domain-module
ESLint plugin enforcing TIB Domain Module framework usage patterns. Prevents accidental AWS SDK, HTTP server, and cross-domain violations.
Install
npm install --save-dev @mettlecast/eslint-plugin-domain-moduleConfigure in eslint.config.js:
import domainModulePlugin from '@mettlecast/eslint-plugin-domain-module';
export default [
{
files: ['src/domain/**/*.ts'],
...domainModulePlugin.configs.recommended,
},
];Rules
| Rule | Flags | Severity |
|---|---|---|
| no-raw-aws-sdk | Direct imports of @aws-sdk/* packages in domain handler files | error |
| no-raw-http-server | Framework imports (express, koa, fastify, aws-lambda) in domain handlers | error |
| require-define-primitive | Handler files without a top-level define*() call (missing domain primitive declaration) | warn |
| no-cross-domain-internal-import | Importing internal modules (not exported types) from another domain directory | error |
Recommended Config
The recommended preset enables all four rules at their default severity levels:
domainModulePlugin.configs.recommended
// Results in:
// - no-raw-aws-sdk: error
// - no-raw-http-server: error
// - require-define-primitive: warn
// - no-cross-domain-internal-import: errorExamples
Violations caught:
// ❌ no-raw-aws-sdk
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
// ❌ no-raw-http-server
import express from 'express';
// ❌ require-define-primitive
export async function chargePayment(event, ctx) { /* ... */ }
// ❌ no-cross-domain-internal-import
import { internalFn } from '../payments/internal.js'; // not in payments/index.tsCorrect usage:
// ✓ Use DomainContext.db instead
const { db } = ctx;
// ✓ Use defineApi() to declare handlers
export const chargeHandler = defineApi({
path: '/charge',
// ...
});
// ✓ Only import exported types from other domains
import type { PaymentEvent } from '@myorg/payments-contracts';See Also
@mettlecast/domain-runtime— handler definitions@mettlecast/domain-cli— validation and linting
