@triggery/eslint-plugin
ESLint plugin for Triggery: catches mis-use of createTrigger and the hook API, enforces conventions, and keeps trigger files readable as specs. Ships recommended and strict flat-config presets for ESLint 9.x.
Install
Section titled “Install”pnpm add -D @triggery/eslint-plugin eslint typescript npm install --save-dev @triggery/eslint-plugin eslint typescript yarn add --save-dev @triggery/eslint-plugin eslint typescript bun add -D @triggery/eslint-plugin eslint typescript Peer deps: eslint >= 9.0.0, typescript >= 5.0.0.
What’s inside
Section titled “What’s inside”| Rule | Recommended | Strict | Auto-fix |
|---|---|---|---|
no-dynamic-id | error | error | — |
no-event-cascade | error | error | — |
hook-rules | error | error | — |
exhaustive-conditions | warn | error | — |
exhaustive-required | warn | error | — |
max-handler-size | warn (≤50) | error (≤30) | — |
max-ports-per-trigger | warn (≤12) | error (≤8) | — |
prefer-named-hook | off | warn (≥3) | — |
Quick example
Section titled “Quick example”Flat config (ESLint 9.x):
eslint.config.js
import triggery from '@triggery/eslint-plugin';
export default [
triggery.configs.recommended,
// Or, dialled up:
// triggery.configs.strict,
];Cherry-picking individual rules:
import triggery from '@triggery/eslint-plugin';
export default [
{
plugins: { '@triggery': triggery },
rules: {
'@triggery/no-dynamic-id': 'error',
'@triggery/no-event-cascade': 'error',
'@triggery/max-handler-size': ['warn', { max: 40 }],
},
},
];Rule highlights
Section titled “Rule highlights”no-dynamic-id—createTrigger({ id })must be a string literal. Trigger ids are registry keys, devtools labels, and graph anchors — they must be deterministic.no-event-cascade— DisallowsuseEvent(...)inside auseAction(...)handler. Cascades are allowed at runtime, but writing them inline hides cross-trigger control flow.hook-rules— Framework-neutral rules-of-hooks foruseEvent/useCondition/useAction/useInlineTrigger.exhaustive-conditions— Every name inrequired: [...]has a matchinguseConditionin the same file.exhaustive-required— EverycreateTrigger({...})call must include an explicitrequired:key (userequired: []if no gate is needed).max-handler-size/max-ports-per-trigger— Keep triggers spec-like; reach for theextract-triggercodemod when they grow.
Related packages
Section titled “Related packages” @triggery/core The runtime these rules know about.
@triggery/codemod extract-trigger / migrate-from-listener-middleware introduce trigger files this plugin checks.
@triggery/cli triggery lint wraps this plugin's recommended preset.
@triggery/testing Static checks plus runtime tests, together.