Skip to content

require-capitalization

🔧 Fixable ⭐ CommonMark 🌟 GFM

🔗 Rule Source 🔗 Test Source

Enforce the use of capital letters at the beginning of sentences.

Rule Details ​

This rule enforces the use of capital letters at the beginning of sentences in Markdown documents. Maintaining consistent capitalization improves document readability and professionalism.

The rule checks the leading text of nodes matched by the configured selectors, such as paragraphs, headings, list items, and table cells, to ensure proper capitalization. When the checked text begins with a lowercase ASCII letter (a through z), the rule reports a violation.

INFO

This rule doesn't report any errors by default. You must configure it with selectors matching the Markdown nodes you want to check.

Examples ​

❌ Incorrect ​

Examples of incorrect code for this rule:

With 'paragraph' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'paragraph'] -->

h
ello world!
>
h
ello world!
[^note]:
f
ootnote text
-
h
ello world!

With 'heading' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'heading'] -->

# 
h
ello world!

With 'tableCell' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'tableCell'] -->

| 
h
eading |
| ------- | |
c
ell |

With 'heading[depth=2]' Selector ​

This ESQuery selector checks only second-level headings.

md
<!-- eslint md/require-capitalization: ['error', 'heading[depth=2]'] -->

# hello world!

## 
h
ello world!
### hello world!

With 'table > tableRow:first-child > tableCell' Selector ​

This ESQuery selector selects table cells in the first (header) row of the table.

md
<!-- eslint md/require-capitalization: ['error', 'table > tableRow:first-child > tableCell'] -->

| 
h
eader |
| ------ | | data |

✅ Correct ​

Examples of correct code for this rule:

With 'paragraph' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'paragraph'] -->

Hello world!

> Hello world!

[^note]: Footnote text

- Hello world!

With 'heading' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'heading'] -->

# Hello world!

With 'tableCell' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'tableCell'] -->

| Heading |
| ------- |
| Cell    |

With 'heading[depth=2]' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'heading[depth=2]'] -->

# hello world!

## Hello world!

### hello world!

With 'root > paragraph' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'root > paragraph'] -->

Hello world!

# hello world!

- hello world!

With 'table > tableRow:first-child > tableCell' Selector ​

md
<!-- eslint md/require-capitalization: ['error', 'table > tableRow:first-child > tableCell'] -->

| Header |
| ------ |
| data   |

Options ​

Like ESLint's no-restricted-syntax, this rule accepts a list of AST selector strings:

js
'md/require-capitalization': ['error', 'paragraph', 'heading', 'tableCell']

Selectors match Markdown AST nodes. For example, 'heading' selects all headings, while 'heading[depth=2]' selects only second-level headings. Use ESLint Code Explorer with Markdown selected to inspect node types and properties.

Alternatively, each option can be an object with:

  • selector (required): The AST selector to check.
  • message (optional): The message reported for violations matching that selector. When omitted, the default message is used, for example: `h` should be capitalized.

Selectors and custom messages must be non-empty strings. String and object options can be mixed:

js
'md/require-capitalization': ['error',
  'paragraph',
  {
    selector: 'heading',
    message: 'Headings must begin with a capital letter.',
  },
]

Fix ​

This rule fixes the reported lowercase letter by replacing it with its uppercase form.

When Not To Use It ​

You can disable this rule if your documentation style, technical terminology, or language does not require initial capitalization.

Prior Art ​