27 lines
819 B
JavaScript
27 lines
819 B
JavaScript
|
const { globalPath } = require('../require_helper');
|
||
|
const {
|
||
|
forEachLine,
|
||
|
getLineMetadata,
|
||
|
isBlankLine,
|
||
|
} = require(`${globalPath}/markdownlint-rule-helpers`);
|
||
|
|
||
|
module.exports = {
|
||
|
names: ['tabs-blank-lines'],
|
||
|
description: 'Tab elements must be surrounded by blank lines',
|
||
|
tags: ['gitlab-docs', 'tabs'],
|
||
|
function: (params, onError) => {
|
||
|
const tabElements = ['::Tabs', '::EndTabs', ':::TabTitle'];
|
||
|
forEachLine(getLineMetadata(params), (line, lineIndex) => {
|
||
|
const lineHasTab = tabElements.includes(line.split(' ')[0]);
|
||
|
const prevLine = params.lines[lineIndex - 1];
|
||
|
const nextLine = params.lines[lineIndex + 1];
|
||
|
|
||
|
if (lineHasTab && (!isBlankLine(prevLine) || !isBlankLine(nextLine))) {
|
||
|
onError({
|
||
|
lineNumber: lineIndex + 1,
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
};
|