rubocop-prose 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/AGENTS.md +13 -0
- data/CHANGELOG.md +82 -0
- data/CONTRIBUTING.md +77 -0
- data/DESIGN.md +51 -0
- data/LICENSE.txt +21 -0
- data/README.md +152 -0
- data/RELEASING.md +32 -0
- data/assets/README.md +3 -0
- data/assets/RUBOCOP-LICENSE +20 -0
- data/assets/logo.gif +0 -0
- data/assets/logo.png +0 -0
- data/assets/logo.svg +80 -0
- data/assets/rubocop-logo.svg +1 -0
- data/config/cops/markdown/atx_heading_space.yml +3 -0
- data/config/cops/markdown/atx_heading_spacing.yml +3 -0
- data/config/cops/markdown/bare_url.yml +7 -0
- data/config/cops/markdown/blockquote_blank_lines.yml +3 -0
- data/config/cops/markdown/blockquote_spacing.yml +3 -0
- data/config/cops/markdown/closed_heading_space.yml +3 -0
- data/config/cops/markdown/closed_heading_spacing.yml +3 -0
- data/config/cops/markdown/code_block_style.yml +8 -0
- data/config/cops/markdown/code_span_spacing.yml +3 -0
- data/config/cops/markdown/compact_lists.yml +3 -0
- data/config/cops/markdown/descriptive_link_text.yml +8 -0
- data/config/cops/markdown/duplicate_headings.yml +4 -0
- data/config/cops/markdown/emphasis_heading.yml +3 -0
- data/config/cops/markdown/emphasis_spacing.yml +3 -0
- data/config/cops/markdown/emphasis_style.yml +4 -0
- data/config/cops/markdown/empty_link.yml +3 -0
- data/config/cops/markdown/fence_blank_lines.yml +6 -0
- data/config/cops/markdown/fence_language.yml +4 -0
- data/config/cops/markdown/fence_style.yml +8 -0
- data/config/cops/markdown/first_heading.yml +6 -0
- data/config/cops/markdown/front_matter.yml +2 -0
- data/config/cops/markdown/hard_break_style.yml +4 -0
- data/config/cops/markdown/hard_tabs.yml +5 -0
- data/config/cops/markdown/heading_blank_lines.yml +5 -0
- data/config/cops/markdown/heading_increment.yml +3 -0
- data/config/cops/markdown/heading_indentation.yml +3 -0
- data/config/cops/markdown/heading_punctuation.yml +4 -0
- data/config/cops/markdown/heading_structure.yml +4 -0
- data/config/cops/markdown/heading_style.yml +9 -0
- data/config/cops/markdown/image_alt_text.yml +3 -0
- data/config/cops/markdown/image_path_separators.yml +3 -0
- data/config/cops/markdown/link_fragment.yml +6 -0
- data/config/cops/markdown/link_style.yml +10 -0
- data/config/cops/markdown/link_text_spacing.yml +3 -0
- data/config/cops/markdown/list_blank_lines.yml +3 -0
- data/config/cops/markdown/list_continuation_indentation.yml +3 -0
- data/config/cops/markdown/list_indentation.yml +3 -0
- data/config/cops/markdown/list_marker_spacing.yml +7 -0
- data/config/cops/markdown/ordered_list_numbering.yml +7 -0
- data/config/cops/markdown/outside_spacing.yml +3 -0
- data/config/cops/markdown/proper_names.yml +5 -0
- data/config/cops/markdown/raw_html.yml +4 -0
- data/config/cops/markdown/reference_definitions.yml +8 -0
- data/config/cops/markdown/reversed_link.yml +3 -0
- data/config/cops/markdown/shell_prompts.yml +13 -0
- data/config/cops/markdown/single_top_level_heading.yml +4 -0
- data/config/cops/markdown/strong_style.yml +4 -0
- data/config/cops/markdown/structural_line_length.yml +9 -0
- data/config/cops/markdown/syntax.yml +3 -0
- data/config/cops/markdown/table_blank_lines.yml +3 -0
- data/config/cops/markdown/table_columns.yml +3 -0
- data/config/cops/markdown/table_pipes.yml +4 -0
- data/config/cops/markdown/table_spacing.yml +4 -0
- data/config/cops/markdown/thematic_break_blank_lines.yml +5 -0
- data/config/cops/markdown/thematic_break_style.yml +4 -0
- data/config/cops/markdown/trailing_whitespace.yml +5 -0
- data/config/cops/markdown/unclosed_fenced_code_block.yml +3 -0
- data/config/cops/markdown/undefined_reference.yml +4 -0
- data/config/cops/markdown/unordered_list_indentation.yml +4 -0
- data/config/cops/markdown/unordered_list_marker.yml +9 -0
- data/config/cops/prose/max_length.yml +5 -0
- data/config/cops/prose/multiple_blank_lines.yml +4 -0
- data/config/cops/prose/trailing_newline.yml +3 -0
- data/config/cops/text/trailing_whitespace.yml +3 -0
- data/config/default.yml +16 -0
- data/docs/cops/markdown/atx_heading_space.md +26 -0
- data/docs/cops/markdown/atx_heading_spacing.md +24 -0
- data/docs/cops/markdown/bare_url.md +30 -0
- data/docs/cops/markdown/blockquote_blank_lines.md +30 -0
- data/docs/cops/markdown/blockquote_spacing.md +30 -0
- data/docs/cops/markdown/closed_heading_space.md +26 -0
- data/docs/cops/markdown/closed_heading_spacing.md +24 -0
- data/docs/cops/markdown/code_block_style.md +37 -0
- data/docs/cops/markdown/code_span_spacing.md +26 -0
- data/docs/cops/markdown/compact_lists.md +29 -0
- data/docs/cops/markdown/descriptive_link_text.md +31 -0
- data/docs/cops/markdown/duplicate_headings.md +35 -0
- data/docs/cops/markdown/emphasis_heading.md +26 -0
- data/docs/cops/markdown/emphasis_spacing.md +24 -0
- data/docs/cops/markdown/emphasis_style.md +34 -0
- data/docs/cops/markdown/empty_link.md +26 -0
- data/docs/cops/markdown/fence_blank_lines.md +43 -0
- data/docs/cops/markdown/fence_language.md +31 -0
- data/docs/cops/markdown/fence_style.md +38 -0
- data/docs/cops/markdown/first_heading.md +31 -0
- data/docs/cops/markdown/hard_break_style.md +50 -0
- data/docs/cops/markdown/hard_tabs.md +30 -0
- data/docs/cops/markdown/heading_blank_lines.md +36 -0
- data/docs/cops/markdown/heading_increment.md +30 -0
- data/docs/cops/markdown/heading_indentation.md +26 -0
- data/docs/cops/markdown/heading_punctuation.md +27 -0
- data/docs/cops/markdown/heading_structure.md +41 -0
- data/docs/cops/markdown/heading_style.md +36 -0
- data/docs/cops/markdown/image_alt_text.md +26 -0
- data/docs/cops/markdown/image_path_separators.md +32 -0
- data/docs/cops/markdown/link_fragment.md +35 -0
- data/docs/cops/markdown/link_style.md +49 -0
- data/docs/cops/markdown/link_text_spacing.md +26 -0
- data/docs/cops/markdown/list_blank_lines.md +31 -0
- data/docs/cops/markdown/list_continuation_indentation.md +28 -0
- data/docs/cops/markdown/list_indentation.md +28 -0
- data/docs/cops/markdown/list_marker_spacing.md +32 -0
- data/docs/cops/markdown/ordered_list_numbering.md +29 -0
- data/docs/cops/markdown/outside_spacing.md +26 -0
- data/docs/cops/markdown/proper_names.md +39 -0
- data/docs/cops/markdown/raw_html.md +27 -0
- data/docs/cops/markdown/reference_definitions.md +36 -0
- data/docs/cops/markdown/reversed_link.md +26 -0
- data/docs/cops/markdown/shell_prompts.md +57 -0
- data/docs/cops/markdown/single_top_level_heading.md +31 -0
- data/docs/cops/markdown/strong_style.md +34 -0
- data/docs/cops/markdown/structural_line_length.md +40 -0
- data/docs/cops/markdown/syntax.md +28 -0
- data/docs/cops/markdown/table_blank_lines.md +34 -0
- data/docs/cops/markdown/table_columns.md +30 -0
- data/docs/cops/markdown/table_pipes.md +38 -0
- data/docs/cops/markdown/table_spacing.md +38 -0
- data/docs/cops/markdown/thematic_break_blank_lines.md +31 -0
- data/docs/cops/markdown/thematic_break_style.md +48 -0
- data/docs/cops/markdown/trailing_whitespace.md +30 -0
- data/docs/cops/markdown/unclosed_fenced_code_block.md +29 -0
- data/docs/cops/markdown/undefined_reference.md +29 -0
- data/docs/cops/markdown/unordered_list_indentation.md +45 -0
- data/docs/cops/markdown/unordered_list_marker.md +36 -0
- data/docs/cops/prose/max_length.md +33 -0
- data/docs/cops/prose/multiple_blank_lines.md +50 -0
- data/docs/cops/prose/trailing_newline.md +26 -0
- data/docs/cops/text/trailing_whitespace.md +26 -0
- data/docs/settings/files.md +33 -0
- data/docs/settings/front_matter.md +12 -0
- data/lib/rubocop/cop/markdown/atx_heading_space.rb +22 -0
- data/lib/rubocop/cop/markdown/atx_heading_spacing.rb +27 -0
- data/lib/rubocop/cop/markdown/bare_url.rb +22 -0
- data/lib/rubocop/cop/markdown/base.rb +17 -0
- data/lib/rubocop/cop/markdown/blockquote_blank_lines.rb +49 -0
- data/lib/rubocop/cop/markdown/blockquote_spacing.rb +76 -0
- data/lib/rubocop/cop/markdown/closed_heading_space.rb +26 -0
- data/lib/rubocop/cop/markdown/closed_heading_spacing.rb +27 -0
- data/lib/rubocop/cop/markdown/code_block_style.rb +80 -0
- data/lib/rubocop/cop/markdown/code_span_spacing.rb +51 -0
- data/lib/rubocop/cop/markdown/compact_lists.rb +43 -0
- data/lib/rubocop/cop/markdown/descriptive_link_text.rb +27 -0
- data/lib/rubocop/cop/markdown/duplicate_headings.rb +28 -0
- data/lib/rubocop/cop/markdown/emphasis_heading.rb +18 -0
- data/lib/rubocop/cop/markdown/emphasis_spacing.rb +30 -0
- data/lib/rubocop/cop/markdown/emphasis_style.rb +34 -0
- data/lib/rubocop/cop/markdown/empty_link.rb +25 -0
- data/lib/rubocop/cop/markdown/fence_blank_lines.rb +72 -0
- data/lib/rubocop/cop/markdown/fence_language.rb +32 -0
- data/lib/rubocop/cop/markdown/fence_style.rb +39 -0
- data/lib/rubocop/cop/markdown/first_heading.rb +44 -0
- data/lib/rubocop/cop/markdown/hard_break_style.rb +65 -0
- data/lib/rubocop/cop/markdown/hard_tabs.rb +32 -0
- data/lib/rubocop/cop/markdown/heading_blank_lines.rb +37 -0
- data/lib/rubocop/cop/markdown/heading_increment.rb +23 -0
- data/lib/rubocop/cop/markdown/heading_indentation.rb +37 -0
- data/lib/rubocop/cop/markdown/heading_punctuation.rb +23 -0
- data/lib/rubocop/cop/markdown/heading_structure.rb +33 -0
- data/lib/rubocop/cop/markdown/heading_style.rb +24 -0
- data/lib/rubocop/cop/markdown/image_alt_text.rb +24 -0
- data/lib/rubocop/cop/markdown/image_path_separators.rb +32 -0
- data/lib/rubocop/cop/markdown/link_fragment.rb +36 -0
- data/lib/rubocop/cop/markdown/link_style.rb +29 -0
- data/lib/rubocop/cop/markdown/link_text_spacing.rb +34 -0
- data/lib/rubocop/cop/markdown/list_blank_lines.rb +38 -0
- data/lib/rubocop/cop/markdown/list_continuation_indentation.rb +59 -0
- data/lib/rubocop/cop/markdown/list_indentation.rb +28 -0
- data/lib/rubocop/cop/markdown/list_marker_spacing.rb +44 -0
- data/lib/rubocop/cop/markdown/ordered_list_numbering.rb +35 -0
- data/lib/rubocop/cop/markdown/outside_spacing.rb +88 -0
- data/lib/rubocop/cop/markdown/proper_names.rb +51 -0
- data/lib/rubocop/cop/markdown/raw_html.rb +60 -0
- data/lib/rubocop/cop/markdown/reference_definitions.rb +37 -0
- data/lib/rubocop/cop/markdown/reversed_link.rb +20 -0
- data/lib/rubocop/cop/markdown/shell_prompts.rb +72 -0
- data/lib/rubocop/cop/markdown/single_top_level_heading.rb +19 -0
- data/lib/rubocop/cop/markdown/strong_style.rb +33 -0
- data/lib/rubocop/cop/markdown/structural_line_length.rb +51 -0
- data/lib/rubocop/cop/markdown/syntax.rb +33 -0
- data/lib/rubocop/cop/markdown/table_blank_lines.rb +46 -0
- data/lib/rubocop/cop/markdown/table_columns.rb +23 -0
- data/lib/rubocop/cop/markdown/table_pipes.rb +45 -0
- data/lib/rubocop/cop/markdown/table_spacing.rb +62 -0
- data/lib/rubocop/cop/markdown/thematic_break_blank_lines.rb +115 -0
- data/lib/rubocop/cop/markdown/thematic_break_style.rb +74 -0
- data/lib/rubocop/cop/markdown/trailing_whitespace.rb +55 -0
- data/lib/rubocop/cop/markdown/unclosed_fenced_code_block.rb +82 -0
- data/lib/rubocop/cop/markdown/undefined_reference.rb +25 -0
- data/lib/rubocop/cop/markdown/unordered_list_indentation.rb +37 -0
- data/lib/rubocop/cop/markdown/unordered_list_marker.rb +45 -0
- data/lib/rubocop/cop/prose/base.rb +55 -0
- data/lib/rubocop/cop/prose/max_length.rb +93 -0
- data/lib/rubocop/cop/prose/multiple_blank_lines.rb +96 -0
- data/lib/rubocop/cop/prose/trailing_newline.rb +26 -0
- data/lib/rubocop/cop/text/base.rb +17 -0
- data/lib/rubocop/cop/text/trailing_whitespace.rb +25 -0
- data/lib/rubocop/prose/code_rules.rb +79 -0
- data/lib/rubocop/prose/document.rb +62 -0
- data/lib/rubocop/prose/file_types.rb +56 -0
- data/lib/rubocop/prose/heading_rules.rb +54 -0
- data/lib/rubocop/prose/inline_rules.rb +213 -0
- data/lib/rubocop/prose/link_rules.rb +630 -0
- data/lib/rubocop/prose/list_rules.rb +65 -0
- data/lib/rubocop/prose/markdown_document.rb +167 -0
- data/lib/rubocop/prose/parser.rb +80 -0
- data/lib/rubocop/prose/plugin.rb +30 -0
- data/lib/rubocop/prose/runner.rb +63 -0
- data/lib/rubocop/prose/source.rb +82 -0
- data/lib/rubocop/prose/structural_blank_lines.rb +90 -0
- data/lib/rubocop/prose/table_rules.rb +71 -0
- data/lib/rubocop/prose/text_document.rb +54 -0
- data/lib/rubocop/prose/version.rb +7 -0
- data/lib/rubocop-prose.rb +30 -0
- metadata +335 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Markdown/TableBlankLines
|
|
2
|
+
|
|
3
|
+
Adds blank lines around Markdown tables without changing their rows or blockquote nesting. Document boundaries need no padding; empty blockquote lines count as blank.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
Markdown/TableBlankLines:
|
|
9
|
+
Enabled: true
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
### Bad
|
|
15
|
+
|
|
16
|
+
```markdown
|
|
17
|
+
Before.
|
|
18
|
+
| A | B |
|
|
19
|
+
| --- | --- |
|
|
20
|
+
| one | two |
|
|
21
|
+
After.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Good
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
Before.
|
|
28
|
+
|
|
29
|
+
| A | B |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| one | two |
|
|
32
|
+
|
|
33
|
+
After.
|
|
34
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Markdown/TableColumns
|
|
2
|
+
|
|
3
|
+
Requires delimiter and body rows to have the same number of cells as the header. Empty cells count; escaped pipes and pipes inside inline code are cell content.
|
|
4
|
+
|
|
5
|
+
Report-only: adding or removing cells can lose content.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/TableColumns:
|
|
11
|
+
Enabled: true
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
### Bad
|
|
17
|
+
|
|
18
|
+
```markdown
|
|
19
|
+
| A | B |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| one |
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Good
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
| A | B |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| one | two |
|
|
30
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Markdown/TablePipes
|
|
2
|
+
|
|
3
|
+
Enforces leading and trailing table pipes. Consistent mode follows each table's header.
|
|
4
|
+
|
|
5
|
+
Autocorrection preserves cell contents. Removing pipes from single-column tables or empty boundary cells is report-only when it could change the table's meaning.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/TablePipes:
|
|
11
|
+
Enabled: true
|
|
12
|
+
Style: consistent # consistent, leading_and_trailing, leading_only, trailing_only or no_leading_or_trailing.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
For this configuration:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
Markdown/TablePipes:
|
|
21
|
+
Style: leading_and_trailing
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Bad
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
A | B
|
|
28
|
+
--- | ---
|
|
29
|
+
one | two
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Good
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
| A | B |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| one | two |
|
|
38
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Markdown/TableSpacing
|
|
2
|
+
|
|
3
|
+
Formats table padding without changing cell contents: `aligned` pads columns to their widest source cell, `compact` uses one space beside pipes, and `tight` removes padding.
|
|
4
|
+
|
|
5
|
+
Alignment counts source characters, not display width. Empty cells stay empty.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/TableSpacing:
|
|
11
|
+
Enabled: true
|
|
12
|
+
Style: aligned # aligned, compact or tight.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
For this configuration:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
Markdown/TableSpacing:
|
|
21
|
+
Style: compact
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Bad
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
|A|B|
|
|
28
|
+
|---|---|
|
|
29
|
+
|one|two|
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Good
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
| A | B |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| one | two |
|
|
38
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Markdown/ThematicBreakBlankLines
|
|
2
|
+
|
|
3
|
+
Requires one blank line above and below each parsed thematic break. Document boundaries and a preceding front-matter header do not require padding. Blockquote markers and list indentation are retained on inserted blank lines.
|
|
4
|
+
|
|
5
|
+
For counts above one, also raise [Prose/MultipleBlankLines](../prose/multiple_blank_lines.md)'s `Max` to permit them.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/ThematicBreakBlankLines:
|
|
11
|
+
Enabled: true
|
|
12
|
+
LinesAbove: 1 # Nonnegative minimum; zero disables checks above breaks.
|
|
13
|
+
LinesBelow: 1 # Nonnegative minimum; zero disables checks below breaks.
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
### Bad
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
***
|
|
22
|
+
After.
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Good
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
***
|
|
29
|
+
|
|
30
|
+
After.
|
|
31
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Markdown/ThematicBreakStyle
|
|
2
|
+
|
|
3
|
+
Enforces one configured thematic-break spelling, permits a configured list of spellings, or follows the first break's exact spelling in consistent mode. Autocorrection preserves indentation and blockquote nesting; when a list permits multiple spellings, invalid breaks are reported without correction because their intended meaning is ambiguous.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
Markdown/ThematicBreakStyle:
|
|
9
|
+
Enabled: true
|
|
10
|
+
Style: consistent
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Example
|
|
14
|
+
|
|
15
|
+
For this configuration:
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
Markdown/ThematicBreakStyle:
|
|
19
|
+
Style:
|
|
20
|
+
- '---'
|
|
21
|
+
- '-----'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Incorrect
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
Before.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
After.
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Correct
|
|
35
|
+
|
|
36
|
+
```markdown
|
|
37
|
+
Before.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
Between.
|
|
42
|
+
|
|
43
|
+
-----
|
|
44
|
+
|
|
45
|
+
After.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Both configured spellings are accepted. A disallowed spelling is reported but not automatically replaced when multiple alternatives are configured.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Markdown/TrailingWhitespace
|
|
2
|
+
|
|
3
|
+
Trims trailing whitespace while preserving paragraph hard breaks at the configured width. Hard-break width must be positive.
|
|
4
|
+
|
|
5
|
+
When [Markdown/HardBreakStyle](hard_break_style.md) is enabled, that cop selects the hard-break syntax and this cop avoids overlapping corrections.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/TrailingWhitespace:
|
|
11
|
+
Enabled: true
|
|
12
|
+
HardBreakSpaces: 2 # Must be an integer of at least 2.
|
|
13
|
+
CodeBlocks: false # When true, code whitespace is report-only to preserve embedded strings.
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Example
|
|
17
|
+
|
|
18
|
+
Inputs are shown as Ruby strings so tabs, trailing spaces, and newline characters are visible.
|
|
19
|
+
|
|
20
|
+
### Bad
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
"A paragraph. \n"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Good
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
"A paragraph.\n"
|
|
30
|
+
```
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Markdown/UnclosedFencedCodeBlock
|
|
2
|
+
|
|
3
|
+
Reports fenced code blocks that reach the end of the document without an explicit closing fence. End-of-file termination is valid Markdown, but an explicit closer can prevent later content from being swallowed after an editing mistake.
|
|
4
|
+
|
|
5
|
+
This cop is report-only and points to the opening fence; it does not guess where a closing fence belongs.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/UnclosedFencedCodeBlock:
|
|
11
|
+
Enabled: true
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
### Bad
|
|
17
|
+
|
|
18
|
+
````markdown
|
|
19
|
+
```ruby
|
|
20
|
+
puts 'hello'
|
|
21
|
+
````
|
|
22
|
+
|
|
23
|
+
### Good
|
|
24
|
+
|
|
25
|
+
````markdown
|
|
26
|
+
```ruby
|
|
27
|
+
puts 'hello'
|
|
28
|
+
```
|
|
29
|
+
````
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Markdown/UndefinedReference
|
|
2
|
+
|
|
3
|
+
Reports undefined full `[text][id]` and collapsed `[id][]` link or image references. Definitions can appear anywhere; IDs ignore case and repeated whitespace.
|
|
4
|
+
|
|
5
|
+
Optional shortcut checking may flag ordinary bracketed prose. Task-list markers and footnotes are not references. Report-only.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/UndefinedReference:
|
|
11
|
+
Enabled: true
|
|
12
|
+
ShortcutSyntax: false # Set true to check unresolved [word] references too.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
### Bad
|
|
18
|
+
|
|
19
|
+
```markdown
|
|
20
|
+
[Read the guide][missing]
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Good
|
|
24
|
+
|
|
25
|
+
```markdown
|
|
26
|
+
[Read the guide][docs]
|
|
27
|
+
|
|
28
|
+
[docs]: /guide
|
|
29
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Markdown/UnorderedListIndentation
|
|
2
|
+
|
|
3
|
+
Requires top-level unordered markers at zero indentation and nested markers at the configured offset from their parent. Under an ordered parent, the offset is at least the width of the parent's marker and following spacing, so the child can align with its content. A deeper blockquote starts a fresh baseline.
|
|
4
|
+
|
|
5
|
+
Indentation counts source characters, not tab stops. Report-only: moving a list can change its continuation blocks.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/UnorderedListIndentation:
|
|
11
|
+
Enabled: true
|
|
12
|
+
Indent: 2 # Characters beyond the parent marker, or its content offset if wider and ordered.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
### Bad
|
|
18
|
+
|
|
19
|
+
```markdown
|
|
20
|
+
- Parent
|
|
21
|
+
- Child
|
|
22
|
+
|
|
23
|
+
1. Ordered parent
|
|
24
|
+
|
|
25
|
+
- Child
|
|
26
|
+
|
|
27
|
+
10. Wider ordered parent
|
|
28
|
+
|
|
29
|
+
- Child
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Good
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
- Parent
|
|
36
|
+
- Child
|
|
37
|
+
|
|
38
|
+
1. Ordered parent
|
|
39
|
+
|
|
40
|
+
- Child
|
|
41
|
+
|
|
42
|
+
10. Wider ordered parent
|
|
43
|
+
|
|
44
|
+
- Child
|
|
45
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Markdown/UnorderedListMarker
|
|
2
|
+
|
|
3
|
+
Enforces a configured unordered list marker or follows the first marker in consistent mode, including nested lists and blockquotes.
|
|
4
|
+
|
|
5
|
+
Autocorrection changes only the marker and is withheld if it could create a thematic break.
|
|
6
|
+
|
|
7
|
+
## Configuration
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown/UnorderedListMarker:
|
|
11
|
+
Enabled: true
|
|
12
|
+
EnforcedStyle: consistent # consistent, asterisk, plus or dash.
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
For this configuration:
|
|
18
|
+
|
|
19
|
+
```yaml
|
|
20
|
+
Markdown/UnorderedListMarker:
|
|
21
|
+
EnforcedStyle: dash
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Bad
|
|
25
|
+
|
|
26
|
+
```markdown
|
|
27
|
+
* one
|
|
28
|
+
* two
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Good
|
|
32
|
+
|
|
33
|
+
```markdown
|
|
34
|
+
- one
|
|
35
|
+
- two
|
|
36
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Prose/MaxLength
|
|
2
|
+
|
|
3
|
+
Wraps or unwraps Markdown and plain-text paragraphs. Markdown formatting preserves nesting, hard breaks, and inline syntax; headings, tables, and code blocks are not reformatted.
|
|
4
|
+
|
|
5
|
+
See [To Wrap or Not to Wrap in Markdown](https://code.dblock.org/2021/06/07/to-wrap-or-not-to-wrap-in-markdown.html) for the rationale behind unwrapped Markdown paragraphs.
|
|
6
|
+
|
|
7
|
+
`Max: false` joins soft line breaks with one space, retaining paragraph boundaries and Markdown hard breaks, including `<br>`. Plain text treats markup literally. Indented text paragraphs and unbreakable overlong tokens can report without correction.
|
|
8
|
+
|
|
9
|
+
Use [Markdown/StructuralLineLength](../markdown/structural_line_length.md) for heading, code-block, and table limits.
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
Prose/MaxLength:
|
|
15
|
+
Enabled: true
|
|
16
|
+
Max: false # One source line per paragraph; a positive character count wraps, including container prefixes.
|
|
17
|
+
IgnoreURLs: true # Ignore paragraph lines containing only one URL.
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Example
|
|
21
|
+
|
|
22
|
+
### Bad
|
|
23
|
+
|
|
24
|
+
```markdown
|
|
25
|
+
A paragraph split
|
|
26
|
+
across two source lines.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### Good
|
|
30
|
+
|
|
31
|
+
```markdown
|
|
32
|
+
A paragraph split across two source lines.
|
|
33
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Prose/MultipleBlankLines
|
|
2
|
+
|
|
3
|
+
Removes excess consecutive blank lines while preserving paragraph separation. In Markdown, marker-only blank lines inside one parsed blockquote count toward the same limit; code blocks and ignored metadata are left alone. Plain text is checked literally without interpreting quote-looking lines as Markdown.
|
|
4
|
+
|
|
5
|
+
[Markdown/BlockquoteBlankLines](../markdown/blockquote_blank_lines.md) handles the separate case of adding markers between adjacent blockquotes.
|
|
6
|
+
|
|
7
|
+
At Markdown structural boundaries, the effective limit is at least the minimum required by the enabled [heading](../markdown/heading_blank_lines.md), [fence](../markdown/fence_blank_lines.md), [list](../markdown/list_blank_lines.md), or [table](../markdown/table_blank_lines.md) spacing cop in that file's configuration. Shared boundaries use the largest minimum, not their sum. `Max` still applies elsewhere, including document edges where no structural padding is required.
|
|
8
|
+
|
|
9
|
+
## Configuration
|
|
10
|
+
|
|
11
|
+
```yaml
|
|
12
|
+
Prose/MultipleBlankLines:
|
|
13
|
+
Enabled: true
|
|
14
|
+
Max: 1 # Non-negative integer; 0 is report-only to preserve paragraph separation.
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Example
|
|
18
|
+
|
|
19
|
+
For this configuration:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
Prose/MultipleBlankLines:
|
|
23
|
+
Max: 1
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Bad
|
|
27
|
+
|
|
28
|
+
```markdown
|
|
29
|
+
First paragraph.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Second paragraph.
|
|
33
|
+
|
|
34
|
+
> First paragraph.
|
|
35
|
+
>
|
|
36
|
+
>
|
|
37
|
+
> Second paragraph.
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Good
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
First paragraph.
|
|
44
|
+
|
|
45
|
+
Second paragraph.
|
|
46
|
+
|
|
47
|
+
> First paragraph.
|
|
48
|
+
>
|
|
49
|
+
> Second paragraph.
|
|
50
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Prose/TrailingNewline
|
|
2
|
+
|
|
3
|
+
Ensures nonempty documents end in exactly one newline, inserting a missing newline or removing trailing blank lines. Empty files are accepted; internal content is unchanged.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
Prose/TrailingNewline:
|
|
9
|
+
Enabled: true
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
Inputs are shown as Ruby strings so tabs, trailing spaces, and newline characters are visible.
|
|
15
|
+
|
|
16
|
+
### Bad
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
"A paragraph."
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Good
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
"A paragraph.\n"
|
|
26
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Text/TrailingWhitespace
|
|
2
|
+
|
|
3
|
+
Removes all trailing spaces and tabs from plain-text lines, including whitespace-only lines.
|
|
4
|
+
|
|
5
|
+
## Configuration
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
Text/TrailingWhitespace:
|
|
9
|
+
Enabled: true
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Example
|
|
13
|
+
|
|
14
|
+
Inputs are shown as Ruby strings so trailing whitespace and newline characters are visible.
|
|
15
|
+
|
|
16
|
+
### Bad
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
"A paragraph. \n"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Good
|
|
23
|
+
|
|
24
|
+
```ruby
|
|
25
|
+
"A paragraph.\n"
|
|
26
|
+
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# File selection
|
|
2
|
+
|
|
3
|
+
`Markdown/Include` and `Text/Include` select files using RuboCop's normal filename and glob patterns.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
Markdown:
|
|
9
|
+
Include:
|
|
10
|
+
- '**/*.md'
|
|
11
|
+
- '**/*.markdown'
|
|
12
|
+
- '**/*.notes'
|
|
13
|
+
Text:
|
|
14
|
+
Include:
|
|
15
|
+
- '**/*.txt'
|
|
16
|
+
- '**/*.text'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Lists replace the inherited patterns for their format; omit a list to inherit it, or use `[]` to disable that format. Per-directory configuration and `--config` work as usual.
|
|
20
|
+
|
|
21
|
+
The [default patterns](../../config/default.yml) recognize common Markdown extensions and `.txt`, including uppercase variants. Custom patterns are case-sensitive. A file matching both formats is a configuration error.
|
|
22
|
+
|
|
23
|
+
Matching files are discovered automatically, without `AllCops/Include`. Use exclusions to skip files:
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
AllCops:
|
|
27
|
+
Exclude:
|
|
28
|
+
- '**/LICENSE.txt'
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Pass `--force-exclusion` to apply exclusions to explicitly named command-line files too.
|
|
32
|
+
|
|
33
|
+
File patterns select the format, not which cops are enabled. `Prose/*` cops support both formats; `Markdown/*` and `Text/*` inspect only their own.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Front matter
|
|
2
|
+
|
|
3
|
+
By default, Markdown checks ignore a leading header opened with `---` and closed with `---` or `...`. Unclosed headers and delimiters elsewhere remain ordinary Markdown.
|
|
4
|
+
|
|
5
|
+
Set `IgnoreFrontMatter: false` to inspect the header as Markdown, not validate its YAML. RuboCop directives inside metadata remain ignored, and this setting does not change Ruby snippet extraction.
|
|
6
|
+
|
|
7
|
+
## Example
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
Markdown:
|
|
11
|
+
IgnoreFrontMatter: true
|
|
12
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../prose/heading_rules'
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module Markdown
|
|
8
|
+
class AtxHeadingSpace < Base
|
|
9
|
+
include RuboCop::Prose::HeadingRules
|
|
10
|
+
|
|
11
|
+
def investigate_document
|
|
12
|
+
heading_candidates.each do |match, number|
|
|
13
|
+
next if match[:rest].empty? || match[:rest].match?(/\A[ \t]/)
|
|
14
|
+
|
|
15
|
+
prose_offense(document.line_range(number),
|
|
16
|
+
message: 'Separate opening heading hashes from text with a space.')
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../prose/heading_rules'
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module Markdown
|
|
8
|
+
class AtxHeadingSpacing < Base
|
|
9
|
+
extend AutoCorrector
|
|
10
|
+
include RuboCop::Prose::HeadingRules
|
|
11
|
+
|
|
12
|
+
def investigate_document
|
|
13
|
+
heading_entries.each do |heading|
|
|
14
|
+
opening = heading[:opening]
|
|
15
|
+
next unless opening && (spacing = /\A[ \t]{2,}(?=\S)/.match(opening[:rest]))
|
|
16
|
+
|
|
17
|
+
column = opening.begin(:rest)
|
|
18
|
+
range = document.range(heading[:line], column, heading[:line], column + spacing[0].length)
|
|
19
|
+
prose_offense(range, message: 'Use one space after opening heading hashes.') do |corrector|
|
|
20
|
+
corrector.replace(processed_range(range), ' ')
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative '../../prose/link_rules'
|
|
4
|
+
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module Markdown
|
|
8
|
+
class BareUrl < Base
|
|
9
|
+
MSG = 'Use an autolink or a Markdown link instead of a bare URL.'
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def investigate_document
|
|
14
|
+
scanner = document.link_rules
|
|
15
|
+
scanner.bare_urls(cop_config.fetch('Schemes', %w[http https ftp])).each do |first, last|
|
|
16
|
+
prose_offense(scanner.range(first, last))
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Markdown
|
|
6
|
+
class Base < Prose::Base
|
|
7
|
+
exclude_from_registry
|
|
8
|
+
|
|
9
|
+
private
|
|
10
|
+
|
|
11
|
+
def applicable_document?
|
|
12
|
+
processed_source.prose_format == :markdown
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|