Archon/eslint.config.mjs
Rasmus Widing 86e4c8d605
fix(bundled-defaults): auto-generate import list, emit inline strings (#1263)
* fix(bundled-defaults): auto-generate import list, emit inline strings

Root-cause fix for bundle drift (15 commands + 7 workflows previously
missing from binary distributions) and a prerequisite for packaging
@archon/workflows as a Node-loadable SDK.

The hand-maintained `bundled-defaults.ts` import list is replaced by
`scripts/generate-bundled-defaults.ts`, which walks
`.archon/{commands,workflows}/defaults/` and emits a generated source
file with inline string literals. `bundled-defaults.ts` becomes a thin
facade that re-exports the generated records and keeps the
`isBinaryBuild()` helper.

Inline strings (via JSON.stringify) replace Bun's
`import X from '...' with { type: 'text' }` attributes. The binary build
still embeds the data at compile time, but the module now loads under
Node too — removing SDK blocker #2.

- Generator: `scripts/generate-bundled-defaults.ts` (+ `--check` mode for CI)
- `package.json`: `generate:bundled`, `check:bundled`; wired into `validate`
- `build-binaries.sh`: regenerates defaults before compile
- Test: `bundle completeness` now derives expected set from on-disk files
- All 56 defaults (36 commands + 20 workflows) now in the bundle

* fix(bundled-defaults): address PR review feedback

Review: https://github.com/coleam00/Archon/pull/1263#issuecomment-4262719090

Generator:
- Guard against .yaml/.yml name collisions (previously silent overwrite)
- Add early access() check with actionable error when run from wrong cwd
- Type top-level catch as unknown; print only message for Error instances
- Drop redundant /* eslint-disable */ emission (global ignore covers it)
- Fix misleading CI-mechanism claim in header comment
- Collapse dead `if (!ext) continue` guard into a single typed pass

Scripts get real type-checking + linting:
- New scripts/tsconfig.json extending root config
- type-check now includes scripts/ via `tsc --noEmit -p scripts/tsconfig.json`
- Drop `scripts/**` from eslint ignores; add to projectService file scope

Tests:
- Inline listNames helper (Rule of Three)
- Drop redundant toBeDefined/typeof assertions; the Record<string, string>
  type plus length > 50 already cover them
- Add content-fidelity round-trip assertion (defense against generator
  content bugs, not just key-set drift)

Facade comment: drop dead reference to .claude/rules/dx-quirks.md.

CI: wire `bun run check:bundled` into .github/workflows/test.yml so the
header's CI-verification claim is truthful.

Docs: CLAUDE.md step count four→five; add contributor bullet about
`bun run generate:bundled` in the Defaults section and CONTRIBUTING.md.

* chore(e2e): bump Codex model to gpt-5.2

gpt-5.1-codex-mini is deprecated and unavailable on ChatGPT-account Codex
auth. Plain gpt-5.2 works. Verified end-to-end:

- e2e-codex-smoke: structured output returns {category:'math'}
- e2e-mixed-providers: claude+codex both return expected tokens
2026-04-16 21:27:51 +02:00

112 lines
4.1 KiB
JavaScript

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import prettierConfig from 'eslint-config-prettier';
export default tseslint.config(
// Global ignores (applied to all configs)
{
ignores: [
'node_modules/**',
'packages/*/node_modules/**',
'packages/*/dist/**',
'dist/**',
'coverage/**',
'.agents/examples/**',
'packages/docs-web/**',
'workspace/**',
'worktrees/**',
'.claude/worktrees/**',
'.claude/skills/**',
'**/*.generated.ts', // Auto-generated source files (content inlined via JSON.stringify)
'**/*.js',
'*.mjs',
'**/*.test.ts',
'**/src/test/**', // Test helper files (mock factories, fixtures)
'*.d.ts', // Root-level declaration files (not in tsconfig project scope)
'**/*.generated.d.ts', // Auto-generated declaration files (e.g. openapi-typescript output)
'packages/web/vite.config.ts', // Vite config doesn't need type-checked linting
'packages/web/components.json',
'packages/web/src/components/ui/**', // shadcn/ui auto-generated components
'packages/web/src/lib/utils.ts', // shadcn/ui utility file
],
},
// Base configs
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.strictTypeChecked,
...tseslint.configs.stylisticTypeChecked,
// Prettier integration
prettierConfig,
// Project-specific settings
{
files: ['packages/*/src/**/*.{ts,tsx}', 'scripts/**/*.ts'],
languageOptions: {
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
rules: {
// === ENFORCED RULES (errors) ===
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'always'],
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'interface',
format: ['PascalCase'],
custom: { regex: '^I?[A-Z]', match: true },
},
{ selector: 'typeAlias', format: ['PascalCase'] },
{ selector: 'function', format: ['camelCase', 'PascalCase'] },
{ selector: 'variable', format: ['camelCase', 'UPPER_CASE'] },
],
'@typescript-eslint/no-non-null-assertion': 'error',
// === DISABLED RULES ===
// --- Template/expression rules ---
// Numbers/booleans in template literals are valid JS (auto-converted to string)
'@typescript-eslint/restrict-template-expressions': 'off',
// Mixed operands in + are often intentional (string concatenation)
'@typescript-eslint/restrict-plus-operands': 'off',
// --- Defensive coding patterns ---
// Switch defaults, null checks, and defensive guards are valuable
'@typescript-eslint/no-unnecessary-condition': 'off',
// Env var checks need || for truthy evaluation (empty string = missing)
'@typescript-eslint/prefer-nullish-coalescing': 'off',
// --- External SDK interop (types are often `any` or incomplete) ---
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
// Event handler patterns in SDKs often have promise mismatches
'@typescript-eslint/no-misused-promises': 'off',
'@typescript-eslint/no-floating-promises': 'off',
// --- Style preferences (not critical for type safety) ---
// Catch variable typing preference
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'off',
// Allow using deprecated APIs during migration periods
'@typescript-eslint/no-deprecated': 'off',
// Empty async functions valid for interface compliance
'@typescript-eslint/require-await': 'off',
// Constructor style preference
'@typescript-eslint/consistent-generic-constructors': 'off',
},
}
);