History

Ban Effect escape hatches

Rhys Sullivan committed 6 months ago

Commit 427d4e21 parent 10d34f84 files · +57 −0Browse files

Showing the changes to scripts/oxlint-plugin-executor (1 of 4 files). Show all

Unified · Split

scripts/oxlint-plugin-executor/rules/no-effect-escape-hatch.js+33−0
@@ -0,0 +1,33 @@
1import { getPropertyName, isTestLike, unwrapExpression } from "../utils.js";
2
3const escapeHatches = new Set(["die", "dieMessage", "orDie", "orDieWith"]);
4
5const message =
6 "Do not collapse Effect failures with die/orDie escape hatches. Keep typed errors in the Effect error channel; at true runtime edges use a narrow boundary suppression. Skill: wrdn-effect-typed-errors.";
7
8const isEffectEscapeHatch = (node) => {
9 const expression = unwrapExpression(node);
10 if (expression?.type !== "MemberExpression") return false;
11 const property = getPropertyName(expression.property);
12 return escapeHatches.has(property);
13};
14
15export default {
16 meta: {
17 type: "problem",
18 docs: {
19 description: "Disallow Effect die/orDie escape hatches outside test code.",
20 },
21 },
22 create(context) {
23 if (isTestLike(context.filename)) return {};
24
25 return {
26 MemberExpression(node) {
27 if (isEffectEscapeHatch(node)) {
28 context.report({ node, message });
29 }
30 },
31 };
32 },
33};