index.js
function validate(exposed, file) {
  var references = file.data[referenceId]
  var filePath = file.path
  var reference
  var nodes
  var real
  var hash
  var pathname
  var warning
  var suggestion
  var ruleId

  for (reference in references) {
    nodes = references[reference]
    real = exposed[reference]
    hash = getHash(reference)

    // Check if files without `hash` can be linked to.  Because there’s no need
    // to inspect those files for headings they are not added to remark.  This
    // is especially useful because they might be non-markdown files. Here we
    // check if they exist.
    if ((real === undefined || real === null) && !hash && fs) {
      real = fs.existsSync(path.join(file.cwd, decodeURI(reference)))
      references[reference] = real
    }

    if (!real) {
      if (hash) {
        pathname = getPathname(reference)
        warning = 'Link to unknown heading'
        ruleId = headingRuleId

        if (pathname !== filePath) {
          warning += ' in `' + pathname + '`'
          ruleId = headingInFileRuleId
        }

        warning += ': `' + hash + '`'
      } else {
        warning = 'Link to unknown file: `' + decodeURI(reference) + '`'
        ruleId = fileRuleId
      }

      suggestion = getClosest(reference, exposed)

      if (suggestion) {
        warning += '. Did you mean `' + suggestion + '`'
      }

      warnAll(file, nodes, warning, ruleId)
    }
  }
}
function validate(exposed, file) {
  var references = file.data[referenceId]
  var filePath = file.path
  var reference
  var nodes
  var real
  var hash
  var pathname
  var warning
  var suggestion
  var ruleId

  for (reference in references) {
    nodes = references[reference]
    real = exposed[reference]
    hash = getHash(reference)

    // Check if files without `hash` can be linked to.  Because there’s no need
    // to inspect those files for headings they are not added to remark.  This
    // is especially useful because they might be non-markdown files. Here we
    // check if they exist.
    if ((real === undefined || real === null) && !hash && fs) {
      real = fs.existsSync(path.join(file.cwd, decodeURI(reference)))
      references[reference] = real
    }

    if (!real) {
      if (hash) {
        pathname = getPathname(reference)
        warning = 'Link to unknown heading'
        ruleId = headingRuleId

        if (pathname !== filePath) {
          warning += ' in `' + pathname + '`'
          ruleId = headingInFileRuleId
        }

        warning += ': `' + hash + '`'
      } else {
        warning = 'Link to unknown file: `' + decodeURI(reference) + '`'
        ruleId = fileRuleId
      }

      suggestion = getClosest(reference, exposed)

      if (suggestion) {
        warning += '. Did you mean `' + suggestion + '`'
      }

      warnAll(file, nodes, warning, ruleId)
    }
  }
}
function validate ( exposed , file ) { var references = file . data [ referenceId ] var filePath = file . path var reference var nodes var real var hash var pathname var warning var suggestion var ruleId for ( reference in references ) { nodes = references [ reference ] real = exposed [ reference ] hash = getHash ( reference ) // Check if files without `hash` can be linked to.  Because there’s no need // to inspect those files for headings they are not added to remark.  This // is especially useful because they might be non-markdown files. Here we // check if they exist. if ( ( real === undefined || real === null ) && ! hash && fs ) { real = fs . existsSync ( path . join ( file . cwd , decodeURI ( reference ) ) ) references [ reference ] = real } if ( ! real ) { if ( hash ) { pathname = getPathname ( reference ) warning = 'Link to unknown heading' ruleId = headingRuleId if ( pathname !== filePath ) { warning += ' in `' + pathname + '`' ruleId = headingInFileRuleId } warning += ': `' + hash + '`' } else { warning = 'Link to unknown file: `' + decodeURI ( reference ) + '`' ruleId = fileRuleId } suggestion = getClosest ( reference , exposed ) if ( suggestion ) { warning += '. Did you mean `' + suggestion + '`' } warnAll ( file , nodes , warning , ruleId ) } } }
Check if `file` references headings or files not in `exposed`.
Check if file references headings or files not in exposed .