Showing the changes to scripts/oxlint-plugin-executor (1 of 4 files). Show all
Unified · Split
| @@ -0,0 +1,33 @@ | ||
| 1 | +import { getPropertyName, isTestLike, unwrapExpression } from "../utils.js"; | |
| 2 | + | |
| 3 | +const escapeHatches = new Set(["die", "dieMessage", "orDie", "orDieWith"]); | |
| 4 | + | |
| 5 | +const 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 | + | |
| 8 | +const 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 | + | |
| 15 | +export 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 | +}; | |