/** * Forbids `throw new Error(...)` and related untyped builtins inside connector * source. Connectors must throw typed errors from `@unito/integration-sdk` * (e.g. `HttpErrors.UnprocessableEntityError`, `HttpErrors.NotFoundError`, * domain-specific subclasses). * * Bad: * throw new Error('Item not found'); * throw Error(`Unsupported item type "${type}"`); * throw new TypeError('Invalid input'); * * Good: * throw new HttpErrors.NotFoundError('Item not found'); * throw new HttpErrors.UnprocessableEntityError(`Unsupported item type "${type}"`); * * Why: * 1. Typed errors carry HTTP status codes — the SDK maps them to the correct * response. Raw `Error` becomes a generic 500. * 2. Typed errors carry structured fields (`category`, `code`, `subCategory`, * `additionalErrorData`) that the structured logger extracts via its * whitelist. Raw `Error` only logs the message. * 3. Downstream code can branch on `instanceof` — raw `Error` forces string * matching on the message, which is brittle. * * Allowlisted files (legitimate raw `Error` use): * - `**\/cache.ts` — internal hash-helper guards * - `**\/script(s)/**` — one-off CLI tooling, not request-path * - `**\/errors.ts` — defines the typed error classes themselves * - `**\/helpers/stringHelper.ts` — pure utility, not request-path * * Allowlisted message substrings: * - `/only supported in tests/i` — dev-mode-only guard * - `/assertNever/` — exhaustiveness check helper */ import type { Rule } from 'eslint'; declare const rule: Rule.RuleModule; export default rule;