Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

requireYieldsCheck.js 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. const canSkip = (utils, settings) => {
  9. const voidingTags = [// An abstract function is by definition incomplete
  10. // so it is perfectly fine if a yield is documented but
  11. // not present within the function.
  12. // A subclass may inherit the doc and implement the
  13. // missing yield.
  14. 'abstract', 'virtual', // Constructor functions do not have a yield value
  15. // so we can bail here, too.
  16. 'class', 'constructor', // This seems to imply a class as well
  17. 'interface'];
  18. if (settings.mode === 'closure') {
  19. // Structural Interface in GCC terms, equivalent to @interface tag as far as this rule is concerned
  20. voidingTags.push('record');
  21. }
  22. return utils.hasATag(voidingTags) || utils.isConstructor() || utils.classHasTag('interface') || settings.mode === 'closure' && utils.classHasTag('record');
  23. };
  24. const checkTagName = (utils, report, tagName) => {
  25. const preferredTagName = utils.getPreferredTagName({
  26. tagName
  27. });
  28. if (!preferredTagName) {
  29. return [];
  30. }
  31. const tags = utils.getTags(preferredTagName);
  32. if (tags.length === 0) {
  33. return [];
  34. }
  35. if (tags.length > 1) {
  36. report(`Found more than one @${preferredTagName} declaration.`);
  37. return [];
  38. }
  39. return [preferredTagName, tags[0]];
  40. };
  41. var _default = (0, _iterateJsdoc.default)(({
  42. context,
  43. report,
  44. settings,
  45. utils
  46. }) => {
  47. if (canSkip(utils, settings)) {
  48. return;
  49. }
  50. const {
  51. next = false,
  52. checkGeneratorsOnly = false
  53. } = context.options[0] || {};
  54. const [preferredYieldTagName, yieldTag] = checkTagName(utils, report, 'yields');
  55. if (preferredYieldTagName) {
  56. const shouldReportYields = () => {
  57. if (checkGeneratorsOnly && !utils.isGenerator()) {
  58. return true;
  59. }
  60. return utils.hasDefinedTypeTag(yieldTag) && !utils.hasYieldValue();
  61. }; // In case a yield value is declared in JSDoc, we also expect one in the code.
  62. if (shouldReportYields()) {
  63. report(`JSDoc @${preferredYieldTagName} declaration present but yield expression not available in function.`);
  64. }
  65. }
  66. if (next) {
  67. const [preferredNextTagName, nextTag] = checkTagName(utils, report, 'next');
  68. if (preferredNextTagName) {
  69. const shouldReportNext = () => {
  70. if (checkGeneratorsOnly && !utils.isGenerator()) {
  71. return true;
  72. }
  73. return utils.hasDefinedTypeTag(nextTag) && !utils.hasYieldReturnValue();
  74. };
  75. if (shouldReportNext()) {
  76. report(`JSDoc @${preferredNextTagName} declaration present but yield expression with return value not available in function.`);
  77. }
  78. }
  79. }
  80. }, {
  81. meta: {
  82. docs: {
  83. description: 'Requires a yield statement in function body if a `@yields` tag is specified in jsdoc comment.',
  84. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-yields-check'
  85. },
  86. schema: [{
  87. additionalProperties: false,
  88. properties: {
  89. checkGeneratorsOnly: {
  90. default: false,
  91. type: 'boolean'
  92. },
  93. contexts: {
  94. items: {
  95. anyOf: [{
  96. type: 'string'
  97. }, {
  98. additionalProperties: false,
  99. properties: {
  100. comment: {
  101. type: 'string'
  102. },
  103. context: {
  104. type: 'string'
  105. }
  106. },
  107. type: 'object'
  108. }]
  109. },
  110. type: 'array'
  111. },
  112. exemptedBy: {
  113. items: {
  114. type: 'string'
  115. },
  116. type: 'array'
  117. },
  118. next: {
  119. default: false,
  120. type: 'boolean'
  121. }
  122. },
  123. type: 'object'
  124. }],
  125. type: 'suggestion'
  126. }
  127. });
  128. exports.default = _default;
  129. module.exports = exports.default;
  130. //# sourceMappingURL=requireYieldsCheck.js.map