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

Markdownlint: New custom ordered list lazy numbering rule #27836

Open
2 of 10 tasks
MaoShizhong opened this issue Apr 22, 2024 · 2 comments
Open
2 of 10 tasks

Markdownlint: New custom ordered list lazy numbering rule #27836

MaoShizhong opened this issue Apr 22, 2024 · 2 comments
Assignees
Labels
Type: Enhancement Involves a new feature or enhancement request

Comments

@MaoShizhong
Copy link
Contributor

MaoShizhong commented Apr 22, 2024

Checks

Describe your suggestion

This repo has markdownlint-cli2 as a dependency, which allows us to run lint checks and fixes via our npm scripts in package.json, using the built-in rules in our markdownlint config files, as well as our various custom rules in the markdownlint directory.

Some rules (not all) have fixers included, so running our fix:lesson or fix:project scripts will automatically resolve some errors, such as using _ instead of *, or not wrapping headings with blank lines etc. Some rules don't have fixers included, as they are more context-based (e.g. descriptive links) and need to be addressed on a case-by-case basis. That, or the built-in rule with all its various options make a built-in fixer a little trickier.

As per the layout style guide, we use lazy numbering with 1s, meaning any ordered list must be prefixed with 1. and we let the markdown converter figure out the correct numbering. We enforce this with the built-in MD029 rule. However, MD029 does not have a built-in fixer. And we want one. So we'll have to do it ourselves.

What we want

We need to deactivate the MD029 rule in our base config file, then write a new custom rule that finds all lines that are ordered list items and are not prefixed with 1., and report the appropriate linting errors on them.
The custom rule will also need to include fix information so that when either fix:* scripts are run, these ordered list items' prefixes are replaced with 1..

1. ONE
2. TWO
   1. child one
   2. child two
3. THREE

2., the nested 2., and 3. should flag errors.
Running the fix:* script should fix the above to

1. ONE
1. TWO
   1. child one
   1. child two
1. THREE

The rule itself will be written in JavaScript.

If you would like to be assigned to work on this, please comment below.

Acceptance criteria

  • Within the markdownlint directory, make a directory for the new custom rule containing the rule .js file. Use the markdownlint custom rules guide and the other custom rules to help you.
    • It must correctly report the line number, and the "detail" (expected and actual values).
    • It must include "fixInfo" that will allow the fix:* scripts to fix the appropriate lines.
  • In the rule's directory, create a tests directory containing an .md file showcasing instances where the rule will flag, and when the rule passes. This test file must not flag any errors other than the custom rule.
  • Inside markdownlint/docs, create a documentation .md file for the new rule so that it can be linked by the custom rule when it errors. It is okay if this documentation file includes unavoidable lint errors - it will not be run through the lint check action when you PR.
  • In .markdownlint-cli2.jsonc, deactivate the MD029 rule by changing its value to false (no object, just false). Its comment will need amending to say it's being overridden by the custom rule (provide the custom rule code).
  • Append the custom rule's file path (to the .js file) to .markdownlint-cli2.jsonc's "customRules" array.

Path

Other / NA

Lesson Url

N/A

(Optional) Discord Name

No response

(Optional) Additional Comments

No response

@MaoShizhong MaoShizhong added Type: Enhancement Involves a new feature or enhancement request Status: Help Wanted This issue can be assigned to other contributors labels Apr 22, 2024
@BryanF1nes
Copy link
Member

I'm interested to take on this challenge!

@MaoShizhong
Copy link
Contributor Author

I've high hopes for you @BryanF1nes !

@MaoShizhong MaoShizhong removed the Status: Help Wanted This issue can be assigned to other contributors label Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Involves a new feature or enhancement request
Projects
None yet
Development

No branches or pull requests

2 participants