lib/rules/computed-property-even-spacing.js
/**
         * Returns a function that checks the spacing of a node on the property name
         * that was passed in.
         * @param {string} propertyName The property on the node to check for spacing
         * @returns {function} A function that will check spacing on a node
         */
Returns a function that checks the spacing of a node on the property name
that was passed in.
@param {string} propertyName The property on the node to check for spacing
@returns {function} A function that will check spacing on a node
Returns a function that checks the spacing of a node on the property name that was passed in . @param { string } propertyName The property on the node to check for spacing @returns { function } A function that will check spacing on a node
function checkSpacing(propertyName) {
            return function(node) {
                if (!node.computed) {
                    return
                }
                const property = node[propertyName]
                const before = context.getSourceCode().getTokenBefore(property)
                const first = context.getSourceCode().getFirstToken(property)
                const last = context.getSourceCode().getLastToken(property)
                const after = context.getSourceCode().getTokenAfter(property)
                let startSpace = null
                let endSpace = null
                if (propertyNameMustBeEven) {
                    if (!isSameLine(before, after)) {
                        context.report({
                            node,
                            message:
                                'Expected "[" and "]" to be on the same line.',
                        })
                        return
                    }
                    startSpace = first.loc.start.column - before.loc.end.column
                    endSpace = after.loc.start.column - last.loc.end.column
                    if (startSpace !== endSpace || startSpace > 1) {
                        context.report({
                            node,
                            message:
                                'Expected 1 or 0 spaces around "[" and "]".',
                        })
                    }
                    return
                }
                if (isSameLine(before, first)) {
                    if (propertyNameMustBeSpaced) {
                        if (
                            !isSpaced(before, first) &&
                            isSameLine(before, first)
                        ) {
                            reportRequiredBeginningSpace(node, before)
                        }
                    } else if (isSpaced(before, first)) {
                        reportNoBeginningSpace(node, before)
                    }
                }
                if (isSameLine(last, after)) {
                    if (propertyNameMustBeSpaced) {
                        if (!isSpaced(last, after) && isSameLine(last, after)) {
                            reportRequiredEndingSpace(node, after)
                        }
                    } else if (isSpaced(last, after)) {
                        reportNoEndingSpace(node, after)
                    }
                }
            }
        }
function checkSpacing ( propertyName ) { return function ( node ) { if ( ! node . computed ) { return } const property = node [ propertyName ] const before = context . getSourceCode ( ) . getTokenBefore ( property ) const first = context . getSourceCode ( ) . getFirstToken ( property ) const last = context . getSourceCode ( ) . getLastToken ( property ) const after = context . getSourceCode ( ) . getTokenAfter ( property ) let startSpace = null let endSpace = null if ( propertyNameMustBeEven ) { if ( ! isSameLine ( before , after ) ) { context . report ( { node , message : 'Expected "[" and "]" to be on the same line.' , } ) return } startSpace = first . loc . start . column - before . loc . end . column endSpace = after . loc . start . column - last . loc . end . column if ( startSpace !== endSpace || startSpace > 1 ) { context . report ( { node , message : 'Expected 1 or 0 spaces around "[" and "]".' , } ) } return } if ( isSameLine ( before , first ) ) { if ( propertyNameMustBeSpaced ) { if ( ! isSpaced ( before , first ) && isSameLine ( before , first ) ) { reportRequiredBeginningSpace ( node , before ) } } else if ( isSpaced ( before , first ) ) { reportNoBeginningSpace ( node , before ) } } if ( isSameLine ( last , after ) ) { if ( propertyNameMustBeSpaced ) { if ( ! isSpaced ( last , after ) && isSameLine ( last , after ) ) { reportRequiredEndingSpace ( node , after ) } } else if ( isSpaced ( last , after ) ) { reportNoEndingSpace ( node , after ) } } } }
Returns a function that checks the spacing of a node on the property name
 that was passed in.
Returns a function that checks the spacing of a node on the property name that was passed in .