npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

eslint-plugin-machina

v0.1.2

Published

ESLint plugin for static analysis of machina FSM configs.

Readme

eslint-plugin-machina

ESLint plugin for static analysis of machina FSM configs. Catches structural issues at lint time — unreachable states, infinite _onEnter loops, missing handlers — without running the machine.

Built on machina-inspect. ESLint 9 flat config only.

Install

npm install --save-dev eslint-plugin-machina
# or
pnpm add -D eslint-plugin-machina

machina-inspect is pulled in automatically as a dependency. For TypeScript files, you also need @typescript-eslint/parser:

npm install --save-dev @typescript-eslint/parser

Setup

Recommended preset

// eslint.config.mjs
import machina from "eslint-plugin-machina";

export default [
    machina.configs.recommended,
    // ... your other configs
];

With TypeScript

// eslint.config.mjs
import tsParser from "@typescript-eslint/parser";
import machina from "eslint-plugin-machina";

export default [
    {
        files: ["src/**/*.ts"],
        languageOptions: { parser: tsParser },
    },
    machina.configs.recommended,
];

Manual configuration

// eslint.config.mjs
import machina from "eslint-plugin-machina";

export default [
    {
        plugins: { machina },
        rules: {
            "machina/unreachable-state": "warn",
            "machina/onenter-loop": "error",
            "machina/missing-handler": "off",
        },
    },
];

Rules

| 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

Detects states with no inbound path from initialState. Unreachable states are dead code.

// Triggers warning on "broken"
createFsm({
    id: "traffic-light",
    initialState: "green",
    states: {
        green: { timeout: "yellow" },
        yellow: { timeout: "red" },
        red: { timeout: "green" },
        broken: {}, // no transitions lead here
    },
});

machina/onenter-loop

Detects unconditional _onEnter transition cycles that will infinite-loop the runtime. Only flags cycles where every edge is unconditional — conditional bounces like if (ctx.error) return "failed" are intentional patterns, not bugs.

// Triggers error — unconditional cycle: a -> b -> a
createFsm({
    id: "bouncy",
    initialState: "a",
    states: {
        a: { _onEnter: () => "b" },
        b: { _onEnter: () => "a" },
    },
});

machina/missing-handler

Detects states that don't handle inputs handled by other states in the same FSM. Off by default — many FSMs have asymmetric handlers by design (terminal states, initialization states, etc.). States with a * catch-all handler are excluded.

// Triggers suggestion — "idle" doesn't handle "stop" or "pause"
createFsm({
    id: "player",
    initialState: "idle",
    states: {
        idle: { start: "running" },
        running: { stop: "idle", pause: "paused" },
        paused: { resume: "running", stop: "idle" },
    },
});

How it works

The plugin listens for createFsm() and createBehavioralFsm() call expressions, builds a StateGraph from the AST using machina-inspect's graph IR, then runs the same structural checks machina-inspect provides. Findings are reported as ESLint diagnostics at the call site.

_child resolution

Child FSM references on _child are resolved when they're:

  • Inline calls: _child: createFsm({ ... }) directly in the state config
  • const references: _child: myChildFsm where myChildFsm is a const declaration bound to a createFsm() / createBehavioralFsm() call 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

License

MIT