canonical
Version:
Canonical code style linter and formatter for JavaScript, SCSS and CSS.
56 lines (41 loc) • 1.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _startsWith = require('lodash/string/startsWith');
var _startsWith2 = _interopRequireDefault(_startsWith);
var _has = require('lodash/object/has');
var _has2 = _interopRequireDefault(_has);
var _iterateJsdoc = require('./../iterateJsdoc');
var _iterateJsdoc2 = _interopRequireDefault(_iterateJsdoc);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = (0, _iterateJsdoc2.default)(function (_ref) {
var jsdoc = _ref.jsdoc;
var report = _ref.report;
var context = _ref.context;
var always = undefined,
descriptionEndsWithANewline = undefined;
if (!jsdoc.description || !jsdoc.tags.length) {
return;
}
if ((0, _has2.default)(context.options, 0)) {
always = context.options[0] === 'always';
} else {
always = true;
}
// The contents of the jsdoc.source and of jsdoc.description is left trimmed.
// The contents of the jsdoc.description is right trimmed.
// This gets the text following the description.
descriptionEndsWithANewline = (0, _startsWith2.default)(jsdoc.source.slice(jsdoc.description.length), '\n\n');
if (always) {
if (!descriptionEndsWithANewline) {
report('There must be a newline after the description of the JSDoc block.');
}
} else {
if (descriptionEndsWithANewline) {
report('There must be no newline after the description of the JSDoc block.');
}
}
});
module.exports = exports['default'];
//# sourceMappingURL=newlineAfterDescription.js.map