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.

newlineAfterDescription.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _lodash = _interopRequireDefault(require("lodash"));
  7. var _iterateJsdoc = _interopRequireDefault(require("../iterateJsdoc"));
  8. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  9. var _default = (0, _iterateJsdoc.default)(({
  10. jsdoc,
  11. report,
  12. context,
  13. jsdocNode,
  14. sourceCode,
  15. indent,
  16. utils
  17. }) => {
  18. let always;
  19. if (!jsdoc.description.trim() || !jsdoc.tags.length) {
  20. return;
  21. }
  22. if (_lodash.default.has(context.options, 0)) {
  23. always = context.options[0] === 'always';
  24. } else {
  25. always = true;
  26. }
  27. const {
  28. description,
  29. lastDescriptionLine
  30. } = utils.getDescription();
  31. const descriptionEndsWithANewline = /\n\r?$/.test(description);
  32. if (always) {
  33. if (!descriptionEndsWithANewline) {
  34. const sourceLines = sourceCode.getText(jsdocNode).split('\n');
  35. report('There must be a newline after the description of the JSDoc block.', fixer => {
  36. // Add the new line
  37. const injectedLine = `${indent} *` + (sourceLines[lastDescriptionLine].endsWith('\r') ? '\r' : '');
  38. sourceLines.splice(lastDescriptionLine + 1, 0, injectedLine);
  39. return fixer.replaceText(jsdocNode, sourceLines.join('\n'));
  40. }, {
  41. line: lastDescriptionLine
  42. });
  43. }
  44. } else if (descriptionEndsWithANewline) {
  45. const sourceLines = sourceCode.getText(jsdocNode).split('\n');
  46. report('There must be no newline after the description of the JSDoc block.', fixer => {
  47. // Remove the extra line
  48. sourceLines.splice(lastDescriptionLine, 1);
  49. return fixer.replaceText(jsdocNode, sourceLines.join('\n'));
  50. }, {
  51. line: lastDescriptionLine
  52. });
  53. }
  54. }, {
  55. iterateAllJsdocs: true,
  56. meta: {
  57. docs: {
  58. description: 'Enforces a consistent padding of the block description.',
  59. url: 'https://github.com/gajus/eslint-plugin-jsdoc#eslint-plugin-jsdoc-rules-newline-after-description'
  60. },
  61. fixable: 'whitespace',
  62. schema: [{
  63. enum: ['always', 'never'],
  64. type: 'string'
  65. }],
  66. type: 'layout'
  67. }
  68. });
  69. exports.default = _default;
  70. module.exports = exports.default;
  71. //# sourceMappingURL=newlineAfterDescription.js.map