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.

requireHyphenBeforeParamDescription.js 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. var _default = (0, _iterateJsdoc.default)(({
  9. sourceCode,
  10. utils,
  11. report,
  12. context,
  13. jsdoc,
  14. jsdocNode
  15. }) => {
  16. const [mainCircumstance, {
  17. tags
  18. } = {}] = context.options;
  19. const checkHyphens = (jsdocTag, targetTagName, circumstance = mainCircumstance) => {
  20. const always = !circumstance || circumstance === 'always';
  21. const desc = utils.getTagDescription(jsdocTag);
  22. if (!desc.trim()) {
  23. return;
  24. }
  25. const startsWithHyphen = /^\s*-/u.test(desc);
  26. if (always) {
  27. if (!startsWithHyphen) {
  28. report(`There must be a hyphen before @${targetTagName} description.`, fixer => {
  29. const lineIndex = jsdocTag.line;
  30. const sourceLines = sourceCode.getText(jsdocNode).split('\n'); // Get start index of description, accounting for multi-line descriptions
  31. const description = desc.split('\n')[0];
  32. const descriptionIndex = sourceLines[lineIndex].lastIndexOf(description);
  33. const replacementLine = sourceLines[lineIndex].slice(0, descriptionIndex) + '- ' + description;
  34. sourceLines.splice(lineIndex, 1, replacementLine);
  35. const replacement = sourceLines.join('\n');
  36. return fixer.replaceText(jsdocNode, replacement);
  37. }, jsdocTag);
  38. }
  39. } else if (startsWithHyphen) {
  40. report(`There must be no hyphen before @${targetTagName} description.`, fixer => {
  41. const [unwantedPart] = /^\s*-\s*/u.exec(desc);
  42. const replacement = sourceCode.getText(jsdocNode).replace(desc, desc.slice(unwantedPart.length));
  43. return fixer.replaceText(jsdocNode, replacement);
  44. }, jsdocTag);
  45. }
  46. };
  47. utils.forEachPreferredTag('param', checkHyphens);
  48. if (tags) {
  49. const tagEntries = Object.entries(tags);
  50. tagEntries.forEach(([tagName, circumstance]) => {
  51. if (tagName === '*') {
  52. const preferredParamTag = utils.getPreferredTagName({
  53. tagName: 'param'
  54. });
  55. jsdoc.tags.forEach(({
  56. tag
  57. }) => {
  58. if (tag === preferredParamTag || tagEntries.some(([tagNme]) => {
  59. return tagNme !== '*' && tagNme === tag;
  60. })) {
  61. return;
  62. }
  63. utils.forEachPreferredTag(tag, (jsdocTag, targetTagName) => {
  64. checkHyphens(jsdocTag, targetTagName, circumstance);
  65. });
  66. });
  67. return;
  68. }
  69. utils.forEachPreferredTag(tagName, (jsdocTag, targetTagName) => {
  70. checkHyphens(jsdocTag, targetTagName, circumstance);
  71. });
  72. });
  73. }
  74. }, {
  75. iterateAllJsdocs: true,
  76. meta: {
  77. docs: {
  78. description: 'Requires a hyphen before the `@param` description.',
  79. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-require-hyphen-before-param-description'
  80. },
  81. fixable: 'code',
  82. schema: [{
  83. enum: ['always', 'never'],
  84. type: 'string'
  85. }, {
  86. additionalProperties: false,
  87. properties: {
  88. tags: {
  89. anyOf: [{
  90. patternProperties: {
  91. '.*': {
  92. enum: ['always', 'never'],
  93. type: 'string'
  94. }
  95. },
  96. type: 'object'
  97. }, {
  98. enum: ['any'],
  99. type: 'string'
  100. }]
  101. }
  102. },
  103. type: 'object'
  104. }],
  105. type: 'layout'
  106. }
  107. });
  108. exports.default = _default;
  109. module.exports = exports.default;
  110. //# sourceMappingURL=requireHyphenBeforeParamDescription.js.map