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.
159 lines
3.8 KiB
JavaScript
159 lines
3.8 KiB
JavaScript
/**
|
|
* @fileoverview Rule to disallow unused labels.
|
|
* @author Toru Nagashima
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Requirements
|
|
//------------------------------------------------------------------------------
|
|
|
|
const astUtils = require("./utils/ast-utils");
|
|
|
|
//------------------------------------------------------------------------------
|
|
// Rule Definition
|
|
//------------------------------------------------------------------------------
|
|
|
|
/** @type {import('../types').Rule.RuleModule} */
|
|
module.exports = {
|
|
meta: {
|
|
type: "suggestion",
|
|
|
|
docs: {
|
|
description: "Disallow unused labels",
|
|
recommended: true,
|
|
url: "https://eslint.org/docs/latest/rules/no-unused-labels",
|
|
},
|
|
|
|
schema: [],
|
|
|
|
fixable: "code",
|
|
|
|
messages: {
|
|
unused: "'{{name}}:' is defined but never used.",
|
|
},
|
|
},
|
|
|
|
create(context) {
|
|
const sourceCode = context.sourceCode;
|
|
let scopeInfo = null;
|
|
|
|
/**
|
|
* Adds a scope info to the stack.
|
|
* @param {ASTNode} node A node to add. This is a LabeledStatement.
|
|
* @returns {void}
|
|
*/
|
|
function enterLabeledScope(node) {
|
|
scopeInfo = {
|
|
label: node.label.name,
|
|
used: false,
|
|
upper: scopeInfo,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Checks if a `LabeledStatement` node is fixable.
|
|
* For a node to be fixable, there must be no comments between the label and the body.
|
|
* Furthermore, is must be possible to remove the label without turning the body statement into a
|
|
* directive after other fixes are applied.
|
|
* @param {ASTNode} node The node to evaluate.
|
|
* @returns {boolean} Whether or not the node is fixable.
|
|
*/
|
|
function isFixable(node) {
|
|
/*
|
|
* Only perform a fix if there are no comments between the label and the body. This will be the case
|
|
* when there is exactly one token/comment (the ":") between the label and the body.
|
|
*/
|
|
if (
|
|
sourceCode.getTokenAfter(node.label, {
|
|
includeComments: true,
|
|
}) !==
|
|
sourceCode.getTokenBefore(node.body, { includeComments: true })
|
|
) {
|
|
return false;
|
|
}
|
|
|
|
// Looking for the node's deepest ancestor which is not a `LabeledStatement`.
|
|
let ancestor = node.parent;
|
|
|
|
while (ancestor.type === "LabeledStatement") {
|
|
ancestor = ancestor.parent;
|
|
}
|
|
|
|
if (
|
|
ancestor.type === "Program" ||
|
|
(ancestor.type === "BlockStatement" &&
|
|
astUtils.isFunction(ancestor.parent))
|
|
) {
|
|
const { body } = node;
|
|
|
|
if (
|
|
body.type === "ExpressionStatement" &&
|
|
((body.expression.type === "Literal" &&
|
|
typeof body.expression.value === "string") ||
|
|
astUtils.isStaticTemplateLiteral(body.expression))
|
|
) {
|
|
return false; // potential directive
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Removes the top of the stack.
|
|
* At the same time, this reports the label if it's never used.
|
|
* @param {ASTNode} node A node to report. This is a LabeledStatement.
|
|
* @returns {void}
|
|
*/
|
|
function exitLabeledScope(node) {
|
|
if (!scopeInfo.used) {
|
|
context.report({
|
|
node: node.label,
|
|
messageId: "unused",
|
|
data: node.label,
|
|
fix: isFixable(node)
|
|
? fixer =>
|
|
fixer.removeRange([
|
|
node.range[0],
|
|
node.body.range[0],
|
|
])
|
|
: null,
|
|
});
|
|
}
|
|
|
|
scopeInfo = scopeInfo.upper;
|
|
}
|
|
|
|
/**
|
|
* Marks the label of a given node as used.
|
|
* @param {ASTNode} node A node to mark. This is a BreakStatement or
|
|
* ContinueStatement.
|
|
* @returns {void}
|
|
*/
|
|
function markAsUsed(node) {
|
|
if (!node.label) {
|
|
return;
|
|
}
|
|
|
|
const label = node.label.name;
|
|
let info = scopeInfo;
|
|
|
|
while (info) {
|
|
if (info.label === label) {
|
|
info.used = true;
|
|
break;
|
|
}
|
|
info = info.upper;
|
|
}
|
|
}
|
|
|
|
return {
|
|
LabeledStatement: enterLabeledScope,
|
|
"LabeledStatement:exit": exitLabeledScope,
|
|
BreakStatement: markAsUsed,
|
|
ContinueStatement: markAsUsed,
|
|
};
|
|
},
|
|
};
|