diff --git a/src/index.ts b/src/index.ts index 0a7b80b..9631933 100644 --- a/src/index.ts +++ b/src/index.ts @@ -234,7 +234,11 @@ export async function create({ skipFiles?: string[]; templates: string[]; getTemplateName: (argv: Argv) => Promise; - mapESLintTemplate: ( + /** + * Map the template name to the ESLint template name. + * If not provided, defaults to 'vanilla-ts' for all templates. + */ + mapESLintTemplate?: ( templateName: string, context: { distFolder: string }, ) => ESLintTemplateName | null; @@ -351,9 +355,11 @@ export async function create({ const toolFolder = path.join(packageRoot, `template-${tool}`); if (tool === 'eslint') { - const eslintTemplateName = mapESLintTemplate(templateName, { - distFolder, - }); + const eslintTemplateName = mapESLintTemplate + ? mapESLintTemplate(templateName, { + distFolder, + }) + : 'vanilla-ts'; if (!eslintTemplateName) { continue; diff --git a/test/agents.test.ts b/test/agents.test.ts index b1c0b04..745305a 100644 --- a/test/agents.test.ts +++ b/test/agents.test.ts @@ -37,7 +37,6 @@ test('should generate AGENTS.md with no tools selected', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, }); const agentsPath = path.join(projectDir, 'AGENTS.md'); @@ -92,7 +91,6 @@ test('should generate AGENTS.md with single tool selected', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, }); const agentsPath = path.join(projectDir, 'AGENTS.md'); @@ -205,7 +203,6 @@ test('should merge top-level sections from AGENTS.md files', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, }); const agentsPath = path.join(projectDir, 'AGENTS.md'); diff --git a/test/custom-tools.test.ts b/test/custom-tools.test.ts index d57178f..6f2376c 100644 --- a/test/custom-tools.test.ts +++ b/test/custom-tools.test.ts @@ -1,7 +1,7 @@ import fs from 'node:fs'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; -import { assert, beforeEach, test } from '@rstest/core'; +import { beforeEach, expect, test } from '@rstest/core'; import fse from 'fs-extra'; import { create } from '../dist/index.js'; @@ -45,7 +45,6 @@ test('should run extra tool action', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, extraTools: [ { value: 'custom-action', @@ -57,7 +56,7 @@ test('should run extra tool action', async () => { ], }); - assert.strictEqual(actionCalled, true); + expect(actionCalled).toBe(true); }); test('should run extra tool command', async () => { @@ -82,7 +81,6 @@ test('should run extra tool command', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, extraTools: [ { value: 'custom-command', @@ -92,5 +90,5 @@ test('should run extra tool command', async () => { ], }); - assert.strictEqual(fs.existsSync(touchedFile), true); + expect(fs.existsSync(touchedFile)).toBe(true); });