remark-lint-no-duplicate-headings-in-section
Advanced tools
Comparing version 2.0.1 to 2.0.2
32
index.js
@@ -39,2 +39,18 @@ /** | ||
* 5:1-5:9: Do not use headings with similar content per section (3:1) | ||
* | ||
* @example {"name": "not-ok-tolerant-heading-increment.md", "label": "input"} | ||
* | ||
* # Alpha | ||
* | ||
* #### Bravo | ||
* | ||
* ###### Charlie | ||
* | ||
* #### Bravo | ||
* | ||
* ###### Delta | ||
* | ||
* @example {"name": "not-ok-tolerant-heading-increment.md", "label": "output"} | ||
* | ||
* 7:1-7:11: Do not use headings with similar content per section (3:1) | ||
*/ | ||
@@ -59,3 +75,3 @@ | ||
function noDuplicateHeadingsInSection(tree, file) { | ||
var stack = [{}] | ||
var stack = [] | ||
@@ -66,11 +82,8 @@ visit(tree, 'heading', visitor) | ||
var depth = node.depth | ||
var siblings = stack[depth - 1] || {} | ||
var value = toString(node).toUpperCase() | ||
var duplicate = siblings[value] | ||
var index = depth - 1 | ||
var scope = stack[index] || (stack[index] = {}) | ||
var duplicate = scope[value] | ||
stack = stack.slice(0, depth) | ||
stack[depth] = {} | ||
siblings[value] = node | ||
if (!generated(node) && duplicate && duplicate.type === 'heading') { | ||
if (!generated(node) && duplicate) { | ||
file.message( | ||
@@ -81,3 +94,6 @@ reason + ' (' + stringify(position.start(duplicate)) + ')', | ||
} | ||
scope[value] = node | ||
stack = stack.slice(0, depth) | ||
} | ||
} |
{ | ||
"name": "remark-lint-no-duplicate-headings-in-section", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "remark-lint rule to warn on duplicate headings in a section", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -66,2 +66,24 @@ <!--This file is generated--> | ||
##### `not-ok-tolerant-heading-increment.md` | ||
###### In | ||
```markdown | ||
# Alpha | ||
#### Bravo | ||
###### Charlie | ||
#### Bravo | ||
###### Delta | ||
``` | ||
###### Out | ||
```text | ||
7:1-7:11: Do not use headings with similar content per section (3:1) | ||
``` | ||
## Install | ||
@@ -68,0 +90,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6608
86
186