You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add unit tests for fixInfo and edge cases across custom rules.
- fenced-code-under-heading: require H2–H6 in range above blocks; no-heading-like-lines: avoid matching **:**; one-sentence-per-line fixes.
- README and markdownlint-rules README: fixture wording, Node.js/utils.js formatting; expected_errors and test-scripts updates.
Copy file name to clipboardExpand all lines: README.md
+2-5Lines changed: 2 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,9 +73,7 @@ Lint and docs-as-code tooling: custom [markdownlint](https://github.com/DavidAns
73
73
- Use when: copying the rule files; required by several of the rules above.
74
74
75
75
-**JS linting** for the rule code: ESLint (recommended + complexity/max-lines + eslint-plugin-security), aligned with the GitHub Actions workflow.
76
-
-**Markdownlint fixture tests**: [md_test_files/](md_test_files/README.md) includes positive_*.
77
-
md and negative_*.
78
-
md fixtures with explicit expected errors, verified by `test-scripts/verify_markdownlint_fixtures.py`.
76
+
-**Markdownlint fixture tests**: [md_test_files/](md_test_files/README.md) includes `positive_*.md` and `negative_*.md` fixtures with explicit expected errors, verified by `test-scripts/verify_markdownlint_fixtures.py`.
79
77
-**Rule unit tests**: Node `node:test` unit tests for each custom rule in `test/markdownlint-rules/` (including security tests for defensive regex handling and ReDoS awareness); run with `make test-rules` or `npm run test:rules`.
80
78
CI runs `make test-rules-coverage` (fails if any rule file is below 90% line/statement coverage).
81
79
-**Python unit tests**: `unittest` tests for [test-scripts/](test-scripts/README.md) in `test-scripts/test_*.py`; run with `make test-python`.
@@ -86,8 +84,7 @@ See **[markdownlint-rules/README.md](markdownlint-rules/README.md)** for rule do
86
84
87
85
## Requirements
88
86
89
-
- Node.
90
-
js and npm (for JS linting)
87
+
-`Node.js` and npm (for JS linting)
91
88
- Python 3 (for repo test scripts and `make lint-python`)
92
89
-[markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) and config (`.markdownlint-cli2.jsonc`, `.markdownlint.yml`) when using the custom rules in another repo
Copy file name to clipboardExpand all lines: markdownlint-rules/README.md
+8-13Lines changed: 8 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,8 @@ In this repo they are registered in [.markdownlint-cli2.jsonc](../.markdownlint-
25
25
You can reuse any of them in your own project; see [Reusing These Rules](#reusing-these-rules) below.
26
26
Some rules are **fixable** (heading-title-case, ascii-only, heading-numbering, no-heading-like-lines, one-sentence-per-line): they report `fixInfo` so `markdownlint-cli2 --fix` and the editor "Fix all" can apply corrections automatically.
27
27
28
-
-**Requirements:** Node.
29
-
js and [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) (or the [markdownlint](https://github.com/DavidAnson/markdownlint) core with custom rule support).
30
-
When reusing rules, copy any helper files they depend on; see [Shared Helper](#shared-helper) for which rules require **utils.
31
-
js**.
28
+
-**Requirements:**`Node.js` and [markdownlint-cli2](https://github.com/DavidAnson/markdownlint-cli2) (or the [markdownlint](https://github.com/DavidAnson/markdownlint) core with custom rule support).
29
+
When reusing rules, copy any helper files they depend on; see [Shared Helper](#shared-helper) for which rules require `utils.js`.
32
30
-**Rule modules**: Each `*.js` file here (except `utils.js`) is a custom rule.
33
31
-**Config**: Rule-specific options are set under the rule name in a markdownlint config file.
34
32
You can use `.markdownlint.yml` or `.markdownlint.json` (markdownlint accepts either).
@@ -42,8 +40,7 @@ To use one or more of these rules in another repo:
42
40
1. Create a `.markdownlint-rules` directory in that repo (if it does not exist).
43
41
2. Copy the rule file(s) you want (e.g. `ascii-only.js`, `no-heading-like-lines.js`) into `.markdownlint-rules`.
44
42
3. If a rule depends on helpers, copy those too.
45
-
Most rules require **utils.
46
-
js** (see [Shared Helper](#shared-helper) for the full list).
43
+
Most rules require `utils.js` (see [Shared Helper](#shared-helper) for the full list).
47
44
Copy `utils.js` into `.markdownlint-rules` and do **not** list it in `customRules` (see below).
48
45
**no-heading-like-lines** optionally uses `heading-title-case.js` and `heading-numbering.js` when `convertToHeading: true` (for AP title case and number prefixes); copy those into the same directory only if you want that behavior.
49
46
4. In the repo root, in `.markdownlint-cli2.jsonc` (or your config file), add the rule name(s) to the `customRules` array and set `customRulePaths` so it points at your `.markdownlint-rules` folder (see [markdownlint-cli2 custom rules](https://github.com/DavidAnson/markdownlint-cli2#custom-rules)).
@@ -298,7 +295,8 @@ document-length:
298
295
Must be a positive integer.
299
296
- **`excludePathPatterns`** (list of strings, default none): Glob patterns for file paths where this rule is skipped.
300
297
301
-
**Behavior:** When the file has more than `maximum` lines, the rule reports a single error on line 1. The message includes the actual line count and the maximum and suggests splitting into smaller files.
298
+
**Behavior:** When the file has more than `maximum` lines, the rule reports a single error on line 1.
299
+
The message includes the actual line count and the maximum and suggests splitting into smaller files.
302
300
303
301
### `ascii-only`
304
302
@@ -634,18 +632,15 @@ one-sentence-per-line:
634
632
635
633
## Shared Helper
636
634
637
-
**utils.
638
-
js** is not a rule; it provides utilities used by all custom rules in this repo.
635
+
`utils.js`is not a rule; it provides utilities used by all custom rules in this repo.
639
636
Do not list it in `customRules` in `.markdownlint-cli2.jsonc`.
640
637
When reusing any rule, copy `utils.js` into your `.markdownlint-rules` (see [Reusing These Rules](#reusing-these-rules)).
- **Path/glob matching:** `globToRegExp`, `matchGlob`, `pathMatchesAny` - used for `excludePathPatterns` and other path options (e.g. ascii-only `allowedPathPatternsUnicode`).
Copy file name to clipboardExpand all lines: markdownlint-rules/no-heading-like-lines.js
+80-49Lines changed: 80 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -29,10 +29,10 @@ try {
29
29
}
30
30
/* c8 ignore stop */
31
31
32
-
/** Patterns: [regex, description]. Order matches EXTRACTORS. Includes MD036-style whole-line emphasis. */
32
+
/** Patterns: [regex, description]. Order matches EXTRACTORS. Includes MD036-style whole-line emphasis. Require content (.+ not .*) so **:** does not match. */
33
33
constPATTERNS=[
34
-
[/^\s*\*\*.*:\*\*\s*$/,"bold with colon inside (**Text:**)"],
35
-
[/^\s*\*\*.*\*\*:\s*$/,"bold with colon outside (**Text**:)"],
34
+
[/^\s*\*\*.+:\*\*\s*$/,"bold with colon inside (**Text:**)"],
35
+
[/^\s*\*\*.+\*\*:\s*$/,"bold with colon outside (**Text**:)"],
36
36
[/^\s*[0-9]+\.\s+\*\*.*\*\*\s*$/,"numbered list with bold (1. **Text**)"],
37
37
[/^\s*\*.*:\*\s*$/,"italic with colon inside (*Text:*)"],
38
38
[/^\s*\*.*\*:\s*$/,"italic with colon outside (*Text*:)"],
@@ -123,66 +123,97 @@ function buildConvertToHeadingInsertText(opts) {
123
123
returnheadingLine;
124
124
}
125
125
126
+
/** True when pattern p matched but content is only colon (e.g. **:**); skip reporting. */
0 commit comments