remark-lint-no-heading-indent
Advanced tools
Comparing version 2.0.1 to 3.0.0
32
index.js
@@ -62,39 +62,19 @@ /** | ||
function noHeadingIndent(tree, file) { | ||
var contents = String(file) | ||
var length = contents.length | ||
visit(tree, 'heading', visitor) | ||
function visitor(node) { | ||
var initial | ||
var begin | ||
var index | ||
var character | ||
function visitor(node, _, parent) { | ||
var diff | ||
if (generated(node)) { | ||
// Note: it’s rather complex to detect what the expected indent is in block | ||
// quotes and lists, so let’s only do directly in root for now. | ||
if (generated(node) || (parent && parent.type !== 'root')) { | ||
return | ||
} | ||
initial = start(node) | ||
begin = initial.offset | ||
index = begin - 1 | ||
diff = start(node).column - 1 | ||
while (++index < length) { | ||
character = contents.charAt(index) | ||
if (character !== ' ' && character !== '\t') { | ||
break | ||
} | ||
} | ||
diff = index - begin | ||
if (diff) { | ||
file.message( | ||
'Remove ' + diff + ' ' + plural('space', diff) + ' before this heading', | ||
{ | ||
line: initial.line, | ||
column: initial.column + diff | ||
} | ||
start(node) | ||
) | ||
@@ -101,0 +81,0 @@ } |
{ | ||
"name": "remark-lint-no-heading-indent", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "remark-lint rule to warn when headings are indented", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -159,5 +159,5 @@ <!--This file is generated--> | ||
[chat-badge]: https://img.shields.io/badge/chat-spectrum.svg | ||
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg | ||
[chat]: https://spectrum.chat/unified/remark | ||
[chat]: https://github.com/remarkjs/remark/discussions | ||
@@ -164,0 +164,0 @@ [npm]: https://docs.npmjs.com/cli/install |
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
6474
73