index.js
function all(tree, file, config) {
  var ignore = config.ignore
  var ignoreLiteral = config.ignoreLiteral
  var ignoreDigits = config.ignoreDigits
  var apos = config.normalizeApostrophes
  var checker = config.checker
  var cache = config.cache

  visit(tree, 'WordNode', checkWord)

  // Check one word.
  function checkWord(node, position, parent) {
    var children = node.children
    var word = toString(node)
    var correct
    var length
    var index
    var child
    var reason
    var message
    var suggestions

    if (ignoreLiteral && isLiteral(parent, position)) {
      return
    }

    if (apos) {
      word = word.replace(smart, straight)
    }

    if (irrelevant(word)) {
      return
    }

    correct = checker.correct(word)

    if (!correct && children.length > 1) {
      correct = true
      length = children.length
      index = -1

      while (++index < length) {
        child = children[index]

        if (child.type !== 'TextNode' || irrelevant(child.value)) {
          continue
        }

        if (!checker.correct(child.value)) {
          correct = false
        }
      }
    }

    if (!correct) {
      if (own.call(cache, word)) {
        reason = cache[word]
      } else {
        reason = quote(word, '`') + ' is misspelt'

        if (config.count === config.max) {
          message = file.message(
            'Too many misspellings; no further spell suggestions are given',
            node,
            'overflow'
          )

          message.source = source
        }

        config.count++

        if (config.count < config.max) {
          suggestions = checker.suggest(word)

          if (suggestions.length !== 0) {
            reason +=
              '; did you mean ' + quote(suggestions, '`').join(', ') + '?'
            cache[word] = reason
          }
        }

        cache[word] = reason
      }

      message = file.message(reason, node, source)
      message.source = source
      message.actual = word
      message.expected = suggestions
    }
  }

  // Check if a word is irrelevant.
  function irrelevant(word) {
    return includes(ignore, word) || (ignoreDigits && digitsOnly.test(word))
  }
}
function all(tree, file, config) {
  var ignore = config.ignore
  var ignoreLiteral = config.ignoreLiteral
  var ignoreDigits = config.ignoreDigits
  var apos = config.normalizeApostrophes
  var checker = config.checker
  var cache = config.cache

  visit(tree, 'WordNode', checkWord)

  // Check one word.
  function checkWord(node, position, parent) {
    var children = node.children
    var word = toString(node)
    var correct
    var length
    var index
    var child
    var reason
    var message
    var suggestions

    if (ignoreLiteral && isLiteral(parent, position)) {
      return
    }

    if (apos) {
      word = word.replace(smart, straight)
    }

    if (irrelevant(word)) {
      return
    }

    correct = checker.correct(word)

    if (!correct && children.length > 1) {
      correct = true
      length = children.length
      index = -1

      while (++index < length) {
        child = children[index]

        if (child.type !== 'TextNode' || irrelevant(child.value)) {
          continue
        }

        if (!checker.correct(child.value)) {
          correct = false
        }
      }
    }

    if (!correct) {
      if (own.call(cache, word)) {
        reason = cache[word]
      } else {
        reason = quote(word, '`') + ' is misspelt'

        if (config.count === config.max) {
          message = file.message(
            'Too many misspellings; no further spell suggestions are given',
            node,
            'overflow'
          )

          message.source = source
        }

        config.count++

        if (config.count < config.max) {
          suggestions = checker.suggest(word)

          if (suggestions.length !== 0) {
            reason +=
              '; did you mean ' + quote(suggestions, '`').join(', ') + '?'
            cache[word] = reason
          }
        }

        cache[word] = reason
      }

      message = file.message(reason, node, source)
      message.source = source
      message.actual = word
      message.expected = suggestions
    }
  }

  // Check if a word is irrelevant.
  function irrelevant(word) {
    return includes(ignore, word) || (ignoreDigits && digitsOnly.test(word))
  }
}
function all ( tree , file , config ) { var ignore = config . ignore var ignoreLiteral = config . ignoreLiteral var ignoreDigits = config . ignoreDigits var apos = config . normalizeApostrophes var checker = config . checker var cache = config . cache visit ( tree , 'WordNode' , checkWord ) // Check one word. function checkWord ( node , position , parent ) { var children = node . children var word = toString ( node ) var correct var length var index var child var reason var message var suggestions if ( ignoreLiteral && isLiteral ( parent , position ) ) { return } if ( apos ) { word = word . replace ( smart , straight ) } if ( irrelevant ( word ) ) { return } correct = checker . correct ( word ) if ( ! correct && children . length > 1 ) { correct = true length = children . length index = - 1 while ( ++ index < length ) { child = children [ index ] if ( child . type !== 'TextNode' || irrelevant ( child . value ) ) { continue } if ( ! checker . correct ( child . value ) ) { correct = false } } } if ( ! correct ) { if ( own . call ( cache , word ) ) { reason = cache [ word ] } else { reason = quote ( word , '`' ) + ' is misspelt' if ( config . count === config . max ) { message = file . message ( 'Too many misspellings; no further spell suggestions are given' , node , 'overflow' ) message . source = source } config . count ++ if ( config . count < config . max ) { suggestions = checker . suggest ( word ) if ( suggestions . length !== 0 ) { reason += '; did you mean ' + quote ( suggestions , '`' ) . join ( ', ' ) + '?' cache [ word ] = reason } } cache [ word ] = reason } message = file . message ( reason , node , source ) message . source = source message . actual = word message . expected = suggestions } } // Check if a word is irrelevant. function irrelevant ( word ) { return includes ( ignore , word ) || ( ignoreDigits && digitsOnly . test ( word ) ) } }
Check a file for spelling mistakes.
Check a file for spelling mistakes .