How to use the unist-util-position.start function in unist-util-position

To help you get started, we’ve selected a few unist-util-position examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vhf / remark-lint-blank-lines-1-0-2 / dist / blank-lines.js View on Github external
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);
        }
      }
    }
  });
}
github remarkjs / remark-lint / packages / remark-lint-no-paragraph-content-indent / index.js View on Github external
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))) {
github remarkjs / remark-lint / packages / remark-lint-blockquote-indentation / index.js View on Github external
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
}
github vhf / remark-lint-blank-lines-1-0-2 / lib / blank-lines.js View on Github external
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);
        }
      }
    }
  });
}
github wemake-services / remark-lint-are-links-valid / lib / are-links-valid.js View on Github external
function handleLinkError(file, link) {
  const { line, column } = start(link.node);
  file.warn(`Link is broken: ${link.link.href}`, { line, column });
}
github remarkjs / remark-lint / packages / remark-lint-no-multiple-toplevel-headings / index.js View on Github external
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))
      }
    }
  }
}
github wemake-services / remark-lint-are-links-valid / dist / are-links-valid.js View on Github external
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 });
}
github remarkjs / remark-lint / packages / remark-lint-no-table-indentation / index.js View on Github external
function each(row) {
    var fence = contents.slice(
      position.start(row).offset,
      position.start(row.children[0]).offset
    )

    if (fence.indexOf('|') > 1) {
      file.message(reason, row)
    }
  }
}

unist-util-position

unist utility to get the position of a node

MIT
Latest version published 1 year ago

Package Health Score

71 / 100
Full package analysis

Popular unist-util-position functions