Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!generated(node) && children) {
head = children[0]
if (head && !generated(head)) {
// Compare parent and first child.
compare(position.start(node), position.start(head), 0)
// Compare between each child.
children.forEach(visitChild)
tail = children[children.length - 1]
// Compare parent and last child.
if (tail !== head && !generated(tail)) {
compare(position.end(node), position.end(tail), 1)
}
}
}
}
visit(tree, function (node, index, parent) {
var next = parent && parent.children[index + 1];
if (generated(node)) {
return;
}
if (next && isApplicable(node) && isApplicable(next)) {
if (node.type === 'heading' && next.type === 'heading') {
if (position.start(next).line !== position.end(node).line + 2) {
file.message('Incorrect number of blank lines between headings', node);
}
} else if (node.type === 'heading' && next.type !== 'heading') {
if (position.start(next).line - position.end(node).line !== 2) {
file.message('Incorrect number of blank lines between heading and section', node);
}
} else if (node.type === 'list') {
if (position.start(next).line - position.end(node).line !== 3) {
file.message('Incorrect number of blank lines between last section and next heading', node);
}
}
}
});
}
visit(tree, (node, index, parent) => {
const next = parent && parent.children[index + 1];
if (generated(node)) {
return;
}
if (next && isApplicable(node) && isApplicable(next)) {
if (node.type === 'heading' && next.type === 'heading') {
if (position.start(next).line !== position.end(node).line + 2) {
file.message('Incorrect number of blank lines between headings', node);
}
} else if (node.type === 'heading' && next.type !== 'heading') {
if (position.start(next).line - position.end(node).line !== 2) {
file.message('Incorrect number of blank lines between heading and section', node);
}
} else if (node.type === 'list') {
if (position.start(next).line - position.end(node).line !== 3) {
file.message('Incorrect number of blank lines between last section and next heading', node);
}
}
}
});
}
if (generated(node)) {
return;
}
if (next && isApplicable(node) && isApplicable(next)) {
if (node.type === 'heading' && next.type === 'heading') {
if (position.start(next).line !== position.end(node).line + 2) {
file.message('Incorrect number of blank lines between headings', node);
}
} else if (node.type === 'heading' && next.type !== 'heading') {
if (position.start(next).line - position.end(node).line !== 2) {
file.message('Incorrect number of blank lines between heading and section', node);
}
} else if (node.type === 'list') {
if (position.start(next).line - position.end(node).line !== 3) {
file.message('Incorrect number of blank lines between last section and next heading', node);
}
}
}
});
}
function check(node, pos, parent) {
var start = position.start(node)
var value
var index
var line
var cumulative
var indent
if (!applicable(node)) {
return
}
if (!start.line || !node.position.indent) {
first = false
return
}
if (first && ws(toString(node).charAt(0))) {
function check(node) {
var head = node.children[0]
var indentation = position.start(head).column - position.start(node).column
var padding = toString(head).match(/^ +/)
if (padding) {
indentation += padding[0].length
}
return indentation
}
if (generated(node)) {
return;
}
if (next && isApplicable(node) && isApplicable(next)) {
if (node.type === 'heading' && next.type === 'heading') {
if (position.start(next).line !== position.end(node).line + 2) {
file.message('Incorrect number of blank lines between headings', node);
}
} else if (node.type === 'heading' && next.type !== 'heading') {
if (position.start(next).line - position.end(node).line !== 2) {
file.message('Incorrect number of blank lines between heading and section', node);
}
} else if (node.type === 'list') {
if (position.start(next).line - position.end(node).line !== 3) {
file.message('Incorrect number of blank lines between last section and next heading', node);
}
}
}
});
}
function handleLinkError(file, link) {
const { line, column } = start(link.node);
file.warn(`Link is broken: ${link.link.href}`, { line, column });
}
function visitor(node) {
if (!generated(node) && node.depth === style) {
if (duplicate) {
file.message(
'Don’t use multiple top level headings (' + duplicate + ')',
node
)
} else {
duplicate = stringify(start(node))
}
}
}
}
function handleLinkDuplicateError(file, link) {
var _start = start(link.node);
var line = _start.line;
var column = _start.column;
file.warn('Link is a duplicate: ' + link.link.href, { line: line, column: column });
}