From 8b3b118bb0dbc6b81e527c1913c0197bcce2cc30 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Fri, 8 May 2026 12:49:35 +0200 Subject: [PATCH] test(core-eslint): anchor-presence CI guard for // comments Co-Authored-By: Claude Sonnet 4.6 --- packages/core-eslint/anchors.test.js | 29 +++++++++++++++++++++++++++ packages/core-eslint/package.json | 6 +++++- packages/core-eslint/vitest.config.js | 9 +++++++++ pnpm-lock.yaml | 3 +++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 packages/core-eslint/anchors.test.js create mode 100644 packages/core-eslint/vitest.config.js diff --git a/packages/core-eslint/anchors.test.js b/packages/core-eslint/anchors.test.js new file mode 100644 index 0000000..ea7a151 --- /dev/null +++ b/packages/core-eslint/anchors.test.js @@ -0,0 +1,29 @@ +import { describe, it, expect } from "vitest"; +import { readFileSync } from "node:fs"; +import { join, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; + +const __dirname = dirname(fileURLToPath(import.meta.url)); +const REPO_ROOT = join(__dirname, "..", ".."); +const FEATURES = ["auth", "blog", "media", "marketing-pages", "navigation"]; +const ANCHORS = { + "src/index.ts": ["// "], + "src/di/symbols.ts": ["// ", "// "], + "src/di/bind-production.ts": ["// ", "// "], + "src/di/bind-dev-seed.ts": ["// ", "// "], + "src/integrations/cms/index.ts": ["// "], +}; + +describe("// anchor presence in feature packages", () => { + for (const feature of FEATURES) { + for (const [relPath, anchors] of Object.entries(ANCHORS)) { + it(`packages/${feature}/${relPath} contains all required anchors`, () => { + const path = join(REPO_ROOT, "packages", feature, relPath); + const content = readFileSync(path, "utf8"); + for (const anchor of anchors) { + expect(content).toContain(anchor); + } + }); + } + } +}); diff --git a/packages/core-eslint/package.json b/packages/core-eslint/package.json index 7e5a4a7..0f0da26 100644 --- a/packages/core-eslint/package.json +++ b/packages/core-eslint/package.json @@ -8,6 +8,9 @@ "./next": "./next.js", "./react-internal": "./react-internal.js" }, + "scripts": { + "test": "vitest run --passWithNoTests" + }, "devDependencies": { "@eslint/js": "^9.20.0", "@typescript-eslint/eslint-plugin": "^8.25.0", @@ -16,7 +19,8 @@ "eslint-config-prettier": "^10.1.0", "eslint-plugin-boundaries": "^4.2.2", "eslint-plugin-turbo": "^2.4.0", - "typescript-eslint": "^8.25.0" + "typescript-eslint": "^8.25.0", + "vitest": "^3.1.0" }, "dependencies": { "globals": "^17.6.0" diff --git a/packages/core-eslint/vitest.config.js b/packages/core-eslint/vitest.config.js new file mode 100644 index 0000000..f04b5e5 --- /dev/null +++ b/packages/core-eslint/vitest.config.js @@ -0,0 +1,9 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { + globals: true, + environment: "node", + include: ["*.test.js"], + }, +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 57fa3fe..9687f80 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -515,6 +515,9 @@ importers: typescript-eslint: specifier: ^8.25.0 version: 8.58.0(eslint@9.39.4(jiti@2.6.1))(typescript@5.9.3) + vitest: + specifier: ^3.1.0 + version: 3.2.4(@types/debug@4.1.13)(@types/node@25.5.2)(happy-dom@20.8.9)(jiti@2.6.1)(jsdom@25.0.1)(lightningcss@1.32.0)(sass@1.99.0)(terser@5.46.2)(tsx@4.21.0) packages/core-events: dependencies: