Files
composiohq__composio/eslint.config.mjs
T
Alberto Schiabel 76881491d0 feat(examples): executable, CI-linked Mastra example (Tool Router + Workers) (#3788)
## What

Turns the **Mastra** example into an executable reference that doubles
as a test, and wires the examples into CI for the first time. First
slice of the v1 "executable examples" workstream — the pattern here is
the template for the other TS providers, then Python.

## Why

Examples under `ts/examples/*` were unverified: the only CI tie-in is
`validate-examples.ts`, which is transpile-only (no cross-file types, no
lint, no execution) and passes on exactly the schema-conversion
regressions we keep hitting in the Mastra provider — all closed but
unprotected:

- https://github.com/ComposioHQ/composio/issues/2109 (zod→json
serialization crash)
- https://github.com/ComposioHQ/composio/issues/3307 (`$defs` dropped
while `$ref` kept)
- https://github.com/mastra-ai/mastra/issues/13909 (already-JSON-Schema
tools crash serialization)

## Changes

**Canonical Mastra example** (`ts/examples/mastra`)
- `src/index.ts` — direct tools on the unauthenticated `HACKERNEWS`
toolkit
- `src/tool-router.ts` — v1-canonical `composio.sessions.create(...)` →
`session.tools()` (drops the deprecated bare `composio.create` alias)
- `src/cloudflare.ts` — the same wrapping path on the Cloudflare Workers
runtime (`export default { fetch }`)
- `src/smoke.ts` — deterministic wrapping + tool-router assertions
(needs only `COMPOSIO_API_KEY`)
- Removed the old Gmail/MCP entries that used deprecated APIs and
required auth
- Runnable via `bun ts/examples/mastra/src/{index,tool-router}.ts`

**Real typecheck + lint** (examples previously escaped both)
- Example now has a `typecheck` script (Node + Worker tsconfigs);
`typecheck:examples` / `lint:examples` scripts added
- eslint now covers `ts/examples/**` with type-safety rules kept
(`no-explicit-any`) and console noise allowed

**Two-tier CI**
- `ts.examples.yml` — per-PR **blocking**, no secrets: build → typecheck
→ lint → `wrangler deploy --dry-run`. This is the tier that catches the
schema-conversion regressions, since a dropped `$defs`/`$ref` surfaces
as a **type** error.
- `ts.examples-nightly.yml` — **non-blocking**, scheduled: executes
against the **staging** backend with secrets; runs the deterministic
smoke always and the full agent examples when an LLM key is set.

## Verification

Locally against staging: `smoke` passes (5 direct + 6 tool-router
tools), `typecheck:examples` and `lint:examples` are green, the Worker
`wrangler deploy --dry-run` bundles, and seeded regressions (a type
error / an `any`) correctly fail their gate.

## Notes

- No changeset — example packages are private/unpublished.
- Follow-ups (separate PRs): template the pattern to the other TS
providers, then port to `python/examples/*`.
2026-07-10 01:40:03 +04:00

94 lines
2.9 KiB
JavaScript

import globals from 'globals';
import tseslint from 'typescript-eslint';
/** @type {import('eslint').Linter.Config[]} */
export default [
{
ignores: [
'ts/packages/**/dist/**',
'ts/packages/**/.generated/**',
'ts/packages/**/acp-adapters/**',
'ts/packages/**/node_modules/**',
'node_modules/**',
'ts/examples/**/dist/**',
'ts/examples/**/dist-worker/**',
'scripts/**',
'**/test/**',
],
},
{ files: ['ts/packages/**/*.ts', 'ts/examples/**/*.ts'] },
{ languageOptions: { globals: globals.browser } },
...tseslint.configs.recommended,
{
rules: {
// "@typescript-eslint/no-var-requires": "off",
'no-restricted-globals': ['error', 'Buffer'],
"no-restricted-imports": ["error", {
"paths": [
{
"name": "crypto",
"message": "Use Web Crypto API instead.",
},
{
"name": "node:crypto",
"message": "Use Web Crypto API instead.",
},
{
"name": "buffer",
"message": "Use Uint8Array instead.",
},
{
"name": "node:buffer",
"message": "Use Uint8Array instead.",
},
],
}],
'@typescript-eslint/no-require-imports': 'warn',
'@typescript-eslint/no-unsafe-function-type': 'off',
'no-prototype-builtins': 'off',
'max-lines-per-function': ['error', 250],
'no-unused-vars': 'off',
'@typescript-eslint/ban-ts-comment': 'warn',
'no-constant-condition': 'off',
'no-ex-assign': 'off',
'no-constant-binary-expression': 'off',
'@typescript-eslint/no-empty-object-type': 'warn',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'no-unsafe-optional-chaining': 'off',
'no-extra-boolean-cast': 'off',
'no-var': 'warn',
'prefer-const': 'warn',
'no-console': 'warn',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
},
},
{
// Examples are console-driven references. Keep type-safety rules
// (no-explicit-any, unused-vars) but drop console noise. The Buffer/crypto
// restrictions above target SDK/Workers source; Node example scripts may
// legitimately use Node built-ins, so relax them here (see KTD6).
files: ['ts/examples/**/*.ts'],
rules: {
'no-console': 'off',
'no-restricted-globals': 'off',
'no-restricted-imports': 'off',
},
},
{
// The Cloudflare Workers entry stays portable: no Node globals even though
// nodejs_compat is enabled. Re-apply the restriction dropped just above.
files: ['ts/examples/**/cloudflare.ts'],
rules: {
'no-restricted-globals': ['error', 'Buffer'],
},
},
];