Assist_Design/scripts/domain/check-exports.mjs
barsa a699080610 Update ESLint Configuration and Clean Up Scripts
- Adjusted ESLint configuration to improve clarity in import rules, specifically preventing deep imports from the domain.
- Removed unnecessary blank lines in `check-domain-imports.mjs`, `check-exports.mjs`, and `codemod-domain-imports.mjs` scripts for better code cleanliness and maintainability.
- Enhanced readability of the import validation message in ESLint configuration.
2025-12-29 18:41:28 +09:00

25 lines
788 B
JavaScript

import fs from "node:fs/promises";
import path from "node:path";
const ROOT = process.cwd();
const pkgPath = path.join(ROOT, "packages", "domain", "package.json");
const pkg = JSON.parse(await fs.readFile(pkgPath, "utf8"));
const exportsField = pkg.exports;
if (!exportsField || typeof exportsField !== "object") {
console.error("[domain] ERROR: package.json exports field is missing or invalid.");
process.exit(1);
}
const keys = Object.keys(exportsField);
const wildcardKeys = keys.filter(k => k.includes("*"));
if (wildcardKeys.length > 0) {
console.error("[domain] ERROR: wildcard subpath exports are not allowed:");
for (const k of wildcardKeys) console.error(`- ${k}`);
process.exit(1);
}
console.log("[domain] OK: package.json exports contains no wildcard keys.");