lib/rules/html-indent.js
function findSwitchCaseBodyInfoAtLineStart(line) {
                    const index = sourceCode.getIndexFromLoc({
                        line,
                        column: 0,
                    })

                    let switchCaseNode = sourceCode.getNodeByRangeIndex(index)
                    if (
                        !switchCaseNode ||
                        switchCaseNode.type === "SwitchStatement"
                    ) {
                        switchCaseNode = switchStatementNode.cases.find(
                            (_token, i) => {
                                const next = switchStatementNode.cases[i + 1]
                                if (!next || index < next.range[0]) {
                                    return true
                                }
                                return false
                            }
                        )
                    }
                    if (
                        !switchCaseNode ||
                        switchCaseNode.type !== "SwitchCase"
                    ) {
                        // not SwitchCase
                        return null
                    }

                    if (switchCaseNode.test) {
                        if (index < switchCaseNode.test.range[1]) {
                            // not body
                            return null
                        }
                    } else {
                        // default:
                        const fToken = sourceCode.getFirstToken(switchCaseNode)
                        const colon = sourceCode.getTokenAfter(
                            fToken,
                            t => t.type === "Punctuator" && t.value === ":"
                        )
                        if (index < colon.range[1]) {
                            // not body
                            return null
                        }
                    }
                    if (
                        !equalsLocation(
                            switchCaseNode.parent,
                            switchStatementNode
                        )
                    ) {
                        // not target
                        return null
                    }
                    const casesIndex = switchStatementNode.cases.findIndex(c =>
                        equalsLocation(c, switchCaseNode)
                    )
                    const evaluate = evaluates.find(
                        e =>
                            e.range[0] <= switchCaseNode.range[0] &&
                            switchCaseNode.range[0] < e.range[1]
                    )
                    return {
                        evaluate,
                        casesIndex,
                        node: switchCaseNode,
                    }
                }
function findSwitchCaseBodyInfoAtLineStart(line) {
                    const index = sourceCode.getIndexFromLoc({
                        line,
                        column: 0,
                    })

                    let switchCaseNode = sourceCode.getNodeByRangeIndex(index)
                    if (
                        !switchCaseNode ||
                        switchCaseNode.type === "SwitchStatement"
                    ) {
                        switchCaseNode = switchStatementNode.cases.find(
                            (_token, i) => {
                                const next = switchStatementNode.cases[i + 1]
                                if (!next || index < next.range[0]) {
                                    return true
                                }
                                return false
                            }
                        )
                    }
                    if (
                        !switchCaseNode ||
                        switchCaseNode.type !== "SwitchCase"
                    ) {
                        // not SwitchCase
                        return null
                    }

                    if (switchCaseNode.test) {
                        if (index < switchCaseNode.test.range[1]) {
                            // not body
                            return null
                        }
                    } else {
                        // default:
                        const fToken = sourceCode.getFirstToken(switchCaseNode)
                        const colon = sourceCode.getTokenAfter(
                            fToken,
                            t => t.type === "Punctuator" && t.value === ":"
                        )
                        if (index < colon.range[1]) {
                            // not body
                            return null
                        }
                    }
                    if (
                        !equalsLocation(
                            switchCaseNode.parent,
                            switchStatementNode
                        )
                    ) {
                        // not target
                        return null
                    }
                    const casesIndex = switchStatementNode.cases.findIndex(c =>
                        equalsLocation(c, switchCaseNode)
                    )
                    const evaluate = evaluates.find(
                        e =>
                            e.range[0] <= switchCaseNode.range[0] &&
                            switchCaseNode.range[0] < e.range[1]
                    )
                    return {
                        evaluate,
                        casesIndex,
                        node: switchCaseNode,
                    }
                }
function findSwitchCaseBodyInfoAtLineStart ( line ) { const index = sourceCode . getIndexFromLoc ( { line , column : 0 , } ) let switchCaseNode = sourceCode . getNodeByRangeIndex ( index ) if ( ! switchCaseNode || switchCaseNode . type === "SwitchStatement" ) { switchCaseNode = switchStatementNode . cases . find ( ( _token , i ) => { const next = switchStatementNode . cases [ i + 1 ] if ( ! next || index < next . range [ 0 ] ) { return true } return false } ) } if ( ! switchCaseNode || switchCaseNode . type !== "SwitchCase" ) { // not SwitchCase return null } if ( switchCaseNode . test ) { if ( index < switchCaseNode . test . range [ 1 ] ) { // not body return null } } else { // default: const fToken = sourceCode . getFirstToken ( switchCaseNode ) const colon = sourceCode . getTokenAfter ( fToken , t => t . type === "Punctuator" && t . value === ":" ) if ( index < colon . range [ 1 ] ) { // not body return null } } if ( ! equalsLocation ( switchCaseNode . parent , switchStatementNode ) ) { // not target return null } const casesIndex = switchStatementNode . cases . findIndex ( c => equalsLocation ( c , switchCaseNode ) ) const evaluate = evaluates . find ( e => e . range [ 0 ] <= switchCaseNode . range [ 0 ] && switchCaseNode . range [ 0 ] < e . range [ 1 ] ) return { evaluate , casesIndex , node : switchCaseNode , } }
Find evaluate token of SwitchCase body from the given line.
@param {number} line The line no to set.
@returns {Token} The evaluate token of SwitchCase.
Find evaluate token of SwitchCase body from the given line .