From 171ed20527a17821c0f45ca6c3f38932702dff24 Mon Sep 17 00:00:00 2001 From: Danijel Martinek Date: Wed, 13 May 2026 07:34:00 +0200 Subject: [PATCH] refactor(core-eslint): readManifestSource delegates to AST parser --- .../core-eslint/rules/_manifest-source.js | 31 ++++--------------- 1 file changed, 6 insertions(+), 25 deletions(-) diff --git a/packages/core-eslint/rules/_manifest-source.js b/packages/core-eslint/rules/_manifest-source.js index dba87ba..0c6baec 100644 --- a/packages/core-eslint/rules/_manifest-source.js +++ b/packages/core-eslint/rules/_manifest-source.js @@ -1,35 +1,16 @@ -import fs from "node:fs"; import path from "node:path"; +import { parseManifestFully } from "./_manifest-ast.js"; /** - * Reads a feature.manifest.ts file and extracts the manifest's `name` field - * and `requiredCores` array via regex. Returns null if the file does not - * exist or does not match the expected literal `as const` manifest shape. - * - * The repo's convention is that every feature.manifest.ts uses defineFeature - * with literal `as const` syntax — this is enforced by the type-system - * design (defineFeature has `` to preserve literal types). The - * regex extraction is therefore safe; the AST path is overkill. + * Reads a feature.manifest.ts and returns { name, requiredCores }. + * Backed by the AST parser from _manifest-ast.js — no longer uses regex. * * Returns: { name: string, requiredCores: string[] } | null */ export function readManifestSource(manifestPath) { - let src; - try { - src = fs.readFileSync(manifestPath, "utf8"); - } catch { - return null; - } - const nameMatch = src.match(/name:\s*"([^"]+)"/); - if (!nameMatch) return null; - const coresMatch = src.match(/requiredCores:\s*\[([^\]]*)\]/); - const cores = coresMatch - ? coresMatch[1] - .split(",") - .map((s) => s.trim().replace(/^"/, "").replace(/"$/, "")) - .filter((s) => s.length > 0) - : []; - return { name: nameMatch[1], requiredCores: cores }; + const full = parseManifestFully(manifestPath); + if (!full) return null; + return { name: full.name, requiredCores: full.requiredCores }; } /**