function checkComputedProperty(node, value) {
            if (
                validIdentifier.test(value) &&
                (allowKeywords || keywords.indexOf(String(value)) === -1) &&
                !(allowPattern && allowPattern.test(value))
            ) {
                const formattedValue = node.property.type === "Literal" ? JSON.stringify(value) : `\`${value}\``;

                context.report({
                    node: node.property,
                    messageId: "useDot",
                    data: {
                        key: formattedValue
                    },
                    fix(fixer) {
                        const leftBracket = sourceCode.getTokenAfter(node.object, astUtils.isOpeningBracketToken);
                        const rightBracket = sourceCode.getLastToken(node);

                        if (sourceCode.getFirstTokenBetween(leftBracket, rightBracket, { includeComments: true, filter: astUtils.isCommentToken })) {

                            // Don't perform any fixes if there are comments inside the brackets.
                            return null;
                        }

                        const tokenAfterProperty = sourceCode.getTokenAfter(rightBracket);
                        const needsSpaceAfterProperty = tokenAfterProperty &&
                            rightBracket.range[1] === tokenAfterProperty.range[0] &&
                            !astUtils.canTokensBeAdjacent(String(value), tokenAfterProperty);

                        const textBeforeDot = astUtils.isDecimalInteger(node.object) ? " " : "";
                        const textAfterProperty = needsSpaceAfterProperty ? " " : "";

                        return fixer.replaceTextRange(
                            [leftBracket.range[0], rightBracket.range[1]],
                            `${textBeforeDot}.${value}${textAfterProperty}`
                        );
                    }
                });
            }
        }
function checkComputedProperty(node, value) {
            if (
                validIdentifier.test(value) &&
                (allowKeywords || keywords.indexOf(String(value)) === -1) &&
                !(allowPattern && allowPattern.test(value))
            ) {
                const formattedValue = node.property.type === "Literal" ? JSON.stringify(value) : `\`${value}\``;

                context.report({
                    node: node.property,
                    messageId: "useDot",
                    data: {
                        key: formattedValue
                    },
                    fix(fixer) {
                        const leftBracket = sourceCode.getTokenAfter(node.object, astUtils.isOpeningBracketToken);
                        const rightBracket = sourceCode.getLastToken(node);

                        if (sourceCode.getFirstTokenBetween(leftBracket, rightBracket, { includeComments: true, filter: astUtils.isCommentToken })) {

                            // Don't perform any fixes if there are comments inside the brackets.
                            return null;
                        }

                        const tokenAfterProperty = sourceCode.getTokenAfter(rightBracket);
                        const needsSpaceAfterProperty = tokenAfterProperty &&
                            rightBracket.range[1] === tokenAfterProperty.range[0] &&
                            !astUtils.canTokensBeAdjacent(String(value), tokenAfterProperty);

                        const textBeforeDot = astUtils.isDecimalInteger(node.object) ? " " : "";
                        const textAfterProperty = needsSpaceAfterProperty ? " " : "";

                        return fixer.replaceTextRange(
                            [leftBracket.range[0], rightBracket.range[1]],
                            `${textBeforeDot}.${value}${textAfterProperty}`
                        );
                    }
                });
            }
        }
function checkComputedProperty ( node , value ) { if ( validIdentifier . test ( value ) && ( allowKeywords || keywords . indexOf ( String ( value ) ) === - 1 ) && ! ( allowPattern && allowPattern . test ( value ) ) ) { const formattedValue = node . property . type === "Literal" ? JSON . stringify ( value ) : ` \` ${ value } \` ` ; context . report ( { node : node . property , messageId : "useDot" , data : { key : formattedValue } , fix ( fixer ) { const leftBracket = sourceCode . getTokenAfter ( node . object , astUtils . isOpeningBracketToken ) ; const rightBracket = sourceCode . getLastToken ( node ) ; if ( sourceCode . getFirstTokenBetween ( leftBracket , rightBracket , { includeComments : true , filter : astUtils . isCommentToken } ) ) { // Don't perform any fixes if there are comments inside the brackets. return null ; } const tokenAfterProperty = sourceCode . getTokenAfter ( rightBracket ) ; const needsSpaceAfterProperty = tokenAfterProperty && rightBracket . range [ 1 ] === tokenAfterProperty . range [ 0 ] && ! astUtils . canTokensBeAdjacent ( String ( value ) , tokenAfterProperty ) ; const textBeforeDot = astUtils . isDecimalInteger ( node . object ) ? " " : "" ; const textAfterProperty = needsSpaceAfterProperty ? " " : "" ; return fixer . replaceTextRange ( [ leftBracket . range [ 0 ] , rightBracket . range [ 1 ] ] , ` ${ textBeforeDot } ${ value } ${ textAfterProperty } ` ) ; } } ) ; } }
Check if the property is valid dot notation
@param {ASTNode} node The dot notation node
@param {string} value Value which is to be checked
@returns {void}
Check if the property is valid dot notation
Checks if a computed property is valid