function checkTypeAnnotationSpacing(typeAnnotation) {
            const nextToken = typeAnnotation;
            const punctuatorTokenEnd = sourceCode.getTokenBefore(nextToken);
            let punctuatorTokenStart = punctuatorTokenEnd;
            let previousToken = sourceCode.getTokenBefore(punctuatorTokenEnd);
            let type = punctuatorTokenEnd.value;

            if (punctuators.indexOf(type) === -1) {
                return;
            }

            const before =
                type === ":" ? colonOptions.before : arrowOptions.before;
            const after =
                type === ":" ? colonOptions.after : arrowOptions.after;

            if (type === ":" && previousToken.value === "?") {
                // shift the start to the ?
                type = "?:";
                punctuatorTokenStart = previousToken;
                previousToken = sourceCode.getTokenBefore(previousToken);

                // handle the +/- modifiers for optional modification operators
                if (
                    previousToken.value === "+" ||
                    previousToken.value === "-"
                ) {
                    type = `${previousToken.value}?:`;
                    punctuatorTokenStart = previousToken;
                    previousToken = sourceCode.getTokenBefore(previousToken);
                }
            }

            const previousDelta =
                punctuatorTokenStart.range[0] - previousToken.range[1];
            const nextDelta = nextToken.range[0] - punctuatorTokenEnd.range[1];

            if (after && nextDelta === 0) {
                context.report({
                    node: punctuatorTokenEnd,
                    message: "Expected a space after the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.insertTextAfter(punctuatorTokenEnd, " ");
                    },
                });
            } else if (!after && nextDelta > 0) {
                context.report({
                    node: punctuatorTokenEnd,
                    message: "Unexpected space after the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.removeRange([
                            punctuatorTokenEnd.range[1],
                            nextToken.range[0],
                        ]);
                    },
                });
            }

            if (before && previousDelta === 0) {
                context.report({
                    node: punctuatorTokenStart,
                    message: "Expected a space before the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.insertTextAfter(previousToken, " ");
                    },
                });
            } else if (!before && previousDelta > 0) {
                context.report({
                    node: punctuatorTokenStart,
                    message: "Unexpected space before the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.removeRange([
                            previousToken.range[1],
                            punctuatorTokenStart.range[0],
                        ]);
                    },
                });
            }
        }
/**
         * Checks if there's proper spacing around type annotations (no space
         * before colon, one space after).
         * @param {ASTNode} typeAnnotation The TSTypeAnnotation node.
         * @returns {void}
         * @private
         */
Checks if there's proper spacing around type annotations (no space
before colon, one space after).
Checks if there ' s proper spacing around type annotations ( no space before colon one space after ) .
function checkTypeAnnotationSpacing(typeAnnotation) {
            const nextToken = typeAnnotation;
            const punctuatorTokenEnd = sourceCode.getTokenBefore(nextToken);
            let punctuatorTokenStart = punctuatorTokenEnd;
            let previousToken = sourceCode.getTokenBefore(punctuatorTokenEnd);
            let type = punctuatorTokenEnd.value;
            if (punctuators.indexOf(type) === -1) {
                return;
            }
            const before =
                type === ":" ? colonOptions.before : arrowOptions.before;
            const after =
                type === ":" ? colonOptions.after : arrowOptions.after;
            if (type === ":" && previousToken.value === "?") {
                type = "?:";
                punctuatorTokenStart = previousToken;
                previousToken = sourceCode.getTokenBefore(previousToken);
                if (
                    previousToken.value === "+" ||
                    previousToken.value === "-"
                ) {
                    type = `${previousToken.value}?:`;
                    punctuatorTokenStart = previousToken;
                    previousToken = sourceCode.getTokenBefore(previousToken);
                }
            }
            const previousDelta =
                punctuatorTokenStart.range[0] - previousToken.range[1];
            const nextDelta = nextToken.range[0] - punctuatorTokenEnd.range[1];
            if (after && nextDelta === 0) {
                context.report({
                    node: punctuatorTokenEnd,
                    message: "Expected a space after the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.insertTextAfter(punctuatorTokenEnd, " ");
                    },
                });
            } else if (!after && nextDelta > 0) {
                context.report({
                    node: punctuatorTokenEnd,
                    message: "Unexpected space after the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.removeRange([
                            punctuatorTokenEnd.range[1],
                            nextToken.range[0],
                        ]);
                    },
                });
            }
            if (before && previousDelta === 0) {
                context.report({
                    node: punctuatorTokenStart,
                    message: "Expected a space before the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.insertTextAfter(previousToken, " ");
                    },
                });
            } else if (!before && previousDelta > 0) {
                context.report({
                    node: punctuatorTokenStart,
                    message: "Unexpected space before the '{{type}}'.",
                    data: {
                        type,
                    },
                    fix(fixer) {
                        return fixer.removeRange([
                            previousToken.range[1],
                            punctuatorTokenStart.range[0],
                        ]);
                    },
                });
            }
        }
function checkTypeAnnotationSpacing ( typeAnnotation ) { const nextToken = typeAnnotation ; const punctuatorTokenEnd = sourceCode . getTokenBefore ( nextToken ) ; let punctuatorTokenStart = punctuatorTokenEnd ; let previousToken = sourceCode . getTokenBefore ( punctuatorTokenEnd ) ; let type = punctuatorTokenEnd . value ; if ( punctuators . indexOf ( type ) === - 1 ) { return ; } const before = type === ":" ? colonOptions . before : arrowOptions . before ; const after = type === ":" ? colonOptions . after : arrowOptions . after ; if ( type === ":" && previousToken . value === "?" ) { type = "?:" ; punctuatorTokenStart = previousToken ; previousToken = sourceCode . getTokenBefore ( previousToken ) ; if ( previousToken . value === "+" || previousToken . value === "-" ) { type = ` ${ previousToken . value } ` ; punctuatorTokenStart = previousToken ; previousToken = sourceCode . getTokenBefore ( previousToken ) ; } } const previousDelta = punctuatorTokenStart . range [ 0 ] - previousToken . range [ 1 ] ; const nextDelta = nextToken . range [ 0 ] - punctuatorTokenEnd . range [ 1 ] ; if ( after && nextDelta === 0 ) { context . report ( { node : punctuatorTokenEnd , message : "Expected a space after the '{{type}}'." , data : { type , } , fix ( fixer ) { return fixer . insertTextAfter ( punctuatorTokenEnd , " " ) ; } , } ) ; } else if ( ! after && nextDelta > 0 ) { context . report ( { node : punctuatorTokenEnd , message : "Unexpected space after the '{{type}}'." , data : { type , } , fix ( fixer ) { return fixer . removeRange ( [ punctuatorTokenEnd . range [ 1 ] , nextToken . range [ 0 ] , ] ) ; } , } ) ; } if ( before && previousDelta === 0 ) { context . report ( { node : punctuatorTokenStart , message : "Expected a space before the '{{type}}'." , data : { type , } , fix ( fixer ) { return fixer . insertTextAfter ( previousToken , " " ) ; } , } ) ; } else if ( ! before && previousDelta > 0 ) { context . report ( { node : punctuatorTokenStart , message : "Unexpected space before the '{{type}}'." , data : { type , } , fix ( fixer ) { return fixer . removeRange ( [ previousToken . range [ 1 ] , punctuatorTokenStart . range [ 0 ] , ] ) ; } , } ) ; } }
Checks if there's proper spacing around type annotations (no space
 before colon, one space after).
Checks if there ' s proper spacing around type annotations ( no space before colon one space after ) .
// shift the start to the ? // handle the +/- modifiers for optional modification operators