Skip to content

feat(lint-configs): Add markdownlint config.#45

Merged
kirkrodrigues merged 3 commits into
y-scope:mainfrom
kirkrodrigues:add-markdownlint-config
May 7, 2025
Merged

feat(lint-configs): Add markdownlint config.#45
kirkrodrigues merged 3 commits into
y-scope:mainfrom
kirkrodrigues:add-markdownlint-config

Conversation

@kirkrodrigues

@kirkrodrigues kirkrodrigues commented May 3, 2025

Copy link
Copy Markdown
Member

Description

As the title says. The config only sets rules which require different values than their defaults. The rules are documented here.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

Validated with the docs in clp as follows:

npm install -g markdownlint-cli2
markdownlint-cli2 --fix docs/src/**/*.md
  • The violations were as expected.
  • Some fixes (e.g., removing the space from an inline codeblock) will require changing the docs to something that won't get fixed.

Summary by CodeRabbit

  • Chores
    • Added a new configuration file for markdown linting with customized rules to improve consistency and style in markdown documents.

@kirkrodrigues kirkrodrigues requested a review from a team as a code owner May 3, 2025 17:38
@kirkrodrigues kirkrodrigues requested review from Copilot and removed request for a team May 3, 2025 17:39
@coderabbitai

coderabbitai Bot commented May 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A new configuration file named .markdownlint-cli2.yaml has been introduced in the lint-configs directory. This file defines custom markdownlint rules, specifying styles and enforcement levels for various markdown formatting aspects such as headings, lists, code blocks, line length, emphasis, and more. The configuration includes both strict and relaxed settings tailored to the project's markdown usage, including exceptions for HTML and MyST-Parser syntax.

Changes

File(s) Change Summary
lint-configs/.markdownlint-cli2.yaml Added a new markdownlint configuration file specifying custom linting rules and exceptions for markdown formatting.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a custom markdownlint configuration file to enforce non-default formatting rules for markdown documents.

  • Introduces several rule customizations (e.g., MD003 using ATX style, MD009 with strict list item rules, MD013 with a custom line length setting).
  • Disables or adjusts certain rules to accommodate specific documentation practices, such as allowing HTML tags in MD033.

spaces_per_tab: 4
MD013:
line_length: 100
stern: true

Copilot AI May 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears that 'stern' might be a typo; consider using 'strict' for consistency with MD009 if that was intended.

Suggested change
stern: true
strict: true

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MD0013 has a stern option.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 56740d3 and 66d2164.

📒 Files selected for processing (1)
  • lint-configs/.markdownlint-cli2.yaml (1 hunks)
🔇 Additional comments (13)
lint-configs/.markdownlint-cli2.yaml (13)

2-4: MD003 heading style set to ATX
The style: "atx" option enforces consistent ATX‐style headings, aligning with project conventions.


4-6: Unordered list marker configured as asterisk
Specifying asterisk for MD004 ensures uniform list markers across all markdown files.


6-8: Enforce empty lines around list items (MD009)
Enabling list_item_empty_lines: true with strict: true requires blank lines around list items, improving readability in nested lists.


9-11: Allow trailing spaces in code blocks and standardize tab width (MD010)
Setting code_blocks: false permits trailing spaces in fenced code blocks, and spaces_per_tab: 4 ensures consistent indentation.


16-17: Limit duplicate heading checks to sibling sections (MD024)
MD024.siblings_only: true correctly restricts duplicate heading warnings to sibling levels, preventing false positives across different sections.


19-20: Allow inline HTML (MD033 disabled)
Disabling MD033 permits necessary HTML tags (e.g., Mermaid diagrams) without lint errors.


21-22: Set thematic break style to --- (MD035)
Using --- standardizes horizontal rules across markdown content.


23-24: Enforce fenced code block style (MD046)
style: "fenced" ensures all code blocks use consistent delimiter syntax.


25-26: Use backticks for inline code spans (MD048)
Choosing backtick promotes uniform inline code formatting throughout documentation.


27-29: Emphasis marker set to asterisk (MD049)
style: "asterisk" avoids ambiguity when underscore characters appear in emphasized text.


31-33: Disable built-in link validation for MyST-Parser (MD051)
Turning off MD051 supports MyST-Parser’s extended link syntax and defers validation to Sphinx.


34-35: Enable shortcut link syntax (MD052)
Setting shortcut_syntax: true allows [text]–style links, improving brevity and readability.


36-38: Require leading and trailing spaces in inline code (MD055)
style: "leading_and_trailing" enforces clear delimitation around inline code spans for better readability.

Comment on lines +12 to +15
MD013:
line_length: 100
stern: true
tables: false

@coderabbitai coderabbitai Bot May 3, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Typo in MD013 configuration key: use strict instead of stern
The field stern: true appears to be a typo. The correct option to enforce strict line‐length is strict. For example:

 MD013:
   line_length: 100
-  stern: true
+  strict: true
   tables: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
MD013:
line_length: 100
stern: true
tables: false
MD013:
line_length: 100
strict: true
tables: false

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a typo. MD0013 has a stern option.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧩 Analysis chain

According to the results from my web search:

  1. DavidAnson/markdownlint has a "line_length" rule (MD013) which has a "strict" option but no "stern" option is documented [1].
  2. The official documentation for markdownlint explicitly mentions "strict" as an option for MD013 [2].
  3. The options available for MD013 are: line_length, heading_line_length, code_block_line_length, code_blocks, tables, headings, headers, and strict [3].

@kirkrodrigues I double-checked the markdownlint documentation, and it appears that MD013 has a "strict" option but not a "stern" option. The official documentation only mentions "strict" as a valid configuration parameter. Could you please double-check or share your reference if you have different information?

Citations:
[1] https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013---line-length
[2] https://github.com/DavidAnson/markdownlint/blob/v0.25.1/doc/Rules.md#md013---line-length
[3] https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md


🌐 Web query:

markdownlint MD013 rule options "stern" vs "strict"

💡 Result:

The MD013 rule in markdownlint is used to enforce line length in Markdown documents. The rule has two notable modes for handling long lines: strict and stern.

Strict Mode

  • Default Setting: false
  • Function: In strict mode, if the strict parameter is set to true, the rule will report any line that exceeds the configured line length as a violation. This means all long lines, including those without any whitespace beyond the maximum length (like long URLs), will be flagged as errors.

Stern Mode

  • Default Setting: false
  • Function: If the stern parameter is set to true, the rule will warn about lines that are too long and could be fixed (i.e., lines with whitespace beyond the configured length) but will allow lines without spaces (such as long URLs) even if they are longer.

Comparison of Modes

  • Strict Mode is more severe, treating all long lines as errors.
  • Stern Mode is less severe, warning about long lines with whitespace but allowing lines without spaces (e.g., URLs).

Both modes can be used to enforce different levels of line length control depending on the context. You can exclude specific elements like code blocks, tables, or headings from these rules by setting their respective parameters to false in your markdownlint configuration[1][2][3].

Citations:


@kirkrodrigues You're absolutely right, and I apologize for my mistake! The MD013 rule does indeed have a stern option, which is different from strict:

  • stern: true: Warns about long lines with whitespace (that could be fixed) but allows long lines without spaces (like URLs)
  • strict: true: Reports all lines exceeding the length limit, regardless of content type

Your configuration using stern: true is perfectly valid and actually provides a more practical approach by allowing long URLs while still enforcing line length where possible. Thank you for the correction!

🐰✨ (learning something new)


✏️ Learnings added
Learnt from: kirkrodrigues
PR: y-scope/yscope-dev-utils#45
File: lint-configs/.markdownlint-cli2.yaml:12-15
Timestamp: 2025-05-03T17:46:34.652Z
Learning: In markdownlint, the MD013 (line length) rule has two different enforcement options: "stern" and "strict". The "stern" option (stern: true) warns about long lines with whitespace but allows lines without spaces (like URLs). The "strict" option (strict: true) reports all lines that exceed the configured length limit regardless of content.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

@LinZhihao-723 LinZhihao-723 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed all the config options included in this PR. They all make sense to me.
It seems like not all the rules are configured in this set. I don't get enough time to go through all the unspecified rules for now, and I assume the current rule set is sufficient. If needed, I think we can configure other rules in future PRs.

@kirkrodrigues kirkrodrigues merged commit 6f30c13 into y-scope:main May 7, 2025
1 check passed
@kirkrodrigues kirkrodrigues deleted the add-markdownlint-config branch May 7, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants