From 2e7f410aa518f3a24f1fdbbb272e360558bbbb82 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 4 Dec 2025 14:28:21 +0800 Subject: [PATCH 1/3] fix: make mapESLintTemplate optional with default value --- src/index.ts | 14 ++++++++++---- test/agents.test.ts | 3 --- test/custom-tools.test.ts | 2 -- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index 0a7b80b..78bc33f 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. + * @default () => 'vanilla-ts' + */ + 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..f21a0c9 100644 --- a/test/custom-tools.test.ts +++ b/test/custom-tools.test.ts @@ -45,7 +45,6 @@ test('should run extra tool action', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, extraTools: [ { value: 'custom-action', @@ -82,7 +81,6 @@ test('should run extra tool command', async () => { root: fixturesDir, templates: ['vanilla'], getTemplateName: async () => 'vanilla', - mapESLintTemplate: () => null, extraTools: [ { value: 'custom-command', From b9d5ace9b3efa1700e53396050be6d5892cc4cf6 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 4 Dec 2025 14:30:48 +0800 Subject: [PATCH 2/3] fix --- test/custom-tools.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/custom-tools.test.ts b/test/custom-tools.test.ts index f21a0c9..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'; @@ -56,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 () => { @@ -90,5 +90,5 @@ test('should run extra tool command', async () => { ], }); - assert.strictEqual(fs.existsSync(touchedFile), true); + expect(fs.existsSync(touchedFile)).toBe(true); }); From a1d1877260765b3b05895d1a788170cbb789c05b Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 4 Dec 2025 14:31:37 +0800 Subject: [PATCH 3/3] Update src/index.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 78bc33f..9631933 100644 --- a/src/index.ts +++ b/src/index.ts @@ -236,7 +236,7 @@ export async function create({ getTemplateName: (argv: Argv) => Promise; /** * Map the template name to the ESLint template name. - * @default () => 'vanilla-ts' + * If not provided, defaults to 'vanilla-ts' for all templates. */ mapESLintTemplate?: ( templateName: string,