@inngest/eslint-plugin
Version:
An ESLint plugin and config for [`inngest`](/packages/inngest/).
44 lines (43 loc) • 1.55 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.noNestedSteps = void 0;
const utils_1 = require("@typescript-eslint/utils");
exports.noNestedSteps = {
meta: {
type: "problem",
docs: {
description: "disallow use of any `step.*` within another `step.*` function",
recommended: "recommended",
},
schema: [], // no options
messages: {
"no-nested-steps": "Use of `step.*` within another `step.*` function is not allowed",
},
},
defaultOptions: [],
create(context) {
let stepDepth = 0;
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 === "step") {
if (stepDepth > 0) {
context.report({
node,
messageId: "no-nested-steps",
});
}
stepDepth++;
}
},
"CallExpression:exit"(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 === "step") {
stepDepth--;
}
},
};
},
};
;