chore(template): clean-slate template snapshot from bb4a0c7
Curated, product-agnostic snapshot of the post-story-04 tree: demo content deleted, auth-only reference feature, web-next shell, all gates green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor library traces, and product naming are curated out; generic template repairs (coverage provider devDeps, root test:coverage script, live lint fixes, root-only release-please) are kept. See TEMPLATE.md for provenance, curation list, and usage. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
This commit is contained in:
47
packages/core-eslint/rules/atomic-tier-import-direction.js
Normal file
47
packages/core-eslint/rules/atomic-tier-import-direction.js
Normal file
@@ -0,0 +1,47 @@
|
||||
const TIERS = ["atoms", "molecules", "organisms", "templates", "pages"];
|
||||
|
||||
function tierOf(filepath) {
|
||||
for (let i = 0; i < TIERS.length; i++) {
|
||||
const tier = TIERS[i];
|
||||
if (filepath.includes(`/${tier}/`) || filepath.includes(`\\${tier}\\`)) {
|
||||
return { name: tier, index: i };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @type {import("eslint").Rule.RuleModule} */
|
||||
export default {
|
||||
meta: {
|
||||
type: "problem",
|
||||
docs: {
|
||||
description:
|
||||
"Atomic-design tier imports respect direction: atoms ← molecules ← organisms ← templates ← pages.",
|
||||
},
|
||||
schema: [],
|
||||
messages: {
|
||||
wrongDirection:
|
||||
"{{fromTier}} cannot import from {{toTier}} ({{importPath}}). Tier direction: atoms ← molecules ← organisms ← templates ← pages.",
|
||||
},
|
||||
},
|
||||
create(context) {
|
||||
const filename = context.filename;
|
||||
const from = tierOf(filename);
|
||||
if (!from) return {};
|
||||
return {
|
||||
ImportDeclaration(node) {
|
||||
const source = node.source.value;
|
||||
if (typeof source !== "string") return;
|
||||
const to = tierOf(source);
|
||||
if (!to) return;
|
||||
if (to.index > from.index) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: "wrongDirection",
|
||||
data: { fromTier: from.name, toTier: to.name, importPath: source },
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user