requireProperty.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc.js"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. var _default = exports.default = (0, _iterateJsdoc.default)(({
  9. utils
  10. }) => {
  11. const propertyAssociatedTags = utils.filterTags(({
  12. tag
  13. }) => {
  14. return ['typedef', 'namespace'].includes(tag);
  15. });
  16. if (!propertyAssociatedTags.length) {
  17. return;
  18. }
  19. const targetTagName = /** @type {string} */utils.getPreferredTagName({
  20. tagName: 'property'
  21. });
  22. if (utils.hasATag([targetTagName])) {
  23. return;
  24. }
  25. for (const propertyAssociatedTag of propertyAssociatedTags) {
  26. if (!['object', 'Object', 'PlainObject'].includes(propertyAssociatedTag.type)) {
  27. continue;
  28. }
  29. utils.reportJSDoc(`Missing JSDoc @${targetTagName}.`, null, () => {
  30. utils.addTag(targetTagName);
  31. });
  32. }
  33. }, {
  34. iterateAllJsdocs: true,
  35. meta: {
  36. docs: {
  37. description: 'Requires that all `@typedef` and `@namespace` tags have `@property` when their type is a plain `object`, `Object`, or `PlainObject`.',
  38. url: 'https://github.com/gajus/eslint-plugin-jsdoc/blob/main/docs/rules/require-property.md#repos-sticky-header'
  39. },
  40. fixable: 'code',
  41. type: 'suggestion'
  42. }
  43. });
  44. module.exports = exports.default;
  45. //# sourceMappingURL=requireProperty.js.map