Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/.markdownlint/rules/tabs_title_markup.js')
-rw-r--r--doc/.markdownlint/rules/tabs_title_markup.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/doc/.markdownlint/rules/tabs_title_markup.js b/doc/.markdownlint/rules/tabs_title_markup.js
new file mode 100644
index 00000000000..9c1de1e630d
--- /dev/null
+++ b/doc/.markdownlint/rules/tabs_title_markup.js
@@ -0,0 +1,31 @@
+const { globalPath } = require('../require_helper');
+const { forEachLine, getLineMetadata } = require(`${globalPath}/markdownlint-rule-helpers`);
+
+module.exports = {
+ names: ['tabs-title-markup'],
+ description: 'Incorrect number of colon characters for tag',
+ information: new URL('https://docs.gitlab.com/ee/development/documentation/styleguide/#tabs'),
+ tags: ['gitlab-docs', 'tabs'],
+ function: (params, onError) => {
+ // Note the correct number of colons in each tab tag type.
+ const wrapperColons = 2;
+ const titleColons = 3;
+
+ forEachLine(getLineMetadata(params), (line, lineIndex) => {
+ // Get the number of colons in this line.
+ const colonCount = [...line].filter((x) => x === ':').length;
+
+ // Throw an error in the case of a mismatch.
+ if (
+ ((line.includes(':Tabs') || line.includes(':EndTabs')) && colonCount !== wrapperColons) ||
+ (line.includes(':TabTitle') && colonCount !== titleColons)
+ ) {
+ const correctColonCount = line.includes(':TabTitle') ? wrapperColons : titleColons;
+ onError({
+ lineNumber: lineIndex + 1,
+ detail: `Actual: ${colonCount}; Expected: ${correctColonCount}`,
+ });
+ }
+ });
+ },
+};