lib/utils/indent-common.js
function validateCore (token, expectedIndent, optionalExpectedIndent) {
    const line = token.loc.start.line
    const indentText = getIndentText(token)

    // If there is no line terminator after the `<script>` start tag,
    // `indentText` contains non-whitespace characters.
    // In that case, do nothing in order to prevent removing the `<script>` tag.
    if (indentText.trim() !== '') {
      return
    }

    const actualIndent = token.loc.start.column
    const unit = (options.indentChar === '\t' ? 'tab' : 'space')

    for (let i = 0; i < indentText.length; ++i) {
      if (indentText[i] !== options.indentChar) {
        context.report({
          loc: {
            start: { line, column: i },
            end: { line, column: i + 1 }
          },
          message: 'Expected {{expected}} character, but found {{actual}} character.',
          data: {
            expected: JSON.stringify(options.indentChar),
            actual: JSON.stringify(indentText[i])
          },
          fix: defineFix(token, actualIndent, expectedIndent)
        })
        return
      }
    }

    if (actualIndent !== expectedIndent && (optionalExpectedIndent === undefined || actualIndent !== optionalExpectedIndent)) {
      context.report({
        loc: {
          start: { line, column: 0 },
          end: { line, column: actualIndent }
        },
        message: 'Expected indentation of {{expectedIndent}} {{unit}}{{expectedIndentPlural}} but found {{actualIndent}} {{unit}}{{actualIndentPlural}}.',
        data: {
          expectedIndent,
          actualIndent,
          unit,
          expectedIndentPlural: (expectedIndent === 1) ? '' : 's',
          actualIndentPlural: (actualIndent === 1) ? '' : 's'
        },
        fix: defineFix(token, actualIndent, expectedIndent)
      })
    }
  }
function validateCore (token, expectedIndent, optionalExpectedIndent) {
    const line = token.loc.start.line
    const indentText = getIndentText(token)

    // If there is no line terminator after the `<script>` start tag,
    // `indentText` contains non-whitespace characters.
    // In that case, do nothing in order to prevent removing the `<script>` tag.
    if (indentText.trim() !== '') {
      return
    }

    const actualIndent = token.loc.start.column
    const unit = (options.indentChar === '\t' ? 'tab' : 'space')

    for (let i = 0; i < indentText.length; ++i) {
      if (indentText[i] !== options.indentChar) {
        context.report({
          loc: {
            start: { line, column: i },
            end: { line, column: i + 1 }
          },
          message: 'Expected {{expected}} character, but found {{actual}} character.',
          data: {
            expected: JSON.stringify(options.indentChar),
            actual: JSON.stringify(indentText[i])
          },
          fix: defineFix(token, actualIndent, expectedIndent)
        })
        return
      }
    }

    if (actualIndent !== expectedIndent && (optionalExpectedIndent === undefined || actualIndent !== optionalExpectedIndent)) {
      context.report({
        loc: {
          start: { line, column: 0 },
          end: { line, column: actualIndent }
        },
        message: 'Expected indentation of {{expectedIndent}} {{unit}}{{expectedIndentPlural}} but found {{actualIndent}} {{unit}}{{actualIndentPlural}}.',
        data: {
          expectedIndent,
          actualIndent,
          unit,
          expectedIndentPlural: (expectedIndent === 1) ? '' : 's',
          actualIndentPlural: (actualIndent === 1) ? '' : 's'
        },
        fix: defineFix(token, actualIndent, expectedIndent)
      })
    }
  }
function validateCore ( token , expectedIndent , optionalExpectedIndent ) { const line = token . loc . start . line const indentText = getIndentText ( token ) // If there is no line terminator after the `<script>` start tag, // `indentText` contains non-whitespace characters. // In that case, do nothing in order to prevent removing the `<script>` tag. if ( indentText . trim ( ) !== '' ) { return } const actualIndent = token . loc . start . column const unit = ( options . indentChar === '\t' ? 'tab' : 'space' ) for ( let i = 0 ; i < indentText . length ; ++ i ) { if ( indentText [ i ] !== options . indentChar ) { context . report ( { loc : { start : { line , column : i } , end : { line , column : i + 1 } } , message : 'Expected {{expected}} character, but found {{actual}} character.' , data : { expected : JSON . stringify ( options . indentChar ) , actual : JSON . stringify ( indentText [ i ] ) } , fix : defineFix ( token , actualIndent , expectedIndent ) } ) return } } if ( actualIndent !== expectedIndent && ( optionalExpectedIndent === undefined || actualIndent !== optionalExpectedIndent ) ) { context . report ( { loc : { start : { line , column : 0 } , end : { line , column : actualIndent } } , message : 'Expected indentation of {{expectedIndent}} {{unit}}{{expectedIndentPlural}} but found {{actualIndent}} {{unit}}{{actualIndentPlural}}.' , data : { expectedIndent , actualIndent , unit , expectedIndentPlural : ( expectedIndent === 1 ) ? '' : 's' , actualIndentPlural : ( actualIndent === 1 ) ? '' : 's' } , fix : defineFix ( token , actualIndent , expectedIndent ) } ) } }
Validate the given token with the pre-calculated expected indentation.
@param {Token} token The token to validate.
@param {number} expectedIndent The expected indentation.
@param {number|undefined} optionalExpectedIndent The optional expected indentation.
@returns {void}
Validate the given token with the pre - calculated expected indentation .