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.

requireFileOverview.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 defaultTags = {
  9. file: {
  10. initialCommentsOnly: true,
  11. mustExist: true,
  12. preventDuplicates: true
  13. }
  14. };
  15. const setDefaults = state => {
  16. // First iteration
  17. if (!state.globalTags) {
  18. state.globalTags = {};
  19. state.hasDuplicates = {};
  20. state.hasTag = {};
  21. state.hasNonCommentBeforeTag = {};
  22. }
  23. };
  24. var _default = (0, _iterateJsdoc.default)(({
  25. jsdocNode,
  26. state,
  27. utils,
  28. context
  29. }) => {
  30. const {
  31. tags = defaultTags
  32. } = context.options[0] || {};
  33. setDefaults(state);
  34. for (const tagName of Object.keys(tags)) {
  35. const targetTagName = utils.getPreferredTagName({
  36. tagName
  37. });
  38. const hasTag = targetTagName && utils.hasTag(targetTagName);
  39. state.hasTag[tagName] = hasTag || state.hasTag[tagName];
  40. const hasDuplicate = state.hasDuplicates[tagName];
  41. if (hasDuplicate === false) {
  42. // Was marked before, so if a tag now, is a dupe
  43. state.hasDuplicates[tagName] = hasTag;
  44. } else if (!hasDuplicate && hasTag) {
  45. // No dupes set before, but has first tag, so change state
  46. // from `undefined` to `false` so can detect next time
  47. state.hasDuplicates[tagName] = false;
  48. state.hasNonCommentBeforeTag[tagName] = state.hasNonComment && state.hasNonComment < jsdocNode.range[0];
  49. }
  50. }
  51. }, {
  52. exit({
  53. context,
  54. state,
  55. utils
  56. }) {
  57. setDefaults(state);
  58. const {
  59. tags = defaultTags
  60. } = context.options[0] || {};
  61. for (const [tagName, {
  62. mustExist = false,
  63. preventDuplicates = false,
  64. initialCommentsOnly = false
  65. }] of Object.entries(tags)) {
  66. const obj = utils.getPreferredTagNameObject({
  67. tagName
  68. });
  69. if (obj && obj.blocked) {
  70. utils.reportSettings(`\`settings.jsdoc.tagNamePreference\` cannot block @${obj.tagName} ` + 'for the `require-file-overview` rule');
  71. } else {
  72. const targetTagName = obj && obj.replacement || obj;
  73. if (mustExist && !state.hasTag[tagName]) {
  74. utils.reportSettings(`Missing @${targetTagName}`);
  75. }
  76. if (preventDuplicates && state.hasDuplicates[tagName]) {
  77. utils.reportSettings(`Duplicate @${targetTagName}`);
  78. }
  79. if (initialCommentsOnly && state.hasNonCommentBeforeTag[tagName]) {
  80. utils.reportSettings(`@${targetTagName} should be at the beginning of the file`);
  81. }
  82. }
  83. }
  84. },
  85. iterateAllJsdocs: true,
  86. meta: {
  87. docs: {
  88. description: 'Checks that all files have one `@file`, `@fileoverview`, or `@overview` tag at the beginning of the file.',
  89. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-file-overview'
  90. },
  91. schema: [{
  92. additionalProperties: false,
  93. properties: {
  94. tags: {
  95. patternProperties: {
  96. '.*': {
  97. additionalProperties: false,
  98. properties: {
  99. initialCommentsOnly: {
  100. type: 'boolean'
  101. },
  102. mustExist: {
  103. type: 'boolean'
  104. },
  105. preventDuplicates: {
  106. type: 'boolean'
  107. }
  108. },
  109. type: 'object'
  110. }
  111. },
  112. type: 'object'
  113. }
  114. },
  115. type: 'object'
  116. }],
  117. type: 'suggestion'
  118. },
  119. nonComment({
  120. state,
  121. node
  122. }) {
  123. if (!state.hasNonComment) {
  124. state.hasNonComment = node.range[0];
  125. }
  126. }
  127. });
  128. exports.default = _default;
  129. module.exports = exports.default;
  130. //# sourceMappingURL=requireFileOverview.js.map