Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

remark-lint-first-heading-level

1.1.3 • Public • Published

remark-lint-first-heading-level

Warn when the first heading has a level other than a specified value.

Options: number, default: 1.

Presets

This rule is not included in any default preset

Example

valid.md

When configured with 2.

In
## Delta
 
Paragraph.
Out

No messages.

valid-html.md

When configured with 2.

In
<h2>Echo</h2>
 
Paragraph.
Out

No messages.

invalid.md

When configured with 2.

In
Foxtrot
 
Paragraph.
Out
1:1-1:10: First heading level should be `2`
invalid-html.md

When configured with 2.

In
<h1>Golf</h1>
 
Paragraph.
Out
1:1-1:14: First heading level should be `2`
valid.md
In
The default is to expect a level one heading
Out

No messages.

valid-html.md
In
<h1>An HTML heading is also seen by this rule.</h1>
Out

No messages.

valid-delayed.md
In
You can use markdown content before the heading.
 
<div>Or non-heading HTML</div>
 
<h1>So the first heading, be it HTML or markdown, is checked</h1>
Out

No messages.

invalid.md
In
## Bravo
 
Paragraph.
Out
1:1-1:9: First heading level should be `1`
invalid-html.md
In
<h2>Charlie</h2>
 
Paragraph.
Out
1:1-1:17: First heading level should be `1`

Install

npm install remark-lint-first-heading-level

Usage

You probably want to use it on the CLI through a config file:

 ...
 "remarkConfig": {
   "plugins": [
     ...
     "lint",
+    "lint-first-heading-level",
     ...
   ]
 }
 ...

Or use it on the CLI directly

remark -u lint -u lint-first-heading-level readme.md

Or use this on the API:

 var remark = require('remark');
 var report = require('vfile-reporter');
 
 remark()
   .use(require('remark-lint'))
+  .use(require('remark-lint-first-heading-level'))
   .process('_Emphasis_ and **importance**', function (err, file) {
     console.error(report(err || file));
   });

License

MIT © Titus Wormer

install

npm i remark-lint-first-heading-level

Downloadsweekly downloads

3,336

version

1.1.3

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability