Extract code from js utilities (#18770)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
fisker Cheungandautofix-ci[bot] authored and GitHub committed 2026-01-28 10:30:30 +08:00
1 parent 04d90fd5b5
commit 16eb5096b6
71 files changed
+384 -384

No files matched your search

+7 -1
View File
@@ -445,7 +445,7 @@ const configs = [
"prettier-internal-rules/no-node-comments": [
"error",
{
file: "src/language-js/utilities/index.js",
file: "src/language-js/utilities/comments.js",
functions: ["hasComment", "getComments"],
},
"src/language-js/pragma.js",
@@ -512,6 +512,12 @@ const configs = [
],
},
},
{
files: ["src/language-js/utilities/utilities.js"],
rules: {
"unicorn/prefer-export-from": ["error", { ignoreUsedVariables: false }],
},
},
];
export default configs;
@@ -1,12 +1,12 @@
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import { isMeaningfulEmptyStatement } from "../utilities/is-meaningful-empty-statement.js";
import {
createTypeCheckFunction,
getFunctionParameters,
isMeaningfulEmptyStatement,
isMethod,
isShorthandSpecifier,
isTsAsConstExpression,
} from "../utilities/index.js";
} from "../utilities/utilities.js";
/**
@import {Node} from "../types/estree.js";
+8 -8
View File
@@ -10,17 +10,11 @@ import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { locEnd, locStart } from "../loc.js";
import { isInsideCallOrNewExpressionParentheses } from "../utilities/call-or-new-expression-parentheses.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import getTextWithoutComments from "../utilities/get-text-without-comments.js";
import {
createTypeCheckFunction,
getCallArguments,
getFunctionParameters,
isMethod,
isObjectProperty,
isPrettierIgnoreComment,
} from "../utilities/index.js";
import isBlockComment from "../utilities/is-block-comment.js";
import isLineComment from "../utilities/is-line-comment.js";
import { isPrettierIgnoreComment } from "../utilities/is-prettier-ignore-comment.js";
import isTypeCastComment from "../utilities/is-type-cast-comment.js";
import {
isBinaryCastExpression,
@@ -31,6 +25,12 @@ import {
isMemberExpression,
isUnionType,
} from "../utilities/node-types.js";
import {
getCallArguments,
getFunctionParameters,
isMethod,
isObjectProperty,
} from "../utilities/utilities.js";
/**
@import {Node, Comment, NodeMap} from "../types/estree.js";
@@ -1,11 +1,11 @@
import {
createTypeCheckFunction,
hasNodeIgnoreComment,
isIifeCalleeOrTaggedTemplateExpressionTag,
shouldUnionTypePrintOwnComments,
} from "../utilities/index.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import { hasNodeIgnoreComment } from "../utilities/has-node-ignore-comment.js";
import { isJsxElement, isUnionType } from "../utilities/node-types.js";
import { shouldExpressionStatementPrintOwnComments } from "../utilities/should-expression-statement-print-own-comments.js";
import {
isIifeCalleeOrTaggedTemplateExpressionTag,
shouldUnionTypePrintOwnComments,
} from "../utilities/utilities.js";
/**
@import {Node} from "../types/estree.js";
+1 -1
View File
@@ -8,7 +8,7 @@ import {
} from "../../document/index.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { printTemplateExpressions } from "../print/template-literal.js";
import isNodeMatches from "../utilities/is-node-matches.js";
import { isNodeMatches } from "../utilities/is-node-matches.js";
import { isAngularComponentStyles } from "./utilities.js";
async function printEmbedCss(textToDoc, print, path, options) {
+2 -5
View File
@@ -1,9 +1,6 @@
import {
CommentCheckFlags,
hasComment,
isObjectProperty,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isArrayExpression } from "../utilities/node-types.js";
import { isObjectProperty } from "../utilities/utilities.js";
const angularComponentObjectExpressionPredicates = [
(node, name) => name === "properties" && node.type === "ObjectExpression",
+1 -1
View File
@@ -1,4 +1,4 @@
import { isMeaningfulEmptyStatement } from "../utilities/index.js";
import { isMeaningfulEmptyStatement } from "../utilities/is-meaningful-empty-statement.js";
import {
isArrayExpression,
isBigIntLiteral,
@@ -1,4 +1,4 @@
import { createTypeCheckFunction } from "../utilities/index.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
/**
@import AstPath from "../../common/ast-path.js"
+1 -1
View File
@@ -1,5 +1,5 @@
import { startsWithNoLookaheadToken } from "../utilities/index.js";
import { isBinaryCastExpression } from "../utilities/node-types.js";
import { startsWithNoLookaheadToken } from "../utilities/utilities.js";
function shouldAddParenthesesToIdentifier(path) {
const { node } = path;
@@ -1,14 +1,5 @@
import {
createTypeCheckFunction,
getFunctionParameters,
getPrecedence,
hasComment,
isBitwiseOperator,
isNullishCoalescing,
isObjectProperty,
shouldFlatten,
startsWithNoLookaheadToken,
} from "../utilities/index.js";
import { hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import {
isArrayExpression,
isBinaryCastExpression,
@@ -22,6 +13,15 @@ import {
isReturnOrThrowStatement,
isUnionType,
} from "../utilities/node-types.js";
import {
getFunctionParameters,
getPrecedence,
isBitwiseOperator,
isNullishCoalescing,
isObjectProperty,
shouldFlatten,
startsWithNoLookaheadToken,
} from "../utilities/utilities.js";
import { shouldAddParenthesesToChainElement } from "./chain-expression.js";
import { shouldAddParenthesesToIdentifier } from "./identifier.js";
import { parentNeedsParentheses } from "./parent-needs-parentheses.js";
@@ -1,16 +1,16 @@
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import {
getLeftSidePathName,
hasNakedLeftSide,
hasNode,
stripChainElementWrappers,
} from "../utilities/index.js";
import {
isCallExpression,
isMemberExpression,
isReturnOrThrowStatement,
} from "../utilities/node-types.js";
import { returnArgumentHasLeadingComment } from "../utilities/return-statement-has-leading-comment.js";
import {
getLeftSidePathName,
hasNakedLeftSide,
hasNode,
stripChainElementWrappers,
} from "../utilities/utilities.js";
/**
* @import AstPath from "../../common/ast-path.js"
+1 -1
View File
@@ -1,6 +1,6 @@
import * as assert from "#universal/assert";
import { locEnd, locEndWithFullText, locStart } from "../../loc.js";
import createTypeCheckFunction from "../../utilities/create-type-check-function.js";
import { createTypeCheckFunction } from "../../utilities/create-type-check-function.js";
import getRaw from "../../utilities/get-raw.js";
import getTextWithoutComments from "../../utilities/get-text-without-comments.js";
import isBlockComment from "../../utilities/is-block-comment.js";
+2 -1
View File
@@ -1,6 +1,7 @@
import { group, join, line } from "../../document/index.js";
import UnexpectedNodeError from "../../utilities/unexpected-node-error.js";
import { createTypeCheckFunction, hasNode } from "../utilities/index.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import { hasNode } from "../utilities/utilities.js";
import { printBinaryishExpression } from "./binaryish.js";
/** @import AstPath from "../../common/ast-path.js" */
+5 -6
View File
@@ -13,18 +13,17 @@ import isNextLineEmptyAfterIndex from "../../utilities/is-next-line-empty.js";
import skipInlineComment from "../../utilities/skip-inline-comment.js";
import skipTrailingComment from "../../utilities/skip-trailing-comment.js";
import { locEnd, locStart } from "../loc.js";
import {
CommentCheckFlags,
hasComment,
isSignedNumericLiteral,
shouldPrintComma,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import {
isArrayExpression,
isNumericLiteral,
isObjectExpression,
isTupleType,
} from "../utilities/node-types.js";
import {
isSignedNumericLiteral,
shouldPrintComma,
} from "../utilities/utilities.js";
import {
printDanglingCommentsInList,
printOptionalToken,
+8 -9
View File
@@ -14,15 +14,7 @@ import {
printCommentsSeparately,
printDanglingComments,
} from "../../main/comments/print.js";
import {
CommentCheckFlags,
getFunctionParameters,
hasComment,
hasLeadingOwnLineComment,
isTemplateOnItsOwnLine,
shouldPrintComma,
startsWithNoLookaheadToken,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import {
isArrayExpression,
isBinaryish,
@@ -30,6 +22,13 @@ import {
isJsxElement,
isObjectExpression,
} from "../utilities/node-types.js";
import {
getFunctionParameters,
hasLeadingOwnLineComment,
isTemplateOnItsOwnLine,
shouldPrintComma,
startsWithNoLookaheadToken,
} from "../utilities/utilities.js";
import { printReturnType, shouldPrintParamsWithoutParens } from "./function.js";
import { printFunctionParameters } from "./function-parameters.js";
+6 -6
View File
@@ -10,12 +10,6 @@ import {
} from "../../document/index.js";
import getStringWidth from "../../utilities/get-string-width.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import {
getCallArguments,
hasLeadingOwnLineComment,
isLoneShortArgument,
isObjectProperty,
} from "../utilities/index.js";
import {
isBinaryish,
isBooleanLiteral,
@@ -28,6 +22,12 @@ import {
isTypeAlias,
isUnionType,
} from "../utilities/node-types.js";
import {
getCallArguments,
hasLeadingOwnLineComment,
isLoneShortArgument,
isObjectProperty,
} from "../utilities/utilities.js";
import { shouldInlineLogicalExpression } from "./binaryish.js";
import { printCallExpression } from "./call-expression.js";
+1 -1
View File
@@ -1,9 +1,9 @@
import { group, indent, softline } from "../../document/index.js";
import { startsWithNoLookaheadToken } from "../utilities/index.js";
import {
isCallExpression,
isMemberExpression,
} from "../utilities/node-types.js";
import { startsWithNoLookaheadToken } from "../utilities/utilities.js";
/**
* @import AstPath from "../../common/ast-path.js"
+7 -8
View File
@@ -14,14 +14,7 @@ import {
softline,
} from "../../document/index.js";
import { printComments } from "../../main/comments/print.js";
import {
CommentCheckFlags,
hasComment,
hasLeadingOwnLineComment,
isBooleanTypeCoercion,
isObjectProperty,
shouldFlatten,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import isTypeCastComment from "../utilities/is-type-cast-comment.js";
import {
isArrayExpression,
@@ -32,6 +25,12 @@ import {
isObjectExpression,
isReturnOrThrowStatement,
} from "../utilities/node-types.js";
import {
hasLeadingOwnLineComment,
isBooleanTypeCoercion,
isObjectProperty,
shouldFlatten,
} from "../utilities/utilities.js";
/** @import {Doc} from "../../document/index.js" */
+2 -5
View File
@@ -1,11 +1,8 @@
import { hardline, indent } from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import {
CommentCheckFlags,
hasComment,
isNextLineEmpty,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isNextLineEmpty } from "../utilities/utilities.js";
import { printStatementSequence } from "./statement-sequence.js";
/** @import {Doc} from "../../document/index.js" */
+15 -16
View File
@@ -10,22 +10,7 @@ import {
softline,
willBreak,
} from "../../document/index.js";
import {
CommentCheckFlags,
getCallArguments,
getCallArgumentSelector,
getFunctionParameters,
hasComment,
isFunctionCompositionArgs,
isLongCurriedCallExpression,
isNextLineEmpty,
isObjectProperty,
isSimpleCallArgument,
isSimpleType,
iterateCallArgumentsPath,
shouldPrintComma,
stripChainElementWrappers,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import {
isArrayExpression,
isBinaryCastExpression,
@@ -37,6 +22,20 @@ import {
isRegExpLiteral,
isStringLiteral,
} from "../utilities/node-types.js";
import {
getCallArguments,
getCallArgumentSelector,
getFunctionParameters,
isFunctionCompositionArgs,
isLongCurriedCallExpression,
isNextLineEmpty,
isObjectProperty,
isSimpleCallArgument,
isSimpleType,
iterateCallArgumentsPath,
shouldPrintComma,
stripChainElementWrappers,
} from "../utilities/utilities.js";
import { isConciselyPrintedArray } from "./array.js";
import { printDanglingCommentsInList } from "./miscellaneous.js";
+8 -8
View File
@@ -1,15 +1,15 @@
import { group, join, lineSuffixBoundary } from "../../document/index.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import {
getCallArguments,
hasComment,
isMemberish,
isNodeMatches,
isTemplateOnItsOwnLine,
iterateCallArgumentsPath,
} from "../utilities/index.js";
import { hasComment } from "../utilities/comments.js";
import { isNodeMatches } from "../utilities/is-node-matches.js";
import { isCallExpression, isStringLiteral } from "../utilities/node-types.js";
import { isTestCall } from "../utilities/test-libraries.js";
import {
getCallArguments,
isMemberish,
isTemplateOnItsOwnLine,
iterateCallArgumentsPath,
} from "../utilities/utilities.js";
import printCallArguments from "./call-arguments.js";
import printMemberChain from "./member-chain.js";
import { printOptionalToken } from "./miscellaneous.js";
+3 -4
View File
@@ -12,12 +12,11 @@ import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import { locEnd, locStart } from "../loc.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
getComments,
hasComment,
isNextLineEmpty,
shouldPrintComma,
} from "../utilities/index.js";
} from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import { isNextLineEmpty, shouldPrintComma } from "../utilities/utilities.js";
import { shouldHugTheOnlyParameter } from "./function-parameters.js";
/*
+3 -6
View File
@@ -14,13 +14,10 @@ import {
} from "../../main/comments/print.js";
import createGroupIdMapper from "../../utilities/create-group-id-mapper.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
stripChainElementWrappers,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import { isMemberExpression } from "../utilities/node-types.js";
import { stripChainElementWrappers } from "../utilities/utilities.js";
import { printAssignment } from "./assignment.js";
import { printClassMemberDecorators } from "./decorators.js";
import { printMethod } from "./function.js";
+3 -6
View File
@@ -7,17 +7,14 @@ import {
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import UnexpectedNodeError from "../../utilities/unexpected-node-error.js";
import {
CommentCheckFlags,
hasComment,
isMeaningfulEmptyStatement,
isMethod,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isMeaningfulEmptyStatement } from "../utilities/is-meaningful-empty-statement.js";
import {
isArrayExpression,
isLiteral,
isObjectExpression,
} from "../utilities/node-types.js";
import { isMethod } from "../utilities/utilities.js";
import { printArray } from "./array.js";
import { printArrowFunction } from "./arrow-function.js";
import {
@@ -8,7 +8,7 @@ import {
isSingleVueEventBindingExpressionStatement,
shouldExpressionStatementPrintLeadingSemicolon,
} from "../semicolon/semicolon.js";
import { CommentCheckFlags, getComments } from "../utilities/index.js";
import { CommentCheckFlags, getComments } from "../utilities/comments.js";
import { shouldExpressionStatementPrintOwnComments } from "../utilities/should-expression-statement-print-own-comments.js";
import {
isVueEventBindingFunctionExpression,
+1 -1
View File
@@ -5,8 +5,8 @@ import { replaceEndOfLine } from "../../document/index.js";
import printNumber from "../../utilities/print-number.js";
import printString from "../../utilities/print-string.js";
import getRaw from "../utilities/get-raw.js";
import { isMethod } from "../utilities/index.js";
import isFlowKeywordType from "../utilities/is-flow-keyword-type.js";
import { isMethod } from "../utilities/utilities.js";
import { printArray } from "./array.js";
import { printArrayType } from "./array-type.js";
import { printBinaryCastExpression } from "./cast-expression.js";
+8 -8
View File
@@ -10,9 +10,15 @@ import {
willBreak,
} from "../../document/index.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { hasComment } from "../utilities/comments.js";
import {
isArrayExpression,
isObjectExpression,
isObjectType,
} from "../utilities/node-types.js";
import { isTestCall } from "../utilities/test-libraries.js";
import {
getFunctionParameters,
hasComment,
hasRestParameter,
isFlowObjectTypePropertyAFunction,
isNextLineEmpty,
@@ -20,13 +26,7 @@ import {
isTypeAnnotationAFunction,
iterateFunctionParametersPath,
shouldPrintComma,
} from "../utilities/index.js";
import {
isArrayExpression,
isObjectExpression,
isObjectType,
} from "../utilities/node-types.js";
import { isTestCall } from "../utilities/test-libraries.js";
} from "../utilities/utilities.js";
import { printDanglingCommentsInList } from "./miscellaneous.js";
/** @import AstPath from "../../common/ast-path.js" */
+1 -1
View File
@@ -1,6 +1,6 @@
import { group } from "../../document/index.js";
import { hasSameLocStart } from "../loc.js";
import { isFlowObjectTypePropertyAFunction } from "../utilities/index.js";
import { isFlowObjectTypePropertyAFunction } from "../utilities/utilities.js";
import { printClassMemberSemicolon } from "./class.js";
import {
printFunctionParameters,
+3 -4
View File
@@ -1,13 +1,12 @@
import * as assert from "#universal/assert";
import { group } from "../../document/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isCallExpression } from "../utilities/node-types.js";
import {
CommentCheckFlags,
getCallArguments,
getFunctionParameters,
hasComment,
isMethod,
} from "../utilities/index.js";
import { isCallExpression } from "../utilities/node-types.js";
} from "../utilities/utilities.js";
import {
printFunctionParameters,
shouldBreakFunctionParameters,
+2 -5
View File
@@ -1,10 +1,7 @@
import { group, hardline } from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import {
CommentCheckFlags,
hasComment,
needsHardlineAfterDanglingComment,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { needsHardlineAfterDanglingComment } from "../utilities/utilities.js";
import { adjustClause, printIfStatementCondition } from "./miscellaneous.js";
/**
+1 -1
View File
@@ -5,7 +5,7 @@ import {
join,
softline,
} from "../../document/index.js";
import { shouldPrintComma } from "../utilities/index.js";
import { shouldPrintComma } from "../utilities/utilities.js";
import { printClassMemberSemicolon } from "./class.js";
import { printTypeAnnotationProperty } from "./type-annotation.js";
+3 -6
View File
@@ -8,13 +8,10 @@ import {
import { printComments } from "../../main/comments/print.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
isIifeCalleeOrTaggedTemplateExpressionTag,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import isIgnored from "../utilities/is-ignored.js";
import { isIifeCalleeOrTaggedTemplateExpressionTag } from "../utilities/utilities.js";
import { printAngular } from "./angular.js";
import { printDecorators } from "./decorators.js";
import { printEstree } from "./estree.js";
+1 -1
View File
@@ -1,6 +1,6 @@
import { group, indent, line } from "../../document/index.js";
import { hasLeadingOwnLineComment } from "../utilities/index.js";
import { isObjectType } from "../utilities/node-types.js";
import { hasLeadingOwnLineComment } from "../utilities/utilities.js";
// `TSIntersectionType` and `IntersectionTypeAnnotation`
function printIntersectionType(path, options, print) {
+6 -62
View File
@@ -20,16 +20,12 @@ import {
} from "../../main/comments/print.js";
import { getPreferredQuote } from "../../utilities/get-preferred-quote.js";
import UnexpectedNodeError from "../../utilities/unexpected-node-error.js";
import WhitespaceUtilities from "../../utilities/whitespace-utilities.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import getRaw from "../utilities/get-raw.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
hasNodeIgnoreComment,
stripChainElementWrappers,
} from "../utilities/index.js";
import { isMeaningfulJsxText } from "../utilities/is-meaningful-jsx-text.js";
import { jsxWhitespace } from "../utilities/jsx-whitespace.js";
import {
isArrayExpression,
isBinaryish,
@@ -38,6 +34,7 @@ import {
isObjectExpression,
isStringLiteral,
} from "../utilities/node-types.js";
import { stripChainElementWrappers } from "../utilities/utilities.js";
/**
@import AstPath from "../../common/ast-path.js";
@@ -45,16 +42,6 @@ import {
@import {Doc} from "../../document/index.js";
*/
/*
Only the following are treated as whitespace inside JSX.
- U+0020 SPACE
- U+000A LF
- U+000D CR
- U+0009 TAB
*/
const jsxWhitespace = new WhitespaceUtilities(" \n\r\t");
const isEmptyStringOrAnyLine = (doc) =>
doc === "" || doc === line || doc === hardline || doc === softline;
@@ -855,20 +842,6 @@ function isEmptyJsxElement(node) {
return child.type === "JSXText" && !isMeaningfulJsxText(child);
}
// Meaningful if it contains non-whitespace characters,
// or it contains whitespace without a new line.
/**
* @param {Node} node
* @returns {boolean}
*/
function isMeaningfulJsxText(node) {
return (
node.type === "JSXText" &&
(jsxWhitespace.hasNonWhitespaceCharacter(getRaw(node)) ||
!/\n/.test(getRaw(node)))
);
}
// Detect an expression node representing `{" "}`
function isJsxWhitespaceExpression(node) {
return (
@@ -879,33 +852,4 @@ function isJsxWhitespaceExpression(node) {
);
}
/**
* @param {AstPath} path
* @returns {boolean}
*/
function hasJsxIgnoreComment(path) {
const { node, parent } = path;
if (!isJsxElement(node) || !isJsxElement(parent)) {
return false;
}
// Lookup the previous sibling, ignoring any empty JSXText elements
const { index, siblings } = path;
let prevSibling;
for (let i = index; i > 0; i--) {
const candidate = siblings[i - 1];
if (candidate.type === "JSXText" && !isMeaningfulJsxText(candidate)) {
continue;
}
prevSibling = candidate;
break;
}
return (
prevSibling?.type === "JSXExpressionContainer" &&
prevSibling.expression.type === "JSXEmptyExpression" &&
hasNodeIgnoreComment(prevSibling.expression)
);
}
export { hasJsxIgnoreComment, printJsx };
export { printJsx };
+1 -1
View File
@@ -10,8 +10,8 @@ import { printDanglingComments } from "../../main/comments/print.js";
import hasNewline from "../../utilities/has-newline.js";
import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import { locEnd, locStart } from "../loc.js";
import { CommentCheckFlags, getComments } from "../utilities/comments.js";
import getTextWithoutComments from "../utilities/get-text-without-comments.js";
import { CommentCheckFlags, getComments } from "../utilities/index.js";
import isLineComment from "../utilities/is-line-comment.js";
import { printClassMemberSemicolon } from "./class.js";
+3 -4
View File
@@ -13,13 +13,12 @@ import {
printDanglingComments,
} from "../../main/comments/print.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
hasLeadingOwnLineComment,
isNextLineEmpty,
} from "../utilities/index.js";
} from "../utilities/utilities.js";
/*
- `MatchExpression` (Flow)
+7 -8
View File
@@ -13,20 +13,19 @@ import getNextNonSpaceNonCommentCharacterIndex from "../../utilities/get-next-no
import isNextLineEmptyAfterIndex from "../../utilities/is-next-line-empty.js";
import { locEnd } from "../loc.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import {
CommentCheckFlags,
hasComment,
isLongCurriedCallExpression,
isMemberish,
isNextLineEmpty,
isSimpleCallArgument,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import {
isCallExpression,
isFunctionOrArrowExpression,
isMemberExpression,
isNumericLiteral,
} from "../utilities/node-types.js";
import {
isLongCurriedCallExpression,
isMemberish,
isNextLineEmpty,
isSimpleCallArgument,
} from "../utilities/utilities.js";
import { printBindExpressionCallee } from "./bind-expression.js";
import printCallArguments from "./call-arguments.js";
import { printMemberLookup } from "./member.js";
+4 -4
View File
@@ -5,16 +5,16 @@ import {
lineSuffixBoundary,
softline,
} from "../../document/index.js";
import {
getCallArguments,
stripChainElementWrappers,
} from "../utilities/index.js";
import {
isCallExpression,
isChainElementWrapper,
isMemberExpression,
isNumericLiteral,
} from "../utilities/node-types.js";
import {
getCallArguments,
stripChainElementWrappers,
} from "../utilities/utilities.js";
import { printOptionalToken } from "./miscellaneous.js";
const isCallExpressionWithArguments = (node) =>
+2 -5
View File
@@ -6,11 +6,8 @@ import {
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import {
isCallExpression,
isMemberExpression,
+4 -5
View File
@@ -12,16 +12,15 @@ import { printDanglingComments } from "../../main/comments/print.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import UnexpectedNodeError from "../../utilities/unexpected-node-error.js";
import { locEnd, locStart } from "../loc.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import getTextWithoutComments from "../utilities/get-text-without-comments.js";
import { isStringLiteral } from "../utilities/node-types.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
isShorthandSpecifier,
needsHardlineAfterDanglingComment,
shouldPrintComma,
} from "../utilities/index.js";
import { isStringLiteral } from "../utilities/node-types.js";
} from "../utilities/utilities.js";
import { printDecoratorsBeforeExport } from "./decorators.js";
import { printDeclareToken } from "./miscellaneous.js";
import { printObject } from "./object.js";
+4 -5
View File
@@ -12,16 +12,15 @@ import hasNewline from "../../utilities/has-newline.js";
import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import { locEnd, locStart } from "../loc.js";
import getTextWithoutComments from "../utilities/get-text-without-comments.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
getComments,
hasComment,
isNextLineEmpty,
shouldPrintComma,
} from "../utilities/index.js";
} from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import getTextWithoutComments from "../utilities/get-text-without-comments.js";
import { isObjectType } from "../utilities/node-types.js";
import { isNextLineEmpty, shouldPrintComma } from "../utilities/utilities.js";
import { shouldHugTheOnlyParameter } from "./function-parameters.js";
import {
printDanglingCommentsInList,
+1 -1
View File
@@ -6,7 +6,7 @@ import {
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import { CommentCheckFlags, hasComment } from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isBinaryish } from "../utilities/node-types.js";
import { returnArgumentHasLeadingComment } from "../utilities/return-statement-has-leading-comment.js";
+1 -1
View File
@@ -1,5 +1,5 @@
import { hardline } from "../../document/index.js";
import { isNextLineEmpty } from "../utilities/index.js";
import { isNextLineEmpty } from "../utilities/utilities.js";
/**
* @import {Doc} from "../../document/index.js"
+2 -5
View File
@@ -6,11 +6,8 @@ import {
softline,
} from "../../document/index.js";
import { printDanglingComments } from "../../main/comments/print.js";
import {
CommentCheckFlags,
hasComment,
isNextLineEmpty,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isNextLineEmpty } from "../utilities/utilities.js";
import { printStatementSequence } from "./statement-sequence.js";
function printSwitchStatement(path, options, print) {
+2 -2
View File
@@ -19,13 +19,13 @@ import {
CommentCheckFlags,
getComments,
hasComment,
stripChainElementWrappers,
} from "../utilities/index.js";
} from "../utilities/comments.js";
import {
isBinaryCastExpression,
isBinaryish,
isMemberExpression,
} from "../utilities/node-types.js";
import { stripChainElementWrappers } from "../utilities/utilities.js";
/**
* @import {Doc} from "../../document/index.js"
+5 -3
View File
@@ -16,9 +16,7 @@ import {
CommentCheckFlags,
getComments,
hasComment,
isLoneShortArgument,
isSimpleExpressionByNodeCount,
} from "../utilities/index.js";
} from "../utilities/comments.js";
import isBlockComment from "../utilities/is-block-comment.js";
import {
isBinaryCastExpression,
@@ -29,6 +27,10 @@ import {
isMemberExpression,
isReturnOrThrowStatement,
} from "../utilities/node-types.js";
import {
isLoneShortArgument,
isSimpleExpressionByNodeCount,
} from "../utilities/utilities.js";
import { printTernaryOld } from "./ternary-old.js";
/**
+1 -1
View File
@@ -1,7 +1,7 @@
import { indent, softline } from "../../document/index.js";
import hasNewline from "../../utilities/has-newline.js";
import { locEnd, locStart } from "../loc.js";
import { hasComment } from "../utilities/index.js";
import { hasComment } from "../utilities/comments.js";
import isBlockComment from "../utilities/is-block-comment.js";
function printTryStatement(path, options, print) {
+2 -5
View File
@@ -1,9 +1,6 @@
import {
CommentCheckFlags,
hasComment,
isSimpleType,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isObjectType, isUnionType } from "../utilities/node-types.js";
import { isSimpleType } from "../utilities/utilities.js";
import { shouldHugUnionType } from "./union-type.js";
/**
+5 -6
View File
@@ -12,14 +12,13 @@ import {
import { printDanglingComments } from "../../main/comments/print.js";
import hasNewline from "../../utilities/has-newline.js";
import { locEnd } from "../loc.js";
import {
CommentCheckFlags,
getFunctionParameters,
hasComment,
shouldPrintComma,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { isObjectType } from "../utilities/node-types.js";
import { isTestCall } from "../utilities/test-libraries.js";
import {
getFunctionParameters,
shouldPrintComma,
} from "../utilities/utilities.js";
import { isArrowFunctionVariableDeclarator } from "./assignment.js";
import {
printTypeAnnotationProperty,
+6 -7
View File
@@ -12,18 +12,17 @@ import {
printCommentsSeparately,
} from "../../main/comments/print.js";
import needsParentheses from "../parentheses/needs-parentheses.js";
import {
CommentCheckFlags,
createTypeCheckFunction,
hasComment,
hasLeadingOwnLineComment,
shouldUnionTypePrintOwnComments,
} from "../utilities/index.js";
import { CommentCheckFlags, hasComment } from "../utilities/comments.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
import {
isConditionalType,
isTupleType,
isTypeAlias,
} from "../utilities/node-types.js";
import {
hasLeadingOwnLineComment,
shouldUnionTypePrintOwnComments,
} from "../utilities/utilities.js";
/**
@import {Doc} from "../../document/index.js";
@@ -1,5 +1,5 @@
import { group, hardline, indent, line } from "../../document/index.js";
import { hasComment } from "../utilities/index.js";
import { hasComment } from "../utilities/comments.js";
import { printDeclareToken } from "./miscellaneous.js";
function printVariableDeclaration(path, options, print) {
+4 -1
View File
@@ -1,7 +1,10 @@
import needsParentheses from "../parentheses/needs-parentheses.js";
import { shouldPrintParamsWithoutParens } from "../print/function.js";
import { getLeftSidePathName, hasNakedLeftSide } from "../utilities/index.js";
import { isJsxElement } from "../utilities/node-types.js";
import {
getLeftSidePathName,
hasNakedLeftSide,
} from "../utilities/utilities.js";
function shouldExpressionStatementPrintLeadingSemicolon(path, options) {
if (options.semi) {
+84
View File
@@ -0,0 +1,84 @@
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import isBlockComment from "./is-block-comment.js";
import isLineComment from "./is-line-comment.js";
import { isPrettierIgnoreComment } from "./is-prettier-ignore-comment.js";
/**
@import {
Node,
Comment,
} from "../types/estree.js";
@import AstPath from "../../common/ast-path.js";
*/
/** @enum {number} */
const CommentCheckFlags = {
/** Check comment is a leading comment */
Leading: 1 << 1,
/** Check comment is a trailing comment */
Trailing: 1 << 2,
/** Check comment is a dangling comment */
Dangling: 1 << 3,
/** Check comment is a block comment */
Block: 1 << 4,
/** Check comment is a line comment */
Line: 1 << 5,
/** Check comment is a `prettier-ignore` comment */
PrettierIgnore: 1 << 6,
/** Check comment is the first attached comment */
First: 1 << 7,
/** Check comment is the last attached comment */
Last: 1 << 8,
};
const getCommentTestFunction = (flags, fn) => {
if (typeof flags === "function") {
fn = flags;
flags = 0;
}
if (flags || fn) {
return (comment, index, comments) =>
!(
(flags & CommentCheckFlags.Leading && !comment.leading) ||
(flags & CommentCheckFlags.Trailing && !comment.trailing) ||
(flags & CommentCheckFlags.Dangling &&
(comment.leading || comment.trailing)) ||
(flags & CommentCheckFlags.Block && !isBlockComment(comment)) ||
(flags & CommentCheckFlags.Line && !isLineComment(comment)) ||
(flags & CommentCheckFlags.First && index !== 0) ||
(flags & CommentCheckFlags.Last && index !== comments.length - 1) ||
(flags & CommentCheckFlags.PrettierIgnore &&
!isPrettierIgnoreComment(comment)) ||
(fn && !fn(comment))
);
}
};
/**
* @param {Node} node
* @param {number | function} [flags]
* @param {function} [fn]
* @returns {boolean}
*/
function hasComment(node, flags, fn) {
if (!isNonEmptyArray(node?.comments)) {
return false;
}
const test = getCommentTestFunction(flags, fn);
return test ? node.comments.some(test) : true;
}
/**
* @param {Node} node
* @param {number | function} [flags]
* @param {function} [fn]
* @returns {Comment[]}
*/
function getComments(node, flags, fn) {
if (!Array.isArray(node?.comments)) {
return [];
}
const test = getCommentTestFunction(flags, fn);
return test ? node.comments.filter(test) : node.comments;
}
export { CommentCheckFlags, getComments, hasComment };
@@ -31,4 +31,4 @@ function createTypeCheckFunction(typesArray) {
return (node) => types.has(node?.type);
}
export default createTypeCheckFunction;
export { createTypeCheckFunction };
@@ -0,0 +1,39 @@
import { hasNodeIgnoreComment } from "./has-node-ignore-comment.js";
import { isMeaningfulJsxText } from "./is-meaningful-jsx-text.js";
import { isJsxElement } from "./node-types.js";
/**
@import AstPath from "../../common/ast-path.js";
@import {Node} from "../types/estree.js";
*/
/**
* @param {AstPath} path
* @returns {boolean}
*/
function hasJsxIgnoreComment(path) {
const { node, parent } = path;
if (!isJsxElement(node) || !isJsxElement(parent)) {
return false;
}
// Lookup the previous sibling, ignoring any empty JSXText elements
const { index, siblings } = path;
let prevSibling;
for (let i = index; i > 0; i--) {
const candidate = siblings[i - 1];
if (candidate.type === "JSXText" && !isMeaningfulJsxText(candidate)) {
continue;
}
prevSibling = candidate;
break;
}
return (
prevSibling?.type === "JSXExpressionContainer" &&
prevSibling.expression.type === "JSXEmptyExpression" &&
hasNodeIgnoreComment(prevSibling.expression)
);
}
export { hasJsxIgnoreComment };
@@ -0,0 +1,9 @@
import { CommentCheckFlags, hasComment } from "./comments.js";
function hasNodeIgnoreComment(node) {
return (
node?.prettierIgnore || hasComment(node, CommentCheckFlags.PrettierIgnore)
);
}
export { hasNodeIgnoreComment };
@@ -1,4 +1,4 @@
import createTypeCheckFunction from "./create-type-check-function.js";
import { createTypeCheckFunction } from "./create-type-check-function.js";
/**
@import {Comment} from "../types/estree.js";
@@ -1,4 +1,4 @@
import createTypeCheckFunction from "./create-type-check-function.js";
import { createTypeCheckFunction } from "./create-type-check-function.js";
const isFlowKeywordType = createTypeCheckFunction([
"AnyTypeAnnotation",
+2 -2
View File
@@ -1,5 +1,5 @@
import { hasJsxIgnoreComment } from "../print/jsx.js";
import { hasNodeIgnoreComment } from "./index.js";
import { hasJsxIgnoreComment } from "./has-jsx-ignore-comment.js";
import { hasNodeIgnoreComment } from "./has-node-ignore-comment.js";
function isIgnored(path) {
return hasNodeIgnoreComment(path.node) || hasJsxIgnoreComment(path);
+1 -1
View File
@@ -1,4 +1,4 @@
import createTypeCheckFunction from "./create-type-check-function.js";
import { createTypeCheckFunction } from "./create-type-check-function.js";
/**
@import {Comment} from "../types/estree.js";
@@ -23,4 +23,4 @@ function isMeaningfulEmptyStatement({ node, parent }) {
return false;
}
export default isMeaningfulEmptyStatement;
export { isMeaningfulEmptyStatement };
@@ -0,0 +1,22 @@
import getRaw from "./get-raw.js";
import { jsxWhitespace } from "./jsx-whitespace.js";
/**
@import {Node} from "../types/estree.js";
*/
// Meaningful if it contains non-whitespace characters,
// or it contains whitespace without a new line.
/**
* @param {Node} node
* @returns {boolean}
*/
function isMeaningfulJsxText(node) {
return (
node.type === "JSXText" &&
(jsxWhitespace.hasNonWhitespaceCharacter(getRaw(node)) ||
!/\n/.test(getRaw(node)))
);
}
export { isMeaningfulJsxText };
+1 -1
View File
@@ -59,4 +59,4 @@ function isNodeMatches(node, nameOrPaths) {
);
}
export default isNodeMatches;
export { isNodeMatches };
@@ -0,0 +1,5 @@
function isPrettierIgnoreComment(comment) {
return comment.value.trim() === "prettier-ignore" && !comment.unignore;
}
export { isPrettierIgnoreComment };
@@ -0,0 +1,13 @@
import WhitespaceUtilities from "../../utilities/whitespace-utilities.js";
/*
Only the following are treated as whitespace inside JSX.
- U+0020 SPACE
- U+000A LF
- U+000D CR
- U+0009 TAB
*/
const jsxWhitespace = new WhitespaceUtilities(" \n\r\t");
export { jsxWhitespace };
+1 -1
View File
@@ -1,4 +1,4 @@
import createTypeCheckFunction from "./create-type-check-function.js";
import { createTypeCheckFunction } from "./create-type-check-function.js";
/**
@import {
@@ -1,13 +1,12 @@
import hasNewlineInRange from "../../utilities/has-newline-in-range.js";
import { locEnd, locStart } from "../loc.js";
import { CommentCheckFlags, hasComment } from "./comments.js";
import { isJsxElement } from "./node-types.js";
import {
CommentCheckFlags,
getLeftSide,
hasComment,
hasLeadingOwnLineComment,
hasNakedLeftSide,
} from "./index.js";
import { isJsxElement } from "./node-types.js";
} from "./utilities.js";
// This recurses the return argument, looking for the first token
// (the leftmost leaf node) and, if it (or its parents) has any
@@ -1,5 +1,5 @@
import { shouldExpressionStatementPrintLeadingSemicolon } from "../semicolon/semicolon.js";
import { CommentCheckFlags, getComments } from "./index.js";
import { CommentCheckFlags, getComments } from "./comments.js";
import isTypeCastComment from "./is-type-cast-comment.js";
function shouldExpressionStatementPrintOwnComments(path, options) {
+2 -2
View File
@@ -1,11 +1,11 @@
import { getCallArguments, getFunctionParameters } from "./index.js";
import isNodeMatches from "./is-node-matches.js";
import { isNodeMatches } from "./is-node-matches.js";
import {
isCallExpression,
isFunctionOrArrowExpression,
isNumericLiteral,
isStringLiteral,
} from "./node-types.js";
import { getCallArguments, getFunctionParameters } from "./utilities.js";
/**
@import {
@@ -2,7 +2,6 @@ import { hasDescendant } from "../../utilities/ast.js";
import getStringWidth from "../../utilities/get-string-width.js";
import hasNewline from "../../utilities/has-newline.js";
import isNextLineEmptyAfterIndex from "../../utilities/is-next-line-empty.js";
import isNonEmptyArray from "../../utilities/is-non-empty-array.js";
import isObject from "../../utilities/is-object.js";
import printString from "../../utilities/print-string.js";
import {
@@ -13,11 +12,12 @@ import {
locStart,
} from "../loc.js";
import getVisitorKeys from "../traverse/get-visitor-keys.js";
import createTypeCheckFunction from "./create-type-check-function.js";
import { CommentCheckFlags, getComments, hasComment } from "./comments.js";
import { createTypeCheckFunction } from "./create-type-check-function.js";
import getRaw from "./get-raw.js";
import { hasNodeIgnoreComment } from "./has-node-ignore-comment.js";
import isBlockComment from "./is-block-comment.js";
import isFlowKeywordType from "./is-flow-keyword-type.js";
import isLineComment from "./is-line-comment.js";
import isTsKeywordType from "./is-ts-keyword-type.js";
import {
isArrayExpression,
@@ -760,86 +760,6 @@ function getCallArgumentSelector(node, index) {
throw new RangeError("Invalid argument index");
}
function isPrettierIgnoreComment(comment) {
return comment.value.trim() === "prettier-ignore" && !comment.unignore;
}
function hasNodeIgnoreComment(node) {
return (
node?.prettierIgnore || hasComment(node, CommentCheckFlags.PrettierIgnore)
);
}
/** @enum {number} */
const CommentCheckFlags = {
/** Check comment is a leading comment */
Leading: 1 << 1,
/** Check comment is a trailing comment */
Trailing: 1 << 2,
/** Check comment is a dangling comment */
Dangling: 1 << 3,
/** Check comment is a block comment */
Block: 1 << 4,
/** Check comment is a line comment */
Line: 1 << 5,
/** Check comment is a `prettier-ignore` comment */
PrettierIgnore: 1 << 6,
/** Check comment is the first attached comment */
First: 1 << 7,
/** Check comment is the last attached comment */
Last: 1 << 8,
};
const getCommentTestFunction = (flags, fn) => {
if (typeof flags === "function") {
fn = flags;
flags = 0;
}
if (flags || fn) {
return (comment, index, comments) =>
!(
(flags & CommentCheckFlags.Leading && !comment.leading) ||
(flags & CommentCheckFlags.Trailing && !comment.trailing) ||
(flags & CommentCheckFlags.Dangling &&
(comment.leading || comment.trailing)) ||
(flags & CommentCheckFlags.Block && !isBlockComment(comment)) ||
(flags & CommentCheckFlags.Line && !isLineComment(comment)) ||
(flags & CommentCheckFlags.First && index !== 0) ||
(flags & CommentCheckFlags.Last && index !== comments.length - 1) ||
(flags & CommentCheckFlags.PrettierIgnore &&
!isPrettierIgnoreComment(comment)) ||
(fn && !fn(comment))
);
}
};
/**
* @param {Node} node
* @param {number | function} [flags]
* @param {function} [fn]
* @returns {boolean}
*/
function hasComment(node, flags, fn) {
if (!isNonEmptyArray(node?.comments)) {
return false;
}
const test = getCommentTestFunction(flags, fn);
return test ? node.comments.some(test) : true;
}
/**
* @param {Node} node
* @param {number | function} [flags]
* @param {function} [fn]
* @returns {Comment[]}
*/
function getComments(node, flags, fn) {
if (!Array.isArray(node?.comments)) {
return [];
}
const test = getCommentTestFunction(flags, fn);
return test ? node.comments.filter(test) : node.comments;
}
/**
* @param {Node} node
* @returns {boolean}
@@ -959,20 +879,15 @@ function stripChainElementWrappers(node) {
}
export {
CommentCheckFlags,
createTypeCheckFunction,
getCallArguments,
getCallArgumentSelector,
getComments,
getFunctionParameters,
getLeftSide,
getLeftSidePathName,
getPrecedence,
hasComment,
hasLeadingOwnLineComment,
hasNakedLeftSide,
hasNode,
hasNodeIgnoreComment,
hasRestParameter,
isBitwiseOperator,
isBooleanTypeCoercion,
@@ -986,7 +901,6 @@ export {
isNextLineEmpty,
isNullishCoalescing,
isObjectProperty,
isPrettierIgnoreComment,
isShorthandSpecifier,
isSignedNumericLiteral,
isSimpleCallArgument,
@@ -1004,5 +918,3 @@ export {
startsWithNoLookaheadToken,
stripChainElementWrappers,
};
export { default as isMeaningfulEmptyStatement } from "./is-meaningful-empty-statement.js";
export { default as isNodeMatches } from "./is-node-matches.js";
@@ -1,4 +1,4 @@
import createTypeCheckFunction from "./create-type-check-function.js";
import { createTypeCheckFunction } from "../utilities/create-type-check-function.js";
// https://github.com/vuejs/core/blob/35785f3cd7bd86cbec3f8324022491da2d088b61/packages/compiler-core/src/babelUtils.ts#L498
const isVueEventBindingTsNode = createTypeCheckFunction([