{"version":3,"file":"noMissingSyntax.cjs","names":["iterateJsdoc"],"sources":["../../src/rules/noMissingSyntax.js"],"sourcesContent":["import iterateJsdoc from '../iterateJsdoc.js';\n\n/**\n * @typedef {{\n *   comment: string,\n *   context: string,\n *   message: string,\n *   minimum: import('../iterateJsdoc.js').Integer\n * }} ContextObject\n */\n\n/**\n * @typedef {string|ContextObject} Context\n */\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @returns {void}\n */\nconst setDefaults = (state) => {\n  if (!state.selectorMap) {\n    state.selectorMap = {};\n  }\n};\n\n/**\n * @param {import('../iterateJsdoc.js').StateObject} state\n * @param {string} selector\n * @param {string} comment\n * @returns {void}\n */\nconst incrementSelector = (state, selector, comment) => {\n  if (!state.selectorMap[selector]) {\n    state.selectorMap[selector] = {};\n  }\n\n  if (!state.selectorMap[selector][comment]) {\n    state.selectorMap[selector][comment] = 0;\n  }\n\n  state.selectorMap[selector][comment]++;\n};\n\nexport default iterateJsdoc(({\n  context,\n  info: {\n    comment,\n  },\n  state,\n  utils,\n}) => {\n  if (!context.options[0]) {\n    // Handle error later\n    return;\n  }\n\n  /**\n   * @type {Context[]}\n   */\n  const contexts = context.options[0].contexts;\n\n  const {\n    contextStr,\n  } = utils.findContext(contexts, comment);\n\n  setDefaults(state);\n\n  incrementSelector(state, contextStr, String(comment));\n}, {\n  contextSelected: true,\n  exit ({\n    context,\n    settings,\n    state,\n  }) {\n    if (!context.options.length && !settings.contexts) {\n      context.report({\n        loc: {\n          end: {\n            column: 1,\n            line: 1,\n          },\n          start: {\n            column: 1,\n            line: 1,\n          },\n        },\n        message: 'Rule `no-missing-syntax` is missing a `contexts` option.',\n      });\n\n      return;\n    }\n\n    setDefaults(state);\n\n    /**\n     * @type {Context[]}\n     */\n    const contexts = (context.options[0] ?? {}).contexts ?? settings?.contexts;\n\n    // Report when MISSING\n    contexts.some((cntxt) => {\n      const contextStr = typeof cntxt === 'object' ? cntxt.context ?? 'any' : cntxt;\n      const comment = typeof cntxt === 'string' ? '' : cntxt?.comment ?? '';\n\n      const contextKey = contextStr === 'any' ? 'undefined' : contextStr;\n\n      if (\n        (!state.selectorMap[contextKey] ||\n        !state.selectorMap[contextKey][comment] ||\n        state.selectorMap[contextKey][comment] < (\n          // @ts-expect-error comment would need an object, not string\n          cntxt?.minimum ?? 1\n        )) &&\n        (contextStr !== 'any' || Object.values(state.selectorMap).every((cmmnt) => {\n          return !cmmnt[comment] || cmmnt[comment] < (\n            // @ts-expect-error comment would need an object, not string\n            cntxt?.minimum ?? 1\n          );\n        }))\n      ) {\n        const message = typeof cntxt === 'string' ?\n          'Syntax is required: {{context}}' :\n          cntxt?.message ?? ('Syntax is required: {{context}}' +\n            (comment ? ' with {{comment}}' : ''));\n        context.report({\n          data: {\n            comment,\n            context: contextStr,\n          },\n          loc: {\n            end: {\n              column: 1,\n              line: 1,\n            },\n            start: {\n              column: 1,\n              line: 1,\n            },\n          },\n          message,\n        });\n\n        return true;\n      }\n\n      return false;\n    });\n  },\n  matchContext: true,\n  meta: {\n    docs: {\n      description: 'Reports when certain comment structures are always expected.',\n      url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/no-missing-syntax.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 (or an object with\noptional \\`context\\` and \\`comment\\` properties) where you wish the rule to be applied.\n\n\\`context\\` defaults to \\`any\\` and \\`comment\\` defaults to no specific comment context.\n\nUse the \\`minimum\\` property (defaults to 1) to indicate how many are required\nfor the rule to be reported.\n\nUse the \\`message\\` property to indicate the specific error to be shown when an\nerror is reported for that context being found missing. You may use\n\\`{{context}}\\` and \\`{{comment}}\\` with such messages. Defaults to\n\\`\"Syntax is required: {{context}}\"\\`, or with a comment, to\n\\`\"Syntax is required: {{context}} with {{comment}}\"\\`.\n\nSet to \\`\"any\"\\` if you want the rule to apply to any JSDoc block throughout\nyour files (as is necessary for finding function blocks not attached to a\nfunction declaration or expression, i.e., \\`@callback\\` or \\`@function\\` (or its\naliases \\`@func\\` or \\`@method\\`) (including those associated with an \\`@interface\\`).\n\nSee the [\"AST and Selectors\"](../advanced.md#ast-and-selectors)\nsection of our Advanced docs for more on the expected format.`,\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                    message: {\n                      type: 'string',\n                    },\n                    minimum: {\n                      type: 'integer',\n                    },\n                  },\n                  type: 'object',\n                },\n              ],\n            },\n            type: 'array',\n          },\n        },\n        type: 'object',\n      },\n    ],\n    type: 'suggestion',\n  },\n});\n"],"mappings":";;;;;;AAAA;AAA8C;AAE9C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA,MAAM,WAAW,GAAI,KAAK,IAAK;EAC7B,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE;IACtB,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC;EACxB;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,KAAK;EACtD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE;IAChC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;EAClC;EAEA,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE;IACzC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;EAC1C;EAEA,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,EAAE;AACxC,CAAC;AAAC,iCAEa,IAAAA,qBAAY,EAAC,CAAC;EAC3B,OAAO;EACP,IAAI,EAAE;IACJ;EACF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