lib/rules/html-indent.js
function findIndentationStartPunctuator(evaluate) {
                const searchIndex = evaluate.code.search(/(\S)\s*$/u)
                if (searchIndex < 0) {
                    return null
                }
                const charIndex =
                    evaluate.expressionStart.range[1] + searchIndex
                const node = sourceCode.getNodeByRangeIndex(charIndex)
                if (!node) {
                    // comment only
                    return null
                }
                const tokens = sourceCode
                    .getTokens(node)
                    .filter(
                        t =>
                            t.range[0] <= evaluate.range[1] &&
                            t.range[1] >= evaluate.range[0]
                    )

                let targetToken = tokens.find(
                    t => t.range[0] <= charIndex && charIndex < t.range[1]
                )
                if (!targetToken) {
                    targetToken = tokens
                        .reverse()
                        .find(t => t.range[1] <= charIndex)
                }
                let token = targetToken
                while (token) {
                    if (
                        token.range[0] > evaluate.range[1] ||
                        token.range[1] < evaluate.range[0]
                    ) {
                        return null
                    }
                    if (isIndentationStartPunctuator(token)) {
                        return token
                    }
                    if (isIndentationEndPunctuator(token)) {
                        // skip
                        const next = findPairOpenPunctuator(token)
                        token = sourceCode.getTokenBefore(next)
                        continue
                    }

                    token = sourceCode.getTokenBefore(token)
                }

                return null
            }
function findIndentationStartPunctuator(evaluate) {
                const searchIndex = evaluate.code.search(/(\S)\s*$/u)
                if (searchIndex < 0) {
                    return null
                }
                const charIndex =
                    evaluate.expressionStart.range[1] + searchIndex
                const node = sourceCode.getNodeByRangeIndex(charIndex)
                if (!node) {
                    // comment only
                    return null
                }
                const tokens = sourceCode
                    .getTokens(node)
                    .filter(
                        t =>
                            t.range[0] <= evaluate.range[1] &&
                            t.range[1] >= evaluate.range[0]
                    )

                let targetToken = tokens.find(
                    t => t.range[0] <= charIndex && charIndex < t.range[1]
                )
                if (!targetToken) {
                    targetToken = tokens
                        .reverse()
                        .find(t => t.range[1] <= charIndex)
                }
                let token = targetToken
                while (token) {
                    if (
                        token.range[0] > evaluate.range[1] ||
                        token.range[1] < evaluate.range[0]
                    ) {
                        return null
                    }
                    if (isIndentationStartPunctuator(token)) {
                        return token
                    }
                    if (isIndentationEndPunctuator(token)) {
                        // skip
                        const next = findPairOpenPunctuator(token)
                        token = sourceCode.getTokenBefore(next)
                        continue
                    }

                    token = sourceCode.getTokenBefore(token)
                }

                return null
            }
function findIndentationStartPunctuator ( evaluate ) { const searchIndex = evaluate . code . search ( / (\S)\s*$ / u ) if ( searchIndex < 0 ) { return null } const charIndex = evaluate . expressionStart . range [ 1 ] + searchIndex const node = sourceCode . getNodeByRangeIndex ( charIndex ) if ( ! node ) { // comment only return null } const tokens = sourceCode . getTokens ( node ) . filter ( t => t . range [ 0 ] <= evaluate . range [ 1 ] && t . range [ 1 ] >= evaluate . range [ 0 ] ) let targetToken = tokens . find ( t => t . range [ 0 ] <= charIndex && charIndex < t . range [ 1 ] ) if ( ! targetToken ) { targetToken = tokens . reverse ( ) . find ( t => t . range [ 1 ] <= charIndex ) } let token = targetToken while ( token ) { if ( token . range [ 0 ] > evaluate . range [ 1 ] || token . range [ 1 ] < evaluate . range [ 0 ] ) { return null } if ( isIndentationStartPunctuator ( token ) ) { return token } if ( isIndentationEndPunctuator ( token ) ) { // skip const next = findPairOpenPunctuator ( token ) token = sourceCode . getTokenBefore ( next ) continue } token = sourceCode . getTokenBefore ( token ) } return null }
Find indentation-start punctuator token, within micro-template evaluate.
@param {Node} evaluate The micro-template evaluate to set
@returns {Token} The indentation-start punctuator token.
Find indentation - start punctuator token within micro - template evaluate .