Skip to content

Improve CI/CD linter error feedback, add help to fix problems fast

Problem to solve

The CI/CD jobs run markdown lint which complains about trailing spaces. https://gitlab.com/gitlab-com/content-sites/handbook/-/jobs/4422964536 I did not add them on purpose, I only used the Web IDE in the browser to edit the handbook. !163 (merged)

The failed linter requires me to navigate back into the Web IDE from the MR, and identify the lines and locations to fix the problems.

$ markdownlint-cli2 "content/**/*.md"
markdownlint-cli2 v0.4.0 (markdownlint v0.25.1)
Finding: content/**/*.md
Linting: 492 file(s)
Summary: 6 error(s)
content/handbook/tools-and-tips/_index.md:1004:82 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
content/handbook/tools-and-tips/_index.md:1006:44 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
content/handbook/tools-and-tips/_index.md:1008:83 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
content/handbook/tools-and-tips/_index.md:1009:213 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
content/handbook/tools-and-tips/_index.md:1012:33 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]
content/handbook/tools-and-tips/_index.md:1015:177 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1]

The errors are hard to read. Engineers might understand the filepath:linenumber:characternumber notation. [Expected: 0 or 2; Actual: 1] is confusing, why would 2 trailing spaces be accepted?

Proposal

When linter errors are found, print a text with instructions how to fix these errors fast. For example, link to a handbook page that explains how to fix trailing whitespaces, or that 1004 in the output means the line number where to start looking.

Potentially there is a shortcut for the Web IDE to trim trailing spaces (or a setting like in VS Code, but that could render MR diffs unreadable if applied to everything).

/cc @jamiemaynard @marshall007

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information