Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Refactor/rework custom trim-code-block-and-unindent markdownlint rule #3183

Open
chalin opened this issue Aug 15, 2023 · 0 comments
Open
Labels
CI/infra CI & infrastructure cleanup/refactoring e1-hours Effort: < 8 hrs enhancement New feature or request p2-medium p3-low

Comments

@chalin
Copy link
Contributor

chalin commented Aug 15, 2023

The trim-code-block-and-unindent custom markdownlint (mdl) rule was introduced by

As was mentioned in the opening comment of #3177, the custom rule reports errors over a line range. I've since learned that mdl (especially it's issuing-fixing approach) is strictly line based. So, trim-code-block-and-unindent would need to be reworked so that it is line based -- that is, it should report an issue for each problematic line, along with the fix for that line only. With this mode of processing, it might be beneficial to split the rule into three:

  1. Report excess lines at the top of the block
  2. Report excess indentation inside of a block (to avoid a flood of reported issues, when not fixing, the custom rule might consider reporting only the first of many lines that need to be unindented)
  3. Report excess lines at the bottom of a block

Consider refactoring this rule so that it could, in principle, be used with mdl invoked from the command line. This is to ensure that it is properly packaged, and would be reusable in the context of other projects.

Reminder that our custom Gulp task actually strips out Hugo/Go-template directives ({{...}}) so it might not make sense to try to implement use of mld's --fix (from the CLI) or generally for all rules in our Gulp task (currently --fix only fixes code-block issues). It might be that mdl's helpers have generic functions that implement fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/infra CI & infrastructure cleanup/refactoring e1-hours Effort: < 8 hrs enhancement New feature or request p2-medium p3-low
Projects
None yet
Development

No branches or pull requests

1 participant