Skip to content

Commit f1f8aaf

Browse files
committed
chore: review comments
1 parent 136e940 commit f1f8aaf

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/rules/no-missing-atx-heading-space.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
//-----------------------------------------------------------------------------
1818

1919
const HEADING_PATTERN = /^(#{1,6})(?:[^#\s])/u;
20+
const NEW_LINE_PATTERN = /\r?\n/u;
2021

2122
//-----------------------------------------------------------------------------
2223
// Rule Definition
@@ -53,7 +54,7 @@ export default {
5354
}
5455

5556
const text = context.sourceCode.getText(firstTextChild);
56-
const lines = text.split(/\r?\n/u);
57+
const lines = text.split(NEW_LINE_PATTERN);
5758

5859
lines.forEach((line, idx) => {
5960
const lineNum =

tests/rules/no-missing-atx-heading-space.test.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ const validHeadings = [
3636
"##### Heading 5",
3737
"###### Heading 6",
3838

39+
// 1.1 ATX heading-like text
40+
"####### Heading 7 (not a valid heading)",
41+
"#######Heading 7 (not a valid heading)",
42+
3943
// 2. Document with multiple headings
4044
dedent`# Heading 1
4145
@@ -45,6 +49,7 @@ const validHeadings = [
4549

4650
// 3. Variations on spacing
4751
"# Heading with extra space",
52+
"#\tHeading with tab",
4853

4954
// 4. Standalone hash
5055
"#",
@@ -66,22 +71,23 @@ const validHeadings = [
6671
"```",
6772

6873
// 7.3 Code blocks with language identifiers
69-
"``` followed by text",
70-
"~~~ followed by more text",
74+
"``` #followed #by text",
75+
"~~~ #followed #by more text",
7176

7277
// 7.4 Code block after paragraph
7378
dedent`This is a paragraph followed by code.
7479
75-
\`\`\`
76-
#This is in a code block
77-
\`\`\``,
80+
\`\`\`
81+
#This is in a code block
82+
\`\`\``,
7883

7984
// 8. Inline code with hash symbols
8085
"This paragraph has `#inline-code` which is not a heading",
8186
"Here's a code span with a hash: `const tag = '#heading'`",
8287

8388
// 9. Markdown links with hash in URLs
8489
"[#370](https://github.com/eslint/markdown/issues/370)",
90+
"![#370](https://github.com/eslint/markdown/image.png)",
8591

8692
// 10. HTML headings (not ATX-style)
8793
"<h1>Heading 1</h1>",
@@ -91,6 +97,7 @@ const validHeadings = [
9197
"<h5>Heading 5</h5>",
9298
"<h6>Heading 6</h6>",
9399
"<h1>#valid heading</h1>",
100+
"<!-- #valid heading -->",
94101

95102
// 11. Content inside single quotes and double quotes
96103
`'#something'`,
@@ -296,11 +303,11 @@ const invalidTests = [
296303
// 5.1 With code markers in context
297304
{
298305
code: dedent`Text before
299-
#Heading with \`\`\` code markers
300-
Text after`,
306+
#Heading with \`\`\` code markers
307+
Text after`,
301308
output: dedent`Text before
302-
# Heading with \`\`\` code markers
303-
Text after`,
309+
# Heading with \`\`\` code markers
310+
Text after`,
304311
errors: [
305312
{
306313
messageId: "missingSpace",

0 commit comments

Comments
 (0)