Skip to content

TypeScript · architecture

no-storage-in-stateless-modules

eslint:no-storage-in-stateless-modules

Disallow SQL or key/value access inside configured stateless modules; derive state from a system of record instead.

Default
error
Fix
none
Languages
typescript

Why

Private storage in a stateless workflow creates another source of truth that can silently diverge.

Fix

Read from the system of record or derive state from an artifact the workflow already produces.

Before / after

Executed by this rule’s unit tests.

Before

Do not write private state in a stateless module

src/engineer-digest/post.ts · focus
await kv.put('digest:last', timestamp);

After

Read from the system of record

src/engineer-digest/post.ts · focus
const issues = await linear.listIssues();

Limits

  • The rule is disabled until module path patterns are configured and recognizes only configured storage method names.

Message IDs

storageInStatelessModule

Options

{
  "additionalProperties": false,
  "properties": {
    "methods": {
      "description": "Storage method names to flag. Replaces the defaults.",
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "modules": {
      "description": "Regex sources matched against the filename. Empty (the default) disables the rule.",
      "items": {
        "type": "string"
      },
      "type": "array"
    }
  },
  "type": "object"
}