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.

noBadBlocks.js 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _commentParser = require("comment-parser");
  7. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. // Neither a single nor 3+ asterisks are valid jsdoc per
  10. // https://jsdoc.app/about-getting-started.html#adding-documentation-comments-to-your-code
  11. const commentRegexp = /^\/\*(?!\*)/u;
  12. const extraAsteriskCommentRegexp = /^\/\*{3,}/u;
  13. var _default = (0, _iterateJsdoc.default)(({
  14. context,
  15. sourceCode,
  16. allComments,
  17. makeReport
  18. }) => {
  19. const [{
  20. ignore = ['ts-check', 'ts-expect-error', 'ts-ignore', 'ts-nocheck'],
  21. preventAllMultiAsteriskBlocks = false
  22. } = {}] = context.options;
  23. let extraAsterisks = false;
  24. const nonJsdocNodes = allComments.filter(comment => {
  25. const commentText = sourceCode.getText(comment);
  26. let sliceIndex = 2;
  27. if (!commentRegexp.test(commentText)) {
  28. var _extraAsteriskComment;
  29. const multiline = (_extraAsteriskComment = extraAsteriskCommentRegexp.exec(commentText)) === null || _extraAsteriskComment === void 0 ? void 0 : _extraAsteriskComment[0];
  30. if (!multiline) {
  31. return false;
  32. }
  33. sliceIndex = multiline.length;
  34. extraAsterisks = true;
  35. if (preventAllMultiAsteriskBlocks) {
  36. return true;
  37. }
  38. }
  39. const [{
  40. tags = {}
  41. } = {}] = (0, _commentParser.parse)(`${commentText.slice(0, 2)}*${commentText.slice(sliceIndex)}`);
  42. return tags.length && !tags.some(({
  43. tag
  44. }) => {
  45. return ignore.includes(tag);
  46. });
  47. });
  48. if (!nonJsdocNodes.length) {
  49. return;
  50. }
  51. nonJsdocNodes.forEach(node => {
  52. const report = makeReport(context, node);
  53. const fix = fixer => {
  54. const text = sourceCode.getText(node);
  55. return fixer.replaceText(node, extraAsterisks ? text.replace(extraAsteriskCommentRegexp, '/**') : text.replace('/*', '/**'));
  56. };
  57. report('Expected JSDoc-like comment to begin with two asterisks.', fix);
  58. });
  59. }, {
  60. checkFile: true,
  61. meta: {
  62. docs: {
  63. description: 'This rule checks for multi-line-style comments which fail to meet the criteria of a jsdoc block.',
  64. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-no-bad-blocks'
  65. },
  66. fixable: 'code',
  67. schema: [{
  68. additionalProperties: false,
  69. properties: {
  70. ignore: {
  71. items: {
  72. type: 'string'
  73. },
  74. type: 'array'
  75. },
  76. preventAllMultiAsteriskBlocks: {
  77. type: 'boolean'
  78. }
  79. },
  80. type: 'object'
  81. }],
  82. type: 'layout'
  83. }
  84. });
  85. exports.default = _default;
  86. module.exports = exports.default;
  87. //# sourceMappingURL=noBadBlocks.js.map