lib/rules/dot-location.js
function checkDotLocation(obj, prop, node) {
            const dot = sourceCode.getTokenBefore(prop);
            const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
            const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);

            if (dot.type === "Punctuator" && dot.value === ".") {
                if (onObject) {
                    if (!astUtils.isTokenOnSameLine(obj, dot)) {
                        const neededTextAfterObj = astUtils.isDecimalInteger(obj) ? " " : "";

                        context.report({
                            node,
                            loc: dot.loc.start,
                            messageId: "expectedDotAfterObject",
                            fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${neededTextAfterObj}.${textBeforeDot}${textAfterDot}`)
                        });
                    }
                } else if (!astUtils.isTokenOnSameLine(dot, prop)) {
                    context.report({
                        node,
                        loc: dot.loc.start,
                        messageId: "expectedDotBeforeProperty",
                        fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${textBeforeDot}${textAfterDot}.`)
                    });
                }
            }
        }
function checkDotLocation(obj, prop, node) {
            const dot = sourceCode.getTokenBefore(prop);
            const textBeforeDot = sourceCode.getText().slice(obj.range[1], dot.range[0]);
            const textAfterDot = sourceCode.getText().slice(dot.range[1], prop.range[0]);

            if (dot.type === "Punctuator" && dot.value === ".") {
                if (onObject) {
                    if (!astUtils.isTokenOnSameLine(obj, dot)) {
                        const neededTextAfterObj = astUtils.isDecimalInteger(obj) ? " " : "";

                        context.report({
                            node,
                            loc: dot.loc.start,
                            messageId: "expectedDotAfterObject",
                            fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${neededTextAfterObj}.${textBeforeDot}${textAfterDot}`)
                        });
                    }
                } else if (!astUtils.isTokenOnSameLine(dot, prop)) {
                    context.report({
                        node,
                        loc: dot.loc.start,
                        messageId: "expectedDotBeforeProperty",
                        fix: fixer => fixer.replaceTextRange([obj.range[1], prop.range[0]], `${textBeforeDot}${textAfterDot}.`)
                    });
                }
            }
        }
function checkDotLocation ( obj , prop , node ) { const dot = sourceCode . getTokenBefore ( prop ) ; const textBeforeDot = sourceCode . getText ( ) . slice ( obj . range [ 1 ] , dot . range [ 0 ] ) ; const textAfterDot = sourceCode . getText ( ) . slice ( dot . range [ 1 ] , prop . range [ 0 ] ) ; if ( dot . type === "Punctuator" && dot . value === "." ) { if ( onObject ) { if ( ! astUtils . isTokenOnSameLine ( obj , dot ) ) { const neededTextAfterObj = astUtils . isDecimalInteger ( obj ) ? " " : "" ; context . report ( { node , loc : dot . loc . start , messageId : "expectedDotAfterObject" , fix : fixer => fixer . replaceTextRange ( [ obj . range [ 1 ] , prop . range [ 0 ] ] , ` ${ neededTextAfterObj } ${ textBeforeDot } ${ textAfterDot } ` ) } ) ; } } else if ( ! astUtils . isTokenOnSameLine ( dot , prop ) ) { context . report ( { node , loc : dot . loc . start , messageId : "expectedDotBeforeProperty" , fix : fixer => fixer . replaceTextRange ( [ obj . range [ 1 ] , prop . range [ 0 ] ] , ` ${ textBeforeDot } ${ textAfterDot } ` ) } ) ; } } }
Reports if the dot between object and property is on the correct loccation.
@param {ASTNode} obj The object owning the property.
@param {ASTNode} prop The property of the object.
@param {ASTNode} node The corresponding node of the token.
@returns {void}
Reports if the dot between object and property is on the correct loccation .