Files
stanza/registry/modules/tooling-eslint-prettier/module.ts
T
jake e28eba2702 feat: add Handlebars template engine with peer-aware render context and consolidate eslint-prettier into a single adaptive template
- Replace per-framework template files (`eslint.config.next.mjs`, `eslint.config.tanstack.mjs`) with a single `eslint.config.mjs` that branches via Handlebars `{{#if peers.framework}}` conditionals; add `handlebars` as a direct dependency to `@stanza/registry`, `apps/cli`, and `apps/web`
- Extend the template render context with a `peers: Partial<Record<CategoryId, string>>` map so any template can inspect the active framework, auth provider, etc.; thread it through `buildRenderContext`, `synthesizeTemplates`, the CLI `codemod-runner`, and the web `getBuilderState` server function
- Extract and export `activePeerIds(manifest, appId?)` from `@stanza/registry` to derive the peer map from a manifest (app-scoped for `home: app` categories); add `selectedPeerIds(selections)` in `apps/web/src/lib/selection.ts` as the URL-params-derived equivalent
- Add integration tests verifying framework-conditional eslint-prettier output for `default`, `next`, and `tanstack-start` adapters; expand resolver tests for `activePeerIds` app-scoping and for modules that declare both a `default` adapter and a framework-specific override
2026-05-25 13:35:27 -04:00

59 lines
1.7 KiB
TypeScript

import { defineModule, type TemplateRef } from "@stanza/registry";
// Same templates regardless of which framework adapter wins. The eslint config
// is a single Handlebars template that branches on `{{peers.framework}}`, so
// pure-TS, Next, and TanStack Start all render from the same source file.
const templates: TemplateRef[] = [
{ src: "eslint.config.mjs", dest: "eslint.config.mjs", scope: "repo", template: true },
{ src: "prettier.config.mjs", dest: "prettier.config.mjs", scope: "repo" },
];
export default defineModule({
id: "eslint-prettier",
category: "tooling",
label: "ESLint + Prettier",
description: "ESLint (flat config) for linting and Prettier for formatting.",
version: "0.1.0",
homepage: "https://eslint.org",
// Framework-agnostic base; adapters layer on framework-specific plugins via
// Handlebars conditionals in the shared template — same shape as the
// tooling-biome / tooling-oxlint-oxfmt siblings, which also install without
// a framework peer.
devDependencies: {
eslint: "^9.39.0",
"@eslint/js": "^9.39.0",
"typescript-eslint": "^8.46.0",
prettier: "^3.6.2",
"eslint-config-prettier": "^10.1.8",
},
scripts: {
lint: "eslint .",
format: "prettier --write .",
},
adapters: [
{
key: "next",
match: { framework: "next" },
devDependencies: {
"@next/eslint-plugin-next": "^16.2.6",
"eslint-plugin-react-hooks": "^7.0.0",
},
templates,
},
{
key: "tanstack-start",
match: { framework: "tanstack-start" },
devDependencies: {
"eslint-plugin-react": "^7.37.5",
"eslint-plugin-react-hooks": "^7.0.0",
},
templates,
},
{
key: "default",
match: {},
templates,
},
],
});