Socket
Socket
Sign inDemoInstall

remark-lint-first-heading-level

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-lint-first-heading-level - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

45

index.js

@@ -11,11 +11,11 @@ /**

*
* @example {"name": "valid.md"}
* @example {"name": "ok.md"}
*
* # The default is to expect a level one heading
*
* @example {"name": "valid-html.md"}
* @example {"name": "ok-html.md"}
*
* <h1>An HTML heading is also seen by this rule.</h1>
*
* @example {"name": "valid-delayed.md"}
* @example {"name": "ok-delayed.md"}
*

@@ -28,3 +28,3 @@ * You can use markdown content before the heading.

*
* @example {"name": "invalid.md", "label": "input"}
* @example {"name": "not-ok.md", "label": "input"}
*

@@ -35,7 +35,7 @@ * ## Bravo

*
* @example {"name": "invalid.md", "label": "output"}
* @example {"name": "not-ok.md", "label": "output"}
*
* 1:1-1:9: First heading level should be `1`
*
* @example {"name": "invalid-html.md", "label": "input"}
* @example {"name": "not-ok-html.md", "label": "input"}
*

@@ -46,7 +46,7 @@ * <h2>Charlie</h2>

*
* @example {"name": "invalid-html.md", "label": "output"}
* @example {"name": "not-ok-html.md", "label": "output"}
*
* 1:1-1:17: First heading level should be `1`
*
* @example {"name": "valid.md", "setting": 2}
* @example {"name": "ok.md", "setting": 2}
*

@@ -57,3 +57,3 @@ * ## Delta

*
* @example {"name": "valid-html.md", "setting": 2}
* @example {"name": "ok-html.md", "setting": 2}
*

@@ -64,3 +64,3 @@ * <h2>Echo</h2>

*
* @example {"name": "invalid.md", "setting": 2, "label": "input"}
* @example {"name": "not-ok.md", "setting": 2, "label": "input"}
*

@@ -71,7 +71,7 @@ * # Foxtrot

*
* @example {"name": "invalid.md", "setting": 2, "label": "output"}
* @example {"name": "not-ok.md", "setting": 2, "label": "output"}
*
* 1:1-1:10: First heading level should be `2`
*
* @example {"name": "invalid-html.md", "setting": 2, "label": "input"}
* @example {"name": "not-ok-html.md", "setting": 2, "label": "input"}
*

@@ -82,3 +82,3 @@ * <h1>Golf</h1>

*
* @example {"name": "invalid-html.md", "setting": 2, "label": "output"}
* @example {"name": "not-ok-html.md", "setting": 2, "label": "output"}
*

@@ -98,4 +98,4 @@ * 1:1-1:14: First heading level should be `2`

function firstHeadingLevel(tree, file, pref) {
var style = pref && pref !== true ? pref : 1
function firstHeadingLevel(tree, file, option) {
var preferred = option && option !== true ? option : 1

@@ -105,14 +105,17 @@ visit(tree, visitor)

function visitor(node) {
var depth
var rank
if (!generated(node)) {
if (node.type === 'heading') {
depth = node.depth
rank = node.depth
} else if (node.type === 'html') {
depth = infer(node)
rank = infer(node)
}
if (depth !== undefined) {
if (depth !== style) {
file.message('First heading level should be `' + style + '`', node)
if (rank !== undefined) {
if (rank !== preferred) {
file.message(
'First heading level should be `' + preferred + '`',
node
)
}

@@ -119,0 +122,0 @@

{
"name": "remark-lint-first-heading-level",
"version": "1.1.4",
"version": "1.1.5",
"description": "remark-lint rule to warn when the first heading has a level other than a specified value",

@@ -10,2 +10,3 @@ "license": "MIT",

"rule",
"remark-lint-rule",
"first",

@@ -18,2 +19,6 @@ "heading",

"bugs": "https://github.com/remarkjs/remark-lint/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",

@@ -20,0 +25,0 @@ "contributors": [

@@ -23,3 +23,3 @@ <!--This file is generated-->

##### `valid.md`
##### `ok.md`

@@ -40,3 +40,3 @@ When configured with `2`.

##### `valid-html.md`
##### `ok-html.md`

@@ -57,3 +57,3 @@ When configured with `2`.

##### `invalid.md`
##### `not-ok.md`

@@ -76,3 +76,3 @@ When configured with `2`.

##### `invalid-html.md`
##### `not-ok-html.md`

@@ -95,3 +95,3 @@ When configured with `2`.

##### `valid.md`
##### `ok.md`

@@ -108,3 +108,3 @@ ###### In

##### `valid-html.md`
##### `ok-html.md`

@@ -121,3 +121,3 @@ ###### In

##### `valid-delayed.md`
##### `ok-delayed.md`

@@ -138,3 +138,3 @@ ###### In

##### `invalid.md`
##### `not-ok.md`

@@ -155,3 +155,3 @@ ###### In

##### `invalid-html.md`
##### `not-ok-html.md`

@@ -185,12 +185,12 @@ ###### In

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

@@ -207,4 +207,4 @@

```diff
var remark = require('remark');
var report = require('vfile-reporter');
var remark = require('remark')
var report = require('vfile-reporter')

@@ -215,4 +215,4 @@ remark()

.process('_Emphasis_ and **importance**', function (err, file) {
console.error(report(err || file));
});
console.error(report(err || file))
})
```

@@ -226,4 +226,4 @@

This project has a [Code of Conduct][coc].
By interacting with this repository, organisation, or community you agree to
This project has a [code of conduct][coc].
By interacting with this repository, organization, or community you agree to
abide by its terms.

@@ -257,3 +257,3 @@

[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg

@@ -260,0 +260,0 @@ [chat]: https://spectrum.chat/unified/remark

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc