import { useCaseNameFromFile } from "./_usecase-name.js"; import { featureRootForFile } from "./_manifest-source.js"; /** * Resolves the rule execution context from an ESLint context object. * Returns null when the file is not a use-case file or not inside a * recognised feature package — callers should return {} immediately. */ export function resolveRuleContext(context) { const opts = context.options[0] ?? {}; const repoRoot = opts.repoRoot ?? context.cwd ?? process.cwd(); const filename = context.filename; const useCaseName = useCaseNameFromFile(filename); if (!useCaseName) return null; const featureRoot = featureRootForFile(filename, repoRoot); if (!featureRoot) return null; return { useCaseName, featureRoot, repoRoot }; }