# ESLint plugin (@manykind-ai/eslint-plugin)

> Reference for @manykind-ai/eslint-plugin 1.0.0: the recommended config and each rule, which show mk build's checks in your editor.

Source: https://developers.manykind.ai/reference/eslint-plugin/

```bash
npm install -D @manykind-ai/eslint-plugin @typescript-eslint/parser
```

The plugin shows the checks `mk build` runs on agent code while you type. It needs ESLint 8 or later.

## Configure

```json
{
  "parser": "@typescript-eslint/parser",
  "plugins": ["@manykind-ai"],
  "extends": ["plugin:@manykind-ai/recommended"],
  "rules": {
    "@manykind-ai/cubby-declared-alias": ["error", { "aliases": ["history"] }],
    "@manykind-ai/model-declared-alias": ["error", { "aliases": ["llm"] }]
  }
}
```

`recommended` turns on every agent rule below as an error.

## Rules

| Rule | Checks | Options |
|---|---|---|
| `on-event-literal` | `@OnEvent(…)` takes a string literal. | — |
| `engagement-id-literal` | `@Engagement({ … })` has `id` and `goal` as string literals. | — |
| `cubby-declared-alias` | `ctx.cubby(…)` takes a string literal naming a declared cubby. | `{ aliases: string[] }` |
| `model-declared-alias` | `ctx.models.X` names a declared model. | `{ aliases: string[] }` |
| `publish-declared-type` | Calls of the form `ctx.publish(type, …)` take a string literal in the declared set. It does not inspect `ctx.vault.publish`. | `{ knownEventTypes: string[] }` |
| `no-banned-imports` | No Node built-ins and no sync database or network packages. | — |

Without options, `cubby-declared-alias` and `publish-declared-type` check only that the argument is a literal, and `model-declared-alias` checks nothing.

### Banned imports

Node built-ins, with or without `node:`: `fs`, `fs/promises`, `path`, `net`, `tls`, `dgram`, `dns`, `http`, `https`, `http2`, `child_process`, `worker_threads`, `cluster`, `os`, `process`, `readline`, `repl`, `vm`, `stream`, `zlib`, `buffer`, `crypto`.

Packages: `pg`, `pg-native`, `mysql`, `mysql2`, `mongodb`, `redis`, `ioredis`, `sqlite3`, `better-sqlite3`, `ws`, `node-fetch`, `axios`.

Use the sandbox globals instead: `fetch` for HTTP, `globalThis.crypto` for WebCrypto, and `ctx.cubby` for storage.

## Editor and build

| Check | Editor (plugin) | `mk build` |
|---|---|---|
| Non-literal `@OnEvent` | error | error |
| Undeclared model alias | error, when `aliases` is set | error |
| Banned import | error | error |
| Cubby alias not in the agent's `cubbies` | error, when `aliases` is set | warning: the Agent Service may declare it |
| Computed cubby alias | error | warning |

## Related

- [Write an agent](https://developers.manykind.ai/agents/code-agents/overview/#what-mk-build-rejects)
- [Agent SDK reference](https://developers.manykind.ai/reference/agent-sdk/)
- [CLI reference](https://developers.manykind.ai/reference/cli/)
