diff --git a/src/configs/flat/base.ts b/src/configs/flat/base.ts index 3137a24e..22cb90f3 100644 --- a/src/configs/flat/base.ts +++ b/src/configs/flat/base.ts @@ -4,7 +4,10 @@ import globals from "globals" import type { ESLint } from "eslint" import * as parser from "astro-eslint-parser" -import { tsESLintParser } from "../has-typescript-eslint-parser" +import { + tsESLintParser, + hasTypescriptEslintParser, +} from "../has-typescript-eslint-parser" import { environments } from "../../environments/index" export default [ { @@ -34,6 +37,9 @@ export default [ // eslint-plugin-astro rules // Enable base rules }, + processor: hasTypescriptEslintParser + ? "astro/client-side-ts" + : "astro/astro", }, { // Define the configuration for ` + `, + { filePath: "path/to/test.astro" }, + ) + + assert.deepStrictEqual( + result + .flatMap((r) => r.messages) + .map((m) => ({ ruleId: m.ruleId, message: m.message })), + [ + { + message: "Using 'Identifier[name='id']' is not allowed.", + ruleId: "no-restricted-syntax", + }, + ], + ) + }) +}) diff --git a/tests/src/integration/client-typescript.ts b/tests/src/integration/client-typescript.ts index eeb92620..603e9615 100644 --- a/tests/src/integration/client-typescript.ts +++ b/tests/src/integration/client-typescript.ts @@ -60,10 +60,8 @@ describe("Integration test for client-side ts", () => { rules: { "no-restricted-syntax": ["error", "TSTypeAnnotation"], } as Record, - }, - { - files: ["*.astro", "**/*.astro"], - processor: "astro/client-side-ts", + // Auto detect the processor + // processor: "astro/client-side-ts", }, ], }) diff --git a/tools/update-rulesets.ts b/tools/update-rulesets.ts index 1289af6d..7147cf4e 100644 --- a/tools/update-rulesets.ts +++ b/tools/update-rulesets.ts @@ -103,7 +103,7 @@ void formatAndSave( import globals from "globals" import type { ESLint } from "eslint" import * as parser from "astro-eslint-parser" -import { tsESLintParser } from "../has-typescript-eslint-parser" +import { tsESLintParser, hasTypescriptEslintParser } from "../has-typescript-eslint-parser" import { environments } from "../../environments/index" export default [ { @@ -139,6 +139,7 @@ export default [ }) .join(",\n ")} }, + processor: hasTypescriptEslintParser ? 'astro/client-side-ts' : 'astro/astro' }, { // Define the configuration for \`