Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
228 lines
5.5 KiB
JavaScript
228 lines
5.5 KiB
JavaScript
/**
|
|
* @fileoverview Rule to disallow specified names in exports
|
|
* @author Milos Djermanovic
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const astUtils = require("./utils/ast-utils");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
/** @type {import('../types').Rule.RuleModule} */
|
|
module.exports = {
|
|
meta: {
|
|
type: "suggestion",
|
|
|
|
docs: {
|
|
description: "Disallow specified names in exports",
|
|
recommended: false,
|
|
url: "https://eslint.org/docs/latest/rules/no-restricted-exports",
|
|
},
|
|
|
|
schema: [
|
|
{
|
|
anyOf: [
|
|
{
|
|
type: "object",
|
|
properties: {
|
|
restrictedNamedExports: {
|
|
type: "array",
|
|
items: {
|
|
type: "string",
|
|
},
|
|
uniqueItems: true,
|
|
},
|
|
restrictedNamedExportsPattern: { type: "string" },
|
|
},
|
|
additionalProperties: false,
|
|
},
|
|
{
|
|
type: "object",
|
|
properties: {
|
|
restrictedNamedExports: {
|
|
type: "array",
|
|
items: {
|
|
type: "string",
|
|
pattern: "^(?!default$)",
|
|
},
|
|
uniqueItems: true,
|
|
},
|
|
restrictedNamedExportsPattern: { type: "string" },
|
|
restrictDefaultExports: {
|
|
type: "object",
|
|
properties: {
|
|
// Allow/Disallow `export default foo; export default 42; export default function foo() {}` format
|
|
direct: {
|
|
type: "boolean",
|
|
},
|
|
|
|
// Allow/Disallow `export { foo as default };` declarations
|
|
named: {
|
|
type: "boolean",
|
|
},
|
|
|
|
// Allow/Disallow `export { default } from "mod"; export { default as default } from "mod";` declarations
|
|
defaultFrom: {
|
|
type: "boolean",
|
|
},
|
|
|
|
// Allow/Disallow `export { foo as default } from "mod";` declarations
|
|
namedFrom: {
|
|
type: "boolean",
|
|
},
|
|
|
|
// Allow/Disallow `export * as default from "mod"`; declarations
|
|
namespaceFrom: {
|
|
type: "boolean",
|
|
},
|
|
},
|
|
additionalProperties: false,
|
|
},
|
|
},
|
|
additionalProperties: false,
|
|
},
|
|
],
|
|
},
|
|
],
|
|
|
|
messages: {
|
|
restrictedNamed:
|
|
"'{{name}}' is restricted from being used as an exported name.",
|
|
restrictedDefault: "Exporting 'default' is restricted.",
|
|
},
|
|
},
|
|
|
|
create(context) {
|
|
const restrictedNames = new Set(
|
|
context.options[0] && context.options[0].restrictedNamedExports,
|
|
);
|
|
const restrictedNamePattern =
|
|
context.options[0] &&
|
|
context.options[0].restrictedNamedExportsPattern;
|
|
const restrictDefaultExports =
|
|
context.options[0] && context.options[0].restrictDefaultExports;
|
|
const sourceCode = context.sourceCode;
|
|
|
|
/**
|
|
* Checks and reports given exported name.
|
|
* @param {ASTNode} node exported `Identifier` or string `Literal` node to check.
|
|
* @returns {void}
|
|
*/
|
|
function checkExportedName(node) {
|
|
const name = astUtils.getModuleExportName(node);
|
|
|
|
let matchesRestrictedNamePattern = false;
|
|
|
|
if (restrictedNamePattern && name !== "default") {
|
|
const patternRegex = new RegExp(restrictedNamePattern, "u");
|
|
|
|
matchesRestrictedNamePattern = patternRegex.test(name);
|
|
}
|
|
|
|
if (matchesRestrictedNamePattern || restrictedNames.has(name)) {
|
|
context.report({
|
|
node,
|
|
messageId: "restrictedNamed",
|
|
data: { name },
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (name === "default") {
|
|
if (node.parent.type === "ExportAllDeclaration") {
|
|
if (
|
|
restrictDefaultExports &&
|
|
restrictDefaultExports.namespaceFrom
|
|
) {
|
|
context.report({
|
|
node,
|
|
messageId: "restrictedDefault",
|
|
});
|
|
}
|
|
} else {
|
|
// ExportSpecifier
|
|
const isSourceSpecified = !!node.parent.parent.source;
|
|
const specifierLocalName = astUtils.getModuleExportName(
|
|
node.parent.local,
|
|
);
|
|
|
|
if (
|
|
!isSourceSpecified &&
|
|
restrictDefaultExports &&
|
|
restrictDefaultExports.named
|
|
) {
|
|
context.report({
|
|
node,
|
|
messageId: "restrictedDefault",
|
|
});
|
|
return;
|
|
}
|
|
|
|
if (isSourceSpecified && restrictDefaultExports) {
|
|
if (
|
|
(specifierLocalName === "default" &&
|
|
restrictDefaultExports.defaultFrom) ||
|
|
(specifierLocalName !== "default" &&
|
|
restrictDefaultExports.namedFrom)
|
|
) {
|
|
context.report({
|
|
node,
|
|
messageId: "restrictedDefault",
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return {
|
|
ExportAllDeclaration(node) {
|
|
if (node.exported) {
|
|
checkExportedName(node.exported);
|
|
}
|
|
},
|
|
|
|
ExportDefaultDeclaration(node) {
|
|
if (restrictDefaultExports && restrictDefaultExports.direct) {
|
|
context.report({
|
|
node,
|
|
messageId: "restrictedDefault",
|
|
});
|
|
}
|
|
},
|
|
|
|
ExportNamedDeclaration(node) {
|
|
const declaration = node.declaration;
|
|
|
|
if (declaration) {
|
|
if (
|
|
declaration.type === "FunctionDeclaration" ||
|
|
declaration.type === "ClassDeclaration"
|
|
) {
|
|
checkExportedName(declaration.id);
|
|
} else if (declaration.type === "VariableDeclaration") {
|
|
sourceCode
|
|
.getDeclaredVariables(declaration)
|
|
.map(v =>
|
|
v.defs.find(d => d.parent === declaration),
|
|
)
|
|
.map(d => d.name) // Identifier nodes
|
|
.forEach(checkExportedName);
|
|
}
|
|
} else {
|
|
node.specifiers
|
|
.map(s => s.exported)
|
|
.forEach(checkExportedName);
|
|
}
|
|
},
|
|
};
|
|
},
|
|
};
|