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:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 14:33:21 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-17 14:33:21 +0300
commit7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch)
tree5bdc2229f5198d516781f8d24eace62fc7e589e9 /doc/.markdownlint
parent185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff)
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'doc/.markdownlint')
-rw-r--r--doc/.markdownlint/require_helper.js14
-rw-r--r--doc/.markdownlint/rules/tabs_blank_lines.js26
-rw-r--r--doc/.markdownlint/rules/tabs_title_markup.js31
-rw-r--r--doc/.markdownlint/rules/tabs_title_text.js23
-rw-r--r--doc/.markdownlint/rules/tabs_wrapper_tags.js21
5 files changed, 115 insertions, 0 deletions
diff --git a/doc/.markdownlint/require_helper.js b/doc/.markdownlint/require_helper.js
new file mode 100644
index 00000000000..7d06cf67419
--- /dev/null
+++ b/doc/.markdownlint/require_helper.js
@@ -0,0 +1,14 @@
+/**
+ * Look up the global node modules directory.
+ *
+ * Because we install markdownlint packages globally
+ * in the Docker image where this runs, we need to
+ * provide the path to the global install location
+ * when referencing global functions from our own node
+ * modules.
+ *
+ * Image:
+ * https://gitlab.com/gitlab-org/gitlab-docs/-/blob/main/dockerfiles/gitlab-docs-lint-markdown.Dockerfile
+ */
+const { execSync } = require('child_process');
+module.exports.globalPath = execSync('yarn global dir').toString().trim() + '/node_modules/';
diff --git a/doc/.markdownlint/rules/tabs_blank_lines.js b/doc/.markdownlint/rules/tabs_blank_lines.js
new file mode 100644
index 00000000000..e0e2c1a0a9b
--- /dev/null
+++ b/doc/.markdownlint/rules/tabs_blank_lines.js
@@ -0,0 +1,26 @@
+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,
+ });
+ }
+ });
+ },
+};
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}`,
+ });
+ }
+ });
+ },
+};
diff --git a/doc/.markdownlint/rules/tabs_title_text.js b/doc/.markdownlint/rules/tabs_title_text.js
new file mode 100644
index 00000000000..672aa70f562
--- /dev/null
+++ b/doc/.markdownlint/rules/tabs_title_text.js
@@ -0,0 +1,23 @@
+const { globalPath } = require('../require_helper');
+const {
+ forEachLine,
+ getLineMetadata,
+ isBlankLine,
+} = require(`${globalPath}/markdownlint-rule-helpers`);
+
+module.exports = {
+ names: ['tabs-title-text'],
+ description: 'Tab without title text',
+ information: new URL('https://docs.gitlab.com/ee/development/documentation/styleguide/#tabs'),
+ tags: ['gitlab-docs', 'tabs'],
+ function: (params, onError) => {
+ forEachLine(getLineMetadata(params), (line, lineIndex) => {
+ if (!isBlankLine(line) && line.replace(':::TabTitle', '').trim() === '') {
+ onError({
+ lineNumber: lineIndex + 1,
+ detail: 'Expected: :::TabTitle <your title here>; Actual: :::TabTitle',
+ });
+ }
+ });
+ },
+};
diff --git a/doc/.markdownlint/rules/tabs_wrapper_tags.js b/doc/.markdownlint/rules/tabs_wrapper_tags.js
new file mode 100644
index 00000000000..beacec0b737
--- /dev/null
+++ b/doc/.markdownlint/rules/tabs_wrapper_tags.js
@@ -0,0 +1,21 @@
+module.exports = {
+ names: ['tabs-wrapper-tags'],
+ description: 'Unequal number of tab start and end tags',
+ information: new URL('https://docs.gitlab.com/ee/development/documentation/styleguide/#tabs'),
+ tags: ['gitlab-docs', 'tabs'],
+ function: function rule(params, onError) {
+ const tabStarts = params.lines.filter((line) => line === '::Tabs');
+ const tabEnds = params.lines.filter((line) => line === '::EndTabs');
+
+ if (tabStarts.length !== tabEnds.length) {
+ const errorIndex =
+ params.lines.indexOf('::Tabs') > 0
+ ? params.lines.indexOf('::Tabs')
+ : params.lines.indexOf('::EndTabs');
+ onError({
+ lineNumber: errorIndex + 1,
+ detail: `Opening tags: ${tabStarts.length}; Closing tags: ${tabEnds.length}`,
+ });
+ }
+ },
+};