Skip to content

Commit 3c472a4

Browse files
committed
Merge branch 'main' into no-html-location-reporting
2 parents 843a4b3 + e4b8de4 commit 3c472a4

39 files changed

+4254
-339
lines changed

.c8rc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"include": ["src/**/*.js"],
3+
"reporter": ["lcov", "text-summary", "cobertura"],
4+
"sourceMap": true
5+
}
Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
name: Add to Triage
1+
name: add-to-triage
22

33
on:
44
issues:
55
types:
66
- opened
7+
- reopened
8+
- transferred
9+
10+
pull_request_target:
11+
types:
12+
- opened
13+
- reopened
714

815
jobs:
9-
add-to-project:
10-
name: Add issue to project
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/[email protected]
14-
with:
15-
project-url: https://github.com/orgs/eslint/projects/3
16-
github-token: ${{ secrets.PROJECT_BOT_TOKEN }}
17-
labeled: "triage:no"
18-
label-operator: NOT
16+
add-to-triage:
17+
uses: eslint/workflows/.github/workflows/add-to-triage.yml@main
18+
secrets:
19+
project_bot_token: ${{ secrets.PROJECT_BOT_TOKEN }}

.github/workflows/stale.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: stale
2+
3+
on:
4+
schedule:
5+
- cron: "31 22 * * *" # Runs every day at 10:31 PM UTC
6+
7+
jobs:
8+
stale:
9+
uses: eslint/workflows/.github/workflows/stale.yml@main
10+
secrets:
11+
token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export default defineConfig([
102102
| [`no-missing-link-fragments`](./docs/rules/no-missing-link-fragments.md) | Disallow link fragments that do not reference valid headings | yes |
103103
| [`no-multiple-h1`](./docs/rules/no-multiple-h1.md) | Disallow multiple H1 headings in the same document | yes |
104104
| [`no-reversed-media-syntax`](./docs/rules/no-reversed-media-syntax.md) | Disallow reversed link and image syntax | yes |
105+
| [`no-space-in-emphasis`](./docs/rules/no-space-in-emphasis.md) | Disallow spaces around emphasis markers | yes |
105106
| [`no-unused-definitions`](./docs/rules/no-unused-definitions.md) | Disallow unused definitions | yes |
106107
| [`require-alt-text`](./docs/rules/require-alt-text.md) | Require alternative text for images | yes |
107108
| [`table-column-count`](./docs/rules/table-column-count.md) | Disallow data rows in a GitHub Flavored Markdown table from having more cells than the header row | yes |

docs/rules/no-html.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,49 @@ The following options are available on this rule:
2626

2727
* `allowed: Array<string>` - when specified, HTML tags are allowed only if they match one of the tags in this array. (default: `[]`)
2828

29-
Examples of **incorrect** code when configured as `"no-html": ["error", { allowed: ["b"] }]`:
29+
Examples of **incorrect** code when configured as `"no-html": ["error", { allowed: ["b"] }]`:
3030

31-
```markdown
32-
<!-- eslint markdown/no-html: ["error", { allowed: ["b"] }] -->
31+
```markdown
32+
<!-- eslint markdown/no-html: ["error", { allowed: ["b"] }] -->
3333

34-
# Heading 1
34+
# Heading 1
3535

36-
Hello <em>world!</em>
37-
```
36+
Hello <em>world!</em>
37+
```
3838

39-
Examples of **correct** code when configured as `"no-html": ["error", { allowed: ["b"] }]`:
39+
Examples of **correct** code when configured as `"no-html": ["error", { allowed: ["b"] }]`:
4040

41-
```markdown
42-
<!-- eslint markdown/no-html: ["error", { allowed: ["b"] }] -->
41+
```markdown
42+
<!-- eslint markdown/no-html: ["error", { allowed: ["b"] }] -->
4343

44-
# Heading 1
44+
# Heading 1
4545

46-
Hello <b>world!</b>
47-
```
46+
Hello <b>world!</b>
47+
```
48+
49+
* `allowedIgnoreCase: boolean` - when `true`, enables case-insensitive matching of HTML tag names against the `allowed` array described above. (default: `false`)
50+
51+
Examples of **incorrect** code when configured as `"no-html": ["error", { allowed: ["DIV"], allowedIgnoreCase: false }]`:
52+
53+
```markdown
54+
<!-- eslint markdown/no-html: ["error", { allowed: ["DIV"], allowedIgnoreCase: false }] -->
55+
56+
# Heading 1
57+
58+
<div>Hello world!</div>
59+
```
60+
61+
Examples of **correct** code when configured as `"no-html": ["error", { allowed: ["DIV"], allowedIgnoreCase: true }]`:
62+
63+
```markdown
64+
<!-- eslint markdown/no-html: ["error", { allowed: ["DIV"], allowedIgnoreCase: true }] -->
65+
66+
# Heading 1
67+
68+
<div>Hello world!</div>
69+
<DIV>Hello world!</DIV>
70+
<DiV>Hello world!</DiV>
71+
```
4872

4973
## When Not to Use It
5074

docs/rules/no-missing-atx-heading-space.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This rule warns when spaces are missing after the hash characters in an ATX styl
44

55
## Rule Details
66

7-
In Markdown, headings can be created using ATX style (using hash (`#`) characters at the beginning of the line) or Setext style (using underlining with equals (`=`) or hyphens (`-`)).
7+
In Markdown, headings can be created using ATX style (using hash (`#`) characters at the beginning of the line, with optional closing hash characters) or Setext style (using underlining with equals (`=`) or hyphens (`-`)).
88

99
For ATX style headings, a space should be used after the hash characters to improve readability and ensure proper rendering across various Markdown parsers.
1010

@@ -38,13 +38,40 @@ Examples of **correct** code for this rule:
3838
This is a paragraph with a #hashtag, not a heading.
3939
```
4040

41+
## Options
42+
43+
The following options are available on this rule:
44+
45+
* `checkClosedHeadings: boolean` - When set to `true`, the rule will also check for missing spaces before closing hash characters in ATX headings. (default: `false`)
46+
47+
Examples of **incorrect** code when configured as `"no-missing-atx-heading-space": ["error", { checkClosedHeadings: true }]`:
48+
49+
```markdown
50+
<!-- eslint markdown/no-missing-atx-heading-space: ["error", { checkClosedHeadings: true }] -->
51+
52+
# Heading 1#
53+
## Heading 2##
54+
### Heading 3###
55+
```
56+
57+
Examples of **correct** code when configured as `"no-missing-atx-heading-space": ["error", { checkClosedHeadings: true }]`:
58+
59+
```markdown
60+
<!-- eslint markdown/no-missing-atx-heading-space: ["error", { checkClosedHeadings: true }] -->
61+
62+
# Heading 1 #
63+
## Heading 2 ##
64+
### Heading 3 ###
65+
```
66+
4167
## When Not To Use It
4268

4369
You might want to turn this rule off if you're working with a Markdown variant that doesn't require spaces after hash characters in headings.
4470

4571
## Prior Art
4672

4773
- [MD018 - No space after hash on atx style heading](https://github.com/DavidAnson/markdownlint/blob/main/doc/md018.md)
74+
- [MD020 - No space inside hashes on closed atx style heading](https://github.com/DavidAnson/markdownlint/blob/main/doc/md020.md)
4875

4976
## Further Reading
5077

docs/rules/no-reversed-media-syntax.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ Examples of **incorrect** code for this rule:
1818
(ESLint)[https://eslint.org/]
1919

2020
!(A beautiful sunset)[sunset.png]
21+
22+
# (ESLint)[https://eslint.org/]
23+
24+
# !(A beautiful sunset)[sunset.png]
25+
26+
| ESLint | Sunset |
27+
| ----------------------------- | --------------------------------- |
28+
| (ESLint)[https://eslint.org/] | !(A beautiful sunset)[sunset.png] |
2129
```
2230

2331
Examples of **correct** code for this rule:
@@ -28,6 +36,14 @@ Examples of **correct** code for this rule:
2836
[ESLint](https://eslint.org/)
2937

3038
![A beautiful sunset](sunset.png)
39+
40+
# [ESLint](https://eslint.org/)
41+
42+
# ![A beautiful sunset](sunset.png)
43+
44+
| ESLint | Sunset |
45+
| ----------------------------- | --------------------------------- |
46+
| [ESLint](https://eslint.org/) | ![A beautiful sunset](sunset.png) |
3147
```
3248

3349
## When Not To Use It

docs/rules/no-space-in-emphasis.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# no-space-in-emphasis
2+
3+
Disallow spaces around emphasis markers.
4+
5+
## Background
6+
7+
In Markdown, emphasis (bold and italic) is created using asterisks (`*`) or underscores (`_`), and a strikethrough is created using tildes (`~`). The emphasis markers must be directly adjacent to the text they're emphasizing, with no spaces between the markers and the text. When spaces are present, the emphasis is not rendered correctly.
8+
9+
Please note that this rule does not check for spaces inside emphasis markers when the content is itself an emphasis (i.e., nested emphasis). For example, `**_ bold _**` and `_** italic **_` are not flagged, even though there are spaces inside the inner emphasis markers.
10+
11+
## Rule Details
12+
13+
This rule warns when it finds emphasis markers that have spaces between the markers and the text they're emphasizing.
14+
15+
Examples of **incorrect** code for this rule:
16+
17+
```markdown
18+
<!-- eslint markdown/no-space-in-emphasis: "error" -->
19+
20+
Here is some ** bold ** text.
21+
Here is some * italic * text.
22+
Here is some __ bold __ text.
23+
Here is some _ italic _ text.
24+
Here is some *** bold italic *** text.
25+
Here is some ___ bold italic ___ text.
26+
```
27+
28+
Examples of **correct** code for this rule:
29+
30+
```markdown
31+
<!-- eslint markdown/no-space-in-emphasis: "error" -->
32+
33+
Here is some **bold** text.
34+
Here is some *italic* text.
35+
Here is some __bold__ text.
36+
Here is some _italic_ text.
37+
Here is some ***bold italic*** text.
38+
Here is some ___bold italic___ text.
39+
Here is some **_ bold _** text.
40+
Here is some _** italic **_ text.
41+
```
42+
43+
## Options
44+
45+
The following options are available on this rule:
46+
47+
* `checkStrikethrough: boolean` - when `true`, also check for spaces around strikethrough markers (`~` and `~~`). (default: `false`)
48+
49+
> [!IMPORTANT] <!-- eslint-disable-line -- This should be fixed in https://github.com/eslint/markdown/issues/294 -->
50+
>
51+
> Use `checkStrikethrough` with `language: "markdown/gfm"`; in CommonMark, `~`/`~~` aren’t strikethrough (they’ll still be linted if enabled).
52+
53+
Examples of **incorrect** code when configured as `"no-space-in-emphasis": ["error", { checkStrikethrough: true }]`:
54+
55+
```markdown
56+
<!-- eslint markdown/no-space-in-emphasis: ["error", { checkStrikethrough: true }] -->
57+
58+
Here is some ~ strikethrough ~ text.
59+
Here is some ~~ strikethrough ~~ text.
60+
```
61+
62+
Examples of **correct** code when configured as `"no-space-in-emphasis": ["error", { checkStrikethrough: true }]`:
63+
64+
```markdown
65+
<!-- eslint markdown/no-space-in-emphasis: ["error", { checkStrikethrough: true }] -->
66+
67+
Here is some ~strikethrough~ text.
68+
Here is some ~~strikethrough~~ text.
69+
```
70+
71+
## When Not to Use It
72+
73+
If you aren't concerned with proper emphasis rendering in your Markdown documents, you can safely disable this rule.
74+
75+
## Prior Art
76+
77+
* [MD037 - Spaces inside emphasis markers](https://github.com/DavidAnson/markdownlint/blob/main/doc/md037.md)

eslint.config.js

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import globals from "globals";
66
import eslintConfigESLint from "eslint-config-eslint";
77
import eslintPlugin from "eslint-plugin-eslint-plugin";
88
import markdown from "./src/index.js";
9-
import { defineConfig } from "eslint/config";
9+
import { defineConfig, globalIgnores } from "eslint/config";
10+
import json from "@eslint/json";
1011

1112
//-----------------------------------------------------------------------------
1213
// Helpers
@@ -22,7 +23,15 @@ const eslintPluginTestsRecommendedConfig =
2223
//-----------------------------------------------------------------------------
2324

2425
export default defineConfig([
25-
eslintConfigESLint,
26+
globalIgnores(
27+
["**/examples/", "coverage/", "dist/", "src/build/", "tests/fixtures/"],
28+
"markdown/ignores",
29+
),
30+
31+
...eslintConfigESLint.map(config => ({
32+
files: ["**/*.js"],
33+
...config,
34+
})),
2635
{
2736
name: "markdown/js",
2837
files: ["**/*.js"],
@@ -36,16 +45,6 @@ export default defineConfig([
3645
markdown,
3746
},
3847
},
39-
{
40-
name: "markdown/ignores",
41-
ignores: [
42-
"**/examples",
43-
"**/coverage",
44-
"**/tests/fixtures",
45-
"dist",
46-
"src/build/",
47-
],
48-
},
4948
{
5049
name: "markdown/tools",
5150
files: ["tools/**/*.js"],
@@ -133,4 +132,10 @@ export default defineConfig([
133132
"eslint-plugin/test-case-shorthand-strings": "error",
134133
},
135134
},
135+
{
136+
plugins: { json },
137+
files: ["**/*.json", ".c8rc"],
138+
language: "json/json",
139+
extends: ["json/recommended"],
140+
},
136141
]);

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@
6868
"build": "npm run build:rules && tsc && npm run build:update-rules-docs",
6969
"build:readme": "node tools/update-readme.js",
7070
"prepare": "npm run build",
71-
"test": "c8 mocha \"tests/**/*.test.js\" --timeout 30000",
71+
"test": "mocha \"tests/**/*.test.js\" --timeout 30000",
72+
"test:coverage": "c8 npm test",
7273
"test:jsr": "npx jsr@latest publish --dry-run",
7374
"test:types": "tsc -p tests/types/tsconfig.json"
7475
},
7576
"devDependencies": {
7677
"@eslint/js": "^9.31.0",
77-
"c8": "^10.1.2",
78+
"@eslint/json": "^0.13.1",
79+
"c8": "^10.1.3",
7880
"dedent": "^1.5.3",
7981
"eslint": "^9.31.0",
8082
"eslint-config-eslint": "^11.0.0",
@@ -84,18 +86,19 @@
8486
"lint-staged": "^15.2.9",
8587
"mocha": "^11.6.0",
8688
"prettier": "^3.3.3",
87-
"typescript": "^5.8.3",
89+
"typescript": "^5.9.2",
8890
"yorkie": "^2.0.0"
8991
},
9092
"dependencies": {
91-
"@eslint/core": "^0.15.1",
92-
"@eslint/plugin-kit": "^0.3.4",
93+
"@eslint/core": "^0.15.2",
94+
"@eslint/plugin-kit": "^0.3.5",
9395
"github-slugger": "^2.0.0",
9496
"mdast-util-from-markdown": "^2.0.2",
9597
"mdast-util-frontmatter": "^2.0.1",
9698
"mdast-util-gfm": "^3.1.0",
9799
"micromark-extension-frontmatter": "^2.0.0",
98-
"micromark-extension-gfm": "^3.0.0"
100+
"micromark-extension-gfm": "^3.0.0",
101+
"micromark-util-normalize-identifier": "^2.0.1"
99102
},
100103
"engines": {
101104
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"

0 commit comments

Comments
 (0)