{"version":3,"file":"requireRejects.cjs","names":["_iterateJsdoc","_interopRequireDefault","require","e","__esModule","default","hasRejectValue","node","innerFunction","isAsync","type","innerIsAsync","async","body","some","bodyNode","callee","object","name","property","expression","consequent","alternate","arguments","length","executor","argument","cases","someCase","nde","handler","finalizer","canSkip","utils","hasATag","avoidDocs","_default","exports","iterateJsdoc","report","tagName","getPreferredTagName","tags","getTags","iteratingFunction","isIteratingFunction","tag","missingRejectsTag","shouldReport","contextDefaults","meta","docs","description","url","schema","additionalProperties","properties","contexts","items","anyOf","comment","context","exemptedBy","module"],"sources":["../../src/rules/requireRejects.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * Checks if a node or its children contain Promise rejection patterns\n * @param {import('eslint').Rule.Node} node\n * @param {boolean} [innerFunction]\n * @param {boolean} [isAsync]\n * @returns {boolean}\n */\n// eslint-disable-next-line complexity -- Temporary\nconst hasRejectValue = (node, innerFunction, isAsync) => {\n  if (!node) {\n    return false;\n  }\n\n  switch (node.type) {\n    case 'ArrowFunctionExpression':\n    case 'FunctionDeclaration':\n    case 'FunctionExpression': {\n      // For inner functions in async contexts, check if they throw\n      // (they could be called and cause rejection)\n      if (innerFunction) {\n        // Check inner functions for throws - if called from async context, throws become rejections\n        const innerIsAsync = node.async;\n        // Pass isAsync=true if the inner function is async OR if we're already in an async context\n        return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), false, innerIsAsync || isAsync);\n      }\n\n      // This is the top-level function we're checking\n      return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), true, node.async);\n    }\n\n    case 'BlockStatement': {\n      return node.body.some((bodyNode) => {\n        return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (bodyNode), innerFunction, isAsync);\n      });\n    }\n\n    case 'CallExpression': {\n      // Check for Promise.reject()\n      if (node.callee.type === 'MemberExpression' &&\n          node.callee.object.type === 'Identifier' &&\n          node.callee.object.name === 'Promise' &&\n          node.callee.property.type === 'Identifier' &&\n          node.callee.property.name === 'reject') {\n        return true;\n      }\n\n      // Check for reject() call (in Promise executor context)\n      if (node.callee.type === 'Identifier' && node.callee.name === 'reject') {\n        return true;\n      }\n\n      // Check if this is calling an inner function that might reject\n      if (innerFunction && node.callee.type === 'Identifier') {\n        // We found a function call inside - check if it could be calling a function that rejects\n        // We'll handle this in function body traversal\n        return false;\n      }\n\n      return false;\n    }\n\n    case 'DoWhileStatement':\n    case 'ForInStatement':\n    case 'ForOfStatement':\n    case 'ForStatement':\n    case 'LabeledStatement':\n    case 'WhileStatement':\n\n    case 'WithStatement': {\n      return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.body), innerFunction, isAsync);\n    }\n\n    case 'ExpressionStatement': {\n      return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.expression), innerFunction, isAsync);\n    }\n\n    case 'IfStatement': {\n      return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.consequent), innerFunction, isAsync) || hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.alternate), innerFunction, isAsync);\n    }\n\n    case 'NewExpression': {\n      // Check for new Promise((resolve, reject) => { reject(...) })\n      if (node.callee.type === 'Identifier' && node.callee.name === 'Promise' && node.arguments.length > 0) {\n        const executor = node.arguments[0];\n        if (executor.type === 'ArrowFunctionExpression' || executor.type === 'FunctionExpression') {\n          // Check if the executor has reject() calls\n          return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (executor.body), false, false);\n        }\n      }\n\n      return false;\n    }\n\n    case 'ReturnStatement': {\n      if (node.argument) {\n        return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.argument), innerFunction, isAsync);\n      }\n\n      return false;\n    }\n\n    case 'SwitchStatement': {\n      return node.cases.some(\n        (someCase) => {\n          return someCase.consequent.some((nde) => {\n            return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (nde), innerFunction, isAsync);\n          });\n        },\n      );\n    }\n\n    // Throw statements in async functions become rejections\n    case 'ThrowStatement': {\n      return isAsync === true;\n    }\n\n    case 'TryStatement': {\n      return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.handler && node.handler.body), innerFunction, isAsync) ||\n        hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node.finalizer), innerFunction, isAsync);\n    }\n\n    default: {\n      return false;\n    }\n  }\n};\n\n/**\n * We can skip checking for a rejects value, in case the documentation is inherited\n * or the method is abstract.\n * @param {import('../iterateJsdoc.js').Utils} utils\n * @returns {boolean}\n */\nconst canSkip = (utils) => {\n  return utils.hasATag([\n    'abstract',\n    'virtual',\n    'type',\n  ]) ||\n    utils.avoidDocs();\n};\n\nexport default iterateJsdoc(({\n  node,\n  report,\n  utils,\n}) => {\n  if (canSkip(utils)) {\n    return;\n  }\n\n  const tagName = /** @type {string} */ (utils.getPreferredTagName({\n    tagName: 'rejects',\n  }));\n  if (!tagName) {\n    return;\n  }\n\n  const tags = utils.getTags(tagName);\n  const iteratingFunction = utils.isIteratingFunction();\n\n  const [\n    tag,\n  ] = tags;\n  const missingRejectsTag = typeof tag === 'undefined' || tag === null;\n\n  const shouldReport = () => {\n    if (!missingRejectsTag) {\n      return false;\n    }\n\n    // Check if this is an async function or returns a Promise\n    const isAsync = utils.isAsync();\n    if (!isAsync && !iteratingFunction) {\n      return false;\n    }\n\n    // For async functions, check for throw statements\n    // For regular functions, check for Promise.reject or reject calls\n    return hasRejectValue(/** @type {import('eslint').Rule.Node} */ (node));\n  };\n\n  if (shouldReport()) {\n    report('Promise-rejecting function requires `@rejects` tag');\n  }\n}, {\n  contextDefaults: true,\n  meta: {\n    docs: {\n      description: 'Requires that Promise rejections are documented with `@rejects` tags.',\n      url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-rejects.md#repos-sticky-header',\n    },\n    schema: [\n      {\n        additionalProperties: false,\n        properties: {\n          contexts: {\n            description: `Set this to an array of strings representing the AST context\n(or objects with optional \\`context\\` and \\`comment\\` properties) where you wish\nthe rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nOverrides the default contexts (\\`ArrowFunctionExpression\\`, \\`FunctionDeclaration\\`,\n\\`FunctionExpression\\`).`,\n            items: {\n              anyOf: [\n                {\n                  type: 'string',\n                },\n                {\n                  additionalProperties: false,\n                  properties: {\n                    comment: {\n                      type: 'string',\n                    },\n                    context: {\n                      type: 'string',\n                    },\n                  },\n                  type: 'object',\n                },\n              ],\n            },\n            type: 'array',\n          },\n          exemptedBy: {\n            description: `Array of tags (e.g., \\`['type']\\`) whose presence on the\ndocument block avoids the need for a \\`@rejects\\`. Defaults to an array\nwith \\`abstract\\`, \\`virtual\\`, and \\`type\\`. If you set this array, it will overwrite the default,\nso be sure to add back those tags if you wish their presence to cause\nexemption of the rule.`,\n            items: {\n              type: 'string',\n            },\n            type: 'array',\n          },\n        },\n        type: 'object',\n      },\n    ],\n    type: 'suggestion',\n  },\n});\n"],"mappings":";;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA8C,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAGA,CAACC,IAAI,EAAEC,aAAa,EAAEC,OAAO,KAAK;EACvD,IAAI,CAACF,IAAI,EAAE;IACT,OAAO,KAAK;EACd;EAEA,QAAQA,IAAI,CAACG,IAAI;IACf,KAAK,yBAAyB;IAC9B,KAAK,qBAAqB;IAC1B,KAAK,oBAAoB;MAAE;QACzB;QACA;QACA,IAAIF,aAAa,EAAE;UACjB;UACA,MAAMG,YAAY,GAAGJ,IAAI,CAACK,KAAK;UAC/B;UACA,OAAON,cAAc,CAAC,yCAA2CC,IAAI,CAACM,IAAI,EAAG,KAAK,EAAEF,YAAY,IAAIF,OAAO,CAAC;QAC9G;;QAEA;QACA,OAAOH,cAAc,CAAC,yCAA2CC,IAAI,CAACM,IAAI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