UNPKG

@inngest/eslint-plugin

Version:

An ESLint plugin and config for [`inngest`](/packages/inngest/).

42 lines (41 loc) 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.awaitInngestSend = void 0; const utils_1 = require("@typescript-eslint/utils"); // Thanks, Max from https://gowindmill.com/ exports.awaitInngestSend = { meta: { type: "suggestion", docs: { description: "enforce `await`, `return`, or `void` before `inngest.send()`", recommended: "recommended", }, schema: [], // no options messages: { "await-inngest-send": "You should use `await`, `return`, or `void` before `inngest.send().", }, }, defaultOptions: [], create(context) { return { CallExpression(node) { if (node.callee.type === utils_1.AST_NODE_TYPES.MemberExpression && node.callee.object.type === utils_1.AST_NODE_TYPES.Identifier && node.callee.object.name === "inngest" && node.callee.property.type === utils_1.AST_NODE_TYPES.Identifier && node.callee.property.name === "send") { const parent = node.parent; if (parent.type !== utils_1.AST_NODE_TYPES.AwaitExpression && parent.type !== utils_1.AST_NODE_TYPES.ReturnStatement && (parent.type !== utils_1.AST_NODE_TYPES.UnaryExpression || parent.operator !== "void")) { context.report({ node, messageId: "await-inngest-send", }); } } }, }; }, };