ESLint Plugin
eslint-plugin-machina surfaces machina-inspect findings inline in your editor. Three rules, one import to set up. ESLint 9 flat config only.
Install
Section titled “Install”machina-inspect is pulled in automatically. For TypeScript files, you also need @typescript-eslint/parser:
Recommended preset
Section titled “Recommended preset”With TypeScript
Section titled “With TypeScript”| Rule | Default | Type | Description |
|---|---|---|---|
machina/unreachable-state | "warn" | problem | States with no inbound path from initialState |
machina/onenter-loop | "error" | problem | Unconditional _onEnter transition cycles |
machina/missing-handler | "off" | suggestion | States missing handlers for inputs other states handle |
machina/unreachable-state
Section titled “machina/unreachable-state”Detects dead states — states that no transition leads to.
machina/onenter-loop
Section titled “machina/onenter-loop”Detects unconditional _onEnter transition cycles that will infinite-loop the runtime. Conditional bounces are intentional patterns and are not flagged.
machina/missing-handler
Section titled “machina/missing-handler”Flags states that don’t handle inputs handled by other states. Off by default because many FSMs have asymmetric handlers by design. States with a * catch-all are excluded.
How it works
Section titled “How it works”The plugin listens for createFsm() and createBehavioralFsm() call expressions, builds a StateGraph from the ESLint AST using machina-inspect’s graph IR, then runs the structural checks. Findings are reported as ESLint diagnostics at the call site.
_child resolution
Section titled “_child resolution”Child FSM references are resolved when they’re inline createFsm() calls or const identifier references to such calls in the same module. Cross-module imports and let/var bindings are silently skipped — no false positives, just no analysis for those cases.
See also
Section titled “See also”- machina-inspect — programmatic API for the same checks
- machina-test — Jest/Vitest custom matchers for graph-level assertions in your test suite
- machina-explorer — paste-and-analyze browser UI