fix(core): Reject empty webhookMethods in community lint rule (#29474)

This commit is contained in:
Chris Z
2026-05-04 07:11:24 +00:00
committed by GitHub
parent 45c18fb09c
commit 34d7a02df7
2 changed files with 15 additions and 0 deletions
@@ -107,6 +107,11 @@ export class RegularClass {
code: createTriggerNode({ webhookMethods: null }),
errors: [{ messageId: 'missingWebhookMethods' }],
},
{
name: 'trigger node with empty webhookMethods object (no lifecycle groups)',
code: createTriggerNode({ webhookMethods: '{}' }),
errors: [{ messageId: 'emptyWebhookMethods' }],
},
{
name: 'trigger node with empty webhookMethods group (all three missing)',
code: createTriggerNode({
@@ -56,6 +56,8 @@ export const WebhookLifecycleCompleteRule = createRule({
messages: {
missingWebhookMethods:
'Webhook trigger node is missing the `webhookMethods` property. Implement `checkExists`, `create`, and `delete` to register, verify, and clean up the webhook on the third-party service.',
emptyWebhookMethods:
'Webhook trigger node has an empty `webhookMethods` object. Define at least one lifecycle group with `checkExists`, `create`, and `delete` methods.',
missingLifecycleMethod:
'Webhook trigger lifecycle is incomplete. `webhookMethods.{{group}}` is missing: {{missing}}. All of `checkExists`, `create`, and `delete` must be implemented.',
},
@@ -91,6 +93,14 @@ export const WebhookLifecycleCompleteRule = createRule({
return;
}
if (webhookMethodsProperty.value.properties.length === 0) {
context.report({
node: webhookMethodsProperty.key,
messageId: 'emptyWebhookMethods',
});
return;
}
for (const groupProperty of webhookMethodsProperty.value.properties) {
if (groupProperty.type !== AST_NODE_TYPES.Property) continue;
if (groupProperty.value.type !== AST_NODE_TYPES.ObjectExpression) continue;