Initial commit
This commit is contained in:
18
packages/core-eslint/rules/_rule-context.js
Normal file
18
packages/core-eslint/rules/_rule-context.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user