"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _lodash = _interopRequireDefault(require("lodash")); var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc")); var _warnRemovedSettings = _interopRequireDefault(require("../warnRemovedSettings")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var _default = (0, _iterateJsdoc.default)(({ jsdoc, report, utils, context }) => { (0, _warnRemovedSettings.default)(context, 'require-example'); if (utils.avoidDocs()) { return; } const _ref = context.options[0] || {}, _ref$avoidExampleOnCo = _ref.avoidExampleOnConstructors, avoidExampleOnConstructors = _ref$avoidExampleOnCo === void 0 ? false : _ref$avoidExampleOnCo; const targetTagName = 'example'; const functionExamples = _lodash.default.filter(jsdoc.tags, { tag: targetTagName }); if (avoidExampleOnConstructors && (utils.hasATag(['class', 'constructor']) || utils.isConstructor())) { return; } if (!functionExamples.length) { utils.reportJSDoc(`Missing JSDoc @${targetTagName} declaration.`, null, () => { if (!jsdoc.tags) { jsdoc.tags = []; } const line = jsdoc.tags.length ? jsdoc.tags[jsdoc.tags.length - 1].line + 1 : 0; jsdoc.tags.push({ description: '', line, name: '', optional: false, tag: targetTagName, type: '' }); }); return; } functionExamples.forEach(example => { const exampleContent = _lodash.default.compact(`${example.name} ${example.description}`.trim().split('\n')); if (!exampleContent.length) { report(`Missing JSDoc @${targetTagName} description.`); } }); }, { contextDefaults: true, meta: { fixable: 'code', schema: [{ additionalProperties: false, properties: { avoidExampleOnConstructors: { default: false, type: 'boolean' }, contexts: { items: { type: 'string' }, type: 'array' }, exemptedBy: { items: { type: 'string' }, type: 'array' } }, type: 'object' }], type: 'suggestion' } }); exports.default = _default; module.exports = exports.default; //# sourceMappingURL=requireExample.js.map