-
Notifications
You must be signed in to change notification settings - Fork 1
plan 51: add MDS036 section-size-limits rule #143
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| --- | ||
| id: MDS036 | ||
| name: max-section-length | ||
| status: ready | ||
| description: Section length must not exceed per-level or per-heading limits. | ||
| --- | ||
| # MDS036: max-section-length | ||
|
|
||
| Section length must not exceed per-level or per-heading limits. | ||
|
|
||
| - **ID**: MDS036 | ||
| - **Name**: `max-section-length` | ||
| - **Status**: ready | ||
| - **Default**: disabled | ||
| - **Fixable**: no | ||
| - **Implementation**: | ||
| [source](./) | ||
| - **Category**: heading | ||
|
|
||
| A section spans from its heading line up to (but not including) the next | ||
| heading line of any level, or the end of file. Nested subsections are | ||
| measured separately from their parent, so the limit applies to the | ||
| content written directly under each heading. | ||
|
|
||
| ## Settings | ||
|
|
||
| | Setting | Type | Default | Description | | ||
| |---------------|------|---------|----------------------------------------------------| | ||
| | `max` | int | 0 | Default line limit; zero disables the global rule. | | ||
| | `per-level` | map | `{}` | Map from heading level (1-6) to line limit. | | ||
| | `per-heading` | list | `[]` | Regex patterns with per-heading line limits. | | ||
|
|
||
| Lookup order for a heading: `per-heading` (first matching regex wins), | ||
| then `per-level`, then `max`. A resolved limit of zero disables the | ||
| check for that heading. | ||
|
|
||
| ## Config | ||
|
|
||
| Enable with a default limit: | ||
|
|
||
| ```yaml | ||
| rules: | ||
| max-section-length: | ||
| max: 100 | ||
| ``` | ||
|
|
||
| Per-level and per-heading overrides: | ||
|
|
||
| ```yaml | ||
| rules: | ||
| max-section-length: | ||
| max: 100 | ||
| per-level: | ||
| 1: 200 | ||
| 2: 80 | ||
| per-heading: | ||
| - pattern: "^Changelog$" | ||
| max: 500 | ||
| ``` | ||
|
|
||
| Disable: | ||
|
|
||
| ```yaml | ||
| rules: | ||
| max-section-length: false | ||
| ``` | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Good | ||
|
|
||
| <?include | ||
| file: good/default.md | ||
| wrap: markdown | ||
| ?> | ||
|
|
||
| ```markdown | ||
| # Title | ||
|
|
||
| Short section within the limit. | ||
|
|
||
| ## Subsection | ||
|
|
||
| Also short. Each section is bounded by the next heading of any level. | ||
|
|
||
| ## Another | ||
|
|
||
| Stays under the limit. | ||
| ``` | ||
|
|
||
| <?/include?> | ||
|
|
||
| ### Bad | ||
|
|
||
| <?include | ||
| file: bad/default.md | ||
| wrap: markdown | ||
| ?> | ||
|
|
||
| ```markdown | ||
| # Too Long | ||
|
|
||
| line a | ||
| line b | ||
| line c | ||
| line d | ||
| ``` | ||
|
|
||
| <?/include?> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| --- | ||
| settings: | ||
| max: 3 | ||
| diagnostics: | ||
| - line: 1 | ||
| column: 1 | ||
| message: 'section "# Too Long" too long (6 > 3)' | ||
| --- | ||
| # Too Long | ||
|
|
||
| line a | ||
| line b | ||
| line c | ||
| line d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| settings: | ||
| max: 0 | ||
| per-level: | ||
| 2: 2 | ||
| diagnostics: | ||
| - line: 3 | ||
| column: 1 | ||
| message: 'section "## Overflowing" too long (5 > 2)' | ||
| --- | ||
| # Overview | ||
|
|
||
| ## Overflowing | ||
|
|
||
| a | ||
| b | ||
| c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| --- | ||
| settings: | ||
| max: 10 | ||
| --- | ||
| # Title | ||
|
|
||
| Short section within the limit. | ||
|
|
||
| ## Subsection | ||
|
|
||
| Also short. Each section is bounded by the next heading of any level. | ||
|
|
||
| ## Another | ||
|
|
||
| Stays under the limit. |
18 changes: 18 additions & 0 deletions
18
internal/rules/MDS036-max-section-length/good/per-level.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| --- | ||
| settings: | ||
| max: 0 | ||
| per-level: | ||
| 2: 4 | ||
| --- | ||
| # Overview | ||
|
|
||
| Top-level has no limit because `max` is zero and level 1 is not listed. | ||
| Only level-2 sections must stay within four lines. | ||
|
|
||
| ## Short | ||
|
|
||
| Two lines of text. | ||
|
|
||
| ## Also Short | ||
|
|
||
| Two more lines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule supports
per-heading(regex-based) limits, but there are no integration fixture files exercisingper-headingsettings. Consider adding at least one good/ and one bad/ fixture that usesper-headingto validate YAML/front-matter decoding and end-to-end behavior (similar to the existing default/per-level fixtures).