chore: Update prettier v3.9 (#18147)

This commit is contained in:
liuxingbaoyu
2026-07-20 20:37:08 +02:00
committed by GitHub
parent da00d1273f
commit 26ff333af8
49 changed files with 129 additions and 319 deletions
+1 -5
View File
@@ -109,11 +109,7 @@ async function generateHelpers(
}
type TypesHelperKind =
| "asserts"
| "ast-types"
| "builders"
| "constants"
| "validators";
"asserts" | "ast-types" | "builders" | "constants" | "validators";
function generateTypeHelpers(
helperKind: TypesHelperKind,
+1 -1
View File
@@ -364,7 +364,7 @@ function pluginPackageJsonMacro({ types: t }: PluginAPI) {
// instead of looping through the folders hierarchy
let pkg;
for (let dir = pathUtils.dirname(this.filename!); ; ) {
for (let dir = pathUtils.dirname(this.filename!); ;) {
try {
pkg = fs.readFileSync(pathUtils.join(dir, "package.json"), "utf8");
break;
@@ -14,9 +14,10 @@ export default {
const scope = context.sourceCode.getScope(node);
const origin = getReferenceOrigin(callee, scope);
if (
!(origin && (origin.kind === "import" || origin.kind === "property"))
)
if (!(
origin &&
(origin.kind === "import" || origin.kind === "property")
))
return;
const { name } = origin;
@@ -24,9 +24,10 @@ export default {
const scope = context.sourceCode.getScope(node);
const origin = getReferenceOrigin(callee, scope);
if (
!(origin && (origin.kind === "import" || origin.kind === "property"))
)
if (!(
origin &&
(origin.kind === "import" || origin.kind === "property")
))
return;
const { name } = origin;
@@ -44,9 +44,7 @@ export default {
function functionVisitor(
node: (
| FunctionDeclaration
| FunctionExpression
| ArrowFunctionExpression
FunctionDeclaration | FunctionExpression | ArrowFunctionExpression
) &
Rule.NodeParentExtension,
) {
@@ -91,9 +91,7 @@ export default function getReferenceOrigin(
// @ts-expect-error upstream typing issue: https://github.com/eslint/eslint/pull/20798
index: definition.index,
functionNode: definition.node as (
| ArrowFunctionExpression
| FunctionDeclaration
| FunctionExpression
ArrowFunctionExpression | FunctionDeclaration | FunctionExpression
) &
Rule.NodeParentExtension,
name: "",
@@ -188,8 +186,7 @@ function getPatternPath(node: Identifier & Rule.NodeParentExtension) {
}
} while (
(current = current.parent.parent as
| (Node & Rule.NodeParentExtension)
| null)
(Node & Rule.NodeParentExtension) | null)
);
return path;
+1 -1
View File
@@ -77,7 +77,7 @@
"open": "^11.0.0",
"p-limit": "^7.2.0",
"pkg-pr-new": "^0.0.54",
"prettier": "^3.8.1",
"prettier": "^3.9.5",
"publint": "^0.3.17",
"rollup": "^4.18.0",
"rollup-plugin-dts": "patch:rollup-plugin-dts@npm%3A6.1.0#~/.yarn/patches/rollup-plugin-dts-npm-6.1.0-6d41e665a7.patch",
+1 -6
View File
@@ -371,12 +371,7 @@ function makeSimpleConfigurator(
// Types are limited here so that in the future these values can be used
// as part of Babel's caching logic.
export type SimpleType =
| string
| boolean
| number
| null
| undefined
| Promise<SimpleType>;
string | boolean | number | null | undefined | Promise<SimpleType>;
export function assertSimpleType(value: unknown): SimpleType {
if (isThenable(value)) {
throw new Error(
@@ -316,9 +316,7 @@ export type RootInputSourceMapOption = InputSourceMap | boolean;
export type RootMode = "root" | "upward" | "upward-optional";
export type TargetsListOrObject =
| Targets
| InputTargets
| InputTargets["browsers"];
Targets | InputTargets | InputTargets["browsers"];
export type OptionsSource =
| "arguments"
+1 -1
View File
@@ -289,7 +289,7 @@ export default class Buffer {
}
hasContent(): boolean {
return this._last !== 0 /*|| this._queuedChar !== 0*/;
return this._last !== 0; /*|| this._queuedChar !== 0*/
}
/**
@@ -137,9 +137,7 @@ export function _methodHead(this: Printer, node: t.Method | t.TSDeclareMethod) {
export function _predicate(
this: Printer,
node:
| t.FunctionDeclaration
| t.FunctionExpression
| t.ArrowFunctionExpression,
t.FunctionDeclaration | t.FunctionExpression | t.ArrowFunctionExpression,
noLineTerminatorAfter?: boolean,
) {
if (node.predicate) {
@@ -163,7 +161,7 @@ export function _functionHead(
// We prevent inner comments from being printed here,
// so that they are always consistently printed in the
// same place regardless of the function type.
this._innerCommentsState = 0 /* INNER_COMMENT_STATE.DISALLOWED */;
this._innerCommentsState = 0; /* INNER_COMMENT_STATE.DISALLOWED */
}
this.space();
}
@@ -173,7 +171,7 @@ export function _functionHead(
// We prevent inner comments from being printed here,
// so that they are always consistently printed in the
// same place regardless of the function type.
this._innerCommentsState = 0 /* INNER_COMMENT_STATE.DISALLOWED */;
this._innerCommentsState = 0; /* INNER_COMMENT_STATE.DISALLOWED */
}
this.token("*");
}
@@ -290,12 +288,8 @@ function _getFuncIdName(
> | null,
) {
let id:
| t.Expression
| t.PrivateName
| t.LVal
| t.VoidPattern
| undefined
| null = idNode;
t.Expression | t.PrivateName | t.LVal | t.VoidPattern | undefined | null =
idNode;
if (!id && parent) {
const parentType = parent.type;
@@ -52,8 +52,7 @@ export function isUnreleasedVersion(
export function getLowestUnreleased(a: string, b: string, env: Target): string {
const unreleasedLabel:
| (typeof unreleasedLabels)[keyof typeof unreleasedLabels]
| undefined =
(typeof unreleasedLabels)[keyof typeof unreleasedLabels] | undefined =
// @ts-expect-error unreleasedLabel is undefined when env is not safari
unreleasedLabels[env];
if (a === unreleasedLabel) {
@@ -34,9 +34,7 @@ type ClassElement =
| t.StaticBlock;
type ClassElementCanHaveComputedKeys =
| t.ClassMethod
| t.ClassProperty
| t.ClassAccessorProperty;
t.ClassMethod | t.ClassProperty | t.ClassAccessorProperty;
export type DecoratorVersionKind = "2023-11";
@@ -615,8 +613,7 @@ interface DecoratorInfo {
name: t.StringLiteral | t.Expression;
privateMethods:
| (t.FunctionExpression | t.ArrowFunctionExpression)[]
| undefined;
(t.FunctionExpression | t.ArrowFunctionExpression)[] | undefined;
// The names of local variables that will be used/returned from the decoration
locals: t.Identifier | t.Identifier[] | undefined;
@@ -1365,8 +1362,7 @@ function transformClass(
let locals: t.Identifier[];
if (hasDecorators) {
let privateMethods: (
| t.FunctionExpression
| t.ArrowFunctionExpression
t.FunctionExpression | t.ArrowFunctionExpression
)[];
let nameExpr: t.Expression;
@@ -1654,9 +1650,7 @@ function transformClass(
if (classDecorators) {
classLocals.push(classIdLocal, classInitLocal!);
const statics: (
| t.ClassProperty
| t.ClassPrivateProperty
| t.ClassPrivateMethod
t.ClassProperty | t.ClassPrivateProperty | t.ClassPrivateMethod
)[] = [];
path.get("body.body").forEach(element => {
if (
@@ -1862,8 +1856,7 @@ function transformClass(
if (computedKeyAssignments.length > 0) {
const elements = originalClassPath.get("body.body");
let firstPublicElement:
| NodePath<t.ClassProperty | t.ClassMethod>
| undefined;
NodePath<t.ClassProperty | t.ClassMethod> | undefined;
for (const path of elements) {
if (
(path.isClassProperty() || path.isClassMethod()) &&
@@ -254,7 +254,7 @@ const handler = {
}
let regular: t.Expression = member.node;
for (let current: NodePath = member; current !== endPath; ) {
for (let current: NodePath = member; current !== endPath;) {
const parentPath = current.parentPath as NodePath<t.Expression>;
// skip transforming `Foo.#BAR?.call(FOO)`
if (
@@ -36,8 +36,7 @@ function isInType(path: NodePath) {
return (
(
path.parentPath.parent as
| t.ExportDefaultDeclaration
| t.ExportNamedDeclaration
t.ExportDefaultDeclaration | t.ExportNamedDeclaration
).exportKind === "type"
);
default:
@@ -361,9 +361,7 @@ export default function /* @no-mangle */ _regenerator() {
_arg > finallyLoc)
) {
entry[4] = _type as
| OperatorType.Return
| OperatorType.Jump
| OperatorType.Throw;
OperatorType.Return | OperatorType.Jump | OperatorType.Throw;
entry[5] = _arg;
ctx.n = finallyLoc;
method = OperatorType.Next;
@@ -23,7 +23,7 @@ function push(flag) {
const out = cp.execSync(`${process.execPath} --help`).toString();
const re = /(?:(-\w), )?(--[\w-]+)\[?(?:=| \[)/g;
for (let res; (res = re.exec(out)); ) {
for (let res; (res = re.exec(out));) {
if (res[1]) push(res[1]);
push(res[2]);
}
+1 -2
View File
@@ -9,8 +9,7 @@ type SyntaxPlugin =
| "placeholders";
type ParseErrorCode =
| "BABEL_PARSER_SYNTAX_ERROR"
| "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
"BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
// Babel uses "normal" SyntaxErrors for it's errors, but adds some extra
// functionality. This functionality is defined in the
+3 -10
View File
@@ -118,10 +118,7 @@ export default abstract class ExpressionParser extends LValParser {
}
const key = prop.key as
| N.Identifier
| N.StringLiteral
| N.NumericLiteral
| N.BigIntLiteral;
N.Identifier | N.StringLiteral | N.NumericLiteral | N.BigIntLiteral;
// It is either an Identifier or a String/NumericLiteral
const name = key.type === "Identifier" ? key.name : key.value;
@@ -917,12 +914,8 @@ export default abstract class ExpressionParser extends LValParser {
);
}
let finishedNode:
| N.CallExpression
| N.OptionalCallExpression
| N.ArrowFunctionExpression = this.finishCallExpression(
node,
optionalChainMember,
);
N.CallExpression | N.OptionalCallExpression | N.ArrowFunctionExpression =
this.finishCallExpression(node, optionalChainMember);
if (maybeAsyncArrow && this.shouldParseAsyncArrow() && !optional) {
/*:: invariant(refExpressionErrors != null) */
+2 -10
View File
@@ -492,11 +492,7 @@ export default abstract class LValParser extends NodeUtils {
const allowEmpty = flags & ParseBindingListFlags.ALLOW_EMPTY;
const elts: (
| Pattern
| Identifier
| RestElement
| TSParameterProperty
| null
Pattern | Identifier | RestElement | TSParameterProperty | null
)[] = [];
let first = true;
while (!this.eat(close)) {
@@ -736,11 +732,7 @@ export default abstract class LValParser extends NodeUtils {
checkLVal(
expression:
| Expression
| ObjectMember
| RestElement
| Pattern
| TSParameterProperty,
Expression | ObjectMember | RestElement | Pattern | TSParameterProperty,
ancestor: LValAncestor,
binding: BindingFlag = BindingFlag.TYPE_NONE,
checkClashes: Set<string> | false = false,
@@ -955,7 +955,7 @@ export default abstract class StatementParser extends ExpressionParser {
// adding statements to.
let cur;
for (let sawDefault; !this.match(tt.braceR); ) {
for (let sawDefault; !this.match(tt.braceR);) {
if (this.match(tt._case) || this.match(tt._default)) {
const isCase = this.match(tt._case);
if (cur) this.finishNode(cur, "SwitchCase");
@@ -2890,9 +2890,7 @@ export default abstract class StatementParser extends ExpressionParser {
parseImportSpecifierLocal<
T extends
| N.ImportSpecifier
| N.ImportDefaultSpecifier
| N.ImportNamespaceSpecifier,
N.ImportSpecifier | N.ImportDefaultSpecifier | N.ImportNamespaceSpecifier,
>(
node: Undone<N.ImportDeclaration>,
specifier: Undone<T>,
@@ -2904,9 +2902,7 @@ export default abstract class StatementParser extends ExpressionParser {
finishImportSpecifier<
T extends
| N.ImportSpecifier
| N.ImportDefaultSpecifier
| N.ImportNamespaceSpecifier,
N.ImportSpecifier | N.ImportDefaultSpecifier | N.ImportNamespaceSpecifier,
>(
specifier: Undone<T>,
type: T["type"],
+1 -6
View File
@@ -158,10 +158,5 @@ export const mixinPlugins = {
};
export const mixinPluginNames = Object.keys(mixinPlugins) as readonly (
| "estree"
| "jsx"
| "flow"
| "typescript"
| "v8intrinsic"
| "placeholders"
"estree" | "jsx" | "flow" | "typescript" | "v8intrinsic" | "placeholders"
)[];
@@ -595,10 +595,7 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
!insideModule)
) {
const label = this.state.value as
| "const"
| "let"
| "type"
| "interface";
"const" | "let" | "type" | "interface";
throw this.raise(
FlowErrors.UnsupportedDeclareExportKind,
this.state.startLoc,
@@ -958,8 +955,7 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
// Used when parsing type arguments from ES or JSX productions, where the first token
// has been created without state.inType. Thus we need to re-scan the lt token.
flowParseTypeParameterInstantiationInExpression():
| N.TypeParameterInstantiation
| undefined {
N.TypeParameterInstantiation | undefined {
if (this.reScan_lt() !== tt.lt) return;
return this.flowParseTypeParameterInstantiation();
}
@@ -3111,10 +3107,8 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
}, state);
let arrowExpression:
| N.ArrowFunctionExpression
| N.TypeCastExpression
| undefined
| null = null;
N.ArrowFunctionExpression | N.TypeCastExpression | undefined | null =
null;
if (
arrow.node &&
@@ -3214,8 +3208,7 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
setArrowFunctionParameters(
node: Undone<N.ArrowFunctionExpression>,
params:
| (N.Expression | N.SpreadElement)[]
| (N.Expression | N.RestElement)[],
(N.Expression | N.SpreadElement)[] | (N.Expression | N.RestElement)[],
): void {
if (
this.state.noArrowParamsConversionAt.includes(
@@ -302,9 +302,7 @@ export default (superClass: typeof Parser) =>
// or single identifier.
jsxParseElementName():
| N.JSXIdentifier
| N.JSXNamespacedName
| N.JSXMemberExpression {
N.JSXIdentifier | N.JSXNamespacedName | N.JSXMemberExpression {
const startLoc = this.state.startLoc;
let node: N.JSXIdentifier | N.JSXNamespacedName | N.JSXMemberExpression =
this.jsxParseNamespacedName();
@@ -323,9 +321,7 @@ export default (superClass: typeof Parser) =>
// Parses any type of JSX attribute value.
jsxParseAttributeValue():
| N.JSXExpressionContainer
| N.JSXElement
| N.StringLiteral {
N.JSXExpressionContainer | N.JSXElement | N.StringLiteral {
let node;
switch (this.state.type) {
case tt.braceL:
@@ -934,12 +934,10 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
tsTryParseIndexSignature(
node: Undone<N.TSIndexSignature>,
): N.TSIndexSignature | undefined {
if (
!(
this.match(tt.bracketL) &&
this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))
)
) {
if (!(
this.match(tt.bracketL) &&
this.tsLookAhead(this.tsIsUnambiguouslyIndexSignature.bind(this))
)) {
return;
}
@@ -2400,8 +2398,7 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
// Used when parsing type arguments from ES or JSX productions, where the first token
// has been created without state.inType. Thus we need to re-scan the lt token.
tsParseTypeArgumentsInExpression():
| N.TSTypeParameterInstantiation
| undefined {
N.TSTypeParameterInstantiation | undefined {
if (this.reScan_lt() !== tt.lt) return;
return this.tsParseTypeArguments();
}
@@ -4258,10 +4255,7 @@ export default (superClass: ClassWithMixin<typeof Parser, IJSXParserMixin>) =>
toAssignableListItem(
exprList: (
| N.Expression
| N.SpreadElement
| N.RestElement
| N.TSTypeCastExpression
N.Expression | N.SpreadElement | N.RestElement | N.TSTypeCastExpression
)[],
index: number,
isLHS: boolean,
+1 -2
View File
@@ -7,8 +7,7 @@ import { tt, type TokenType } from "./types.ts";
import type { Errors, ParseError } from "../parse-error.ts";
export type DeferredStrictError =
| typeof Errors.StrictNumericEscape
| typeof Errors.StrictOctalLiteral;
typeof Errors.StrictNumericEscape | typeof Errors.StrictOctalLiteral;
export const enum LoopLabelKind {
Loop = 1,
+3 -10
View File
@@ -186,9 +186,7 @@ export type ESTreeClassElement =
export type ESTreeLiteral = EstreeLiteral | EstreeBigIntLiteral;
export type ESTreeExpression =
| EstreeChainExpression
| ESTreeLiteral
| EstreeTSEmptyBodyFunctionExpression;
EstreeChainExpression | ESTreeLiteral | EstreeTSEmptyBodyFunctionExpression;
export type Node = N.Node | ESTreeNode | TSTypeCastExpression;
@@ -198,9 +196,7 @@ export type NormalFunction = N.FunctionDeclaration | N.FunctionExpression;
export type Assignable = N.AssignmentExpression["left"];
export type ObjectOrClassMember =
| N.ClassMethod
| N.ClassProperty
| N.ObjectMember;
N.ClassMethod | N.ClassProperty | N.ObjectMember;
export type ObjectMember = N.ObjectProperty | N.ObjectMethod;
@@ -212,10 +208,7 @@ export type ClassMember =
| N.ClassAccessorProperty;
export type MethodLike =
| N.ObjectMethod
| N.ClassMethod
| N.ClassPrivateMethod
| N.TSDeclareMethod;
N.ObjectMethod | N.ClassMethod | N.ClassPrivateMethod | N.TSDeclareMethod;
export type AnyImport = N.ImportDeclaration | N.TSImportEqualsDeclaration;
export type AnyExport =
@@ -73,8 +73,7 @@ class ExpressionScope {
}
type ArrowHeadParsingParameterInitializerError =
| typeof Errors.AwaitExpressionFormalParameter
| typeof Errors.YieldInParameter;
typeof Errors.AwaitExpressionFormalParameter | typeof Errors.YieldInParameter;
type ArrowHeadParsingDeclarationError =
| ArrowHeadParsingParameterInitializerError
| typeof Errors.InvalidParenthesizedAssignment
@@ -271,11 +271,7 @@ export function* traversePattern(
export function hasPrivateKeys(
pattern:
| t.LVal
| t.PatternLike
| t.OptionalMemberExpression
| null
| undefined,
t.LVal | t.PatternLike | t.OptionalMemberExpression | null | undefined,
) {
let result = false;
traversePattern(pattern, function* (node) {
@@ -38,7 +38,7 @@ function takeVoidPatternComments(node: t.VoidPattern, parent: t.ArrayPattern) {
}
function syncScopeForReplacedVoidPattern(path: NodePath<t.Identifier>) {
for (let childPath: NodePath = path; childPath.parentPath != null; ) {
for (let childPath: NodePath = path; childPath.parentPath != null;) {
const parentPath: NodePath = childPath.parentPath;
switch (parentPath.type) {
case "VariableDeclaration": {
@@ -147,9 +147,7 @@ export function removeTrailingVoidPatternsFromParams(
export function isAnonymousFunctionDefinition(
node: t.Node | null,
): node is
| t.ClassExpression
| t.ArrowFunctionExpression
| t.FunctionExpression {
t.ClassExpression | t.ArrowFunctionExpression | t.FunctionExpression {
return (
t.isArrowFunctionExpression(node) ||
((t.isFunctionExpression(node) || t.isClassExpression(node)) && !node.id)
@@ -144,9 +144,8 @@ export default declare(({ types: t, template, traverse, assertVersion }) => {
const pendingStaticBlocks: t.StaticBlock[] = [];
let lastStaticProp:
| null
| NodePath<t.ClassProperty>
| NodePath<t.ClassPrivateProperty> = null;
null | NodePath<t.ClassProperty> | NodePath<t.ClassPrivateProperty> =
null;
for (const path of classBody.get("body")) {
if (path.isStaticBlock()) {
@@ -284,8 +284,7 @@ export default function transformClass(
];
if (bareSuperNode.arguments?.length) {
const bareSuperNodeArguments = bareSuperNode.arguments as (
| t.Expression
| t.SpreadElement
t.Expression | t.SpreadElement
)[];
/**
@@ -79,9 +79,7 @@ const arrayUnpackVisitor = (
};
export type DestructuringTransformerNode =
| t.VariableDeclaration
| t.ExpressionStatement
| t.ReturnStatement;
t.VariableDeclaration | t.ExpressionStatement | t.ReturnStatement;
// using/await using declaration must not contain pattern as its id.
export type VariableDeclarationKindAllowsPattern = Exclude<
@@ -12,9 +12,7 @@ const enum USING_KIND {
function isAnonymousFunctionDefinition(
node: t.Node,
): node is
| t.ClassExpression
| t.ArrowFunctionExpression
| t.FunctionExpression {
t.ClassExpression | t.ArrowFunctionExpression | t.FunctionExpression {
return (
t.isArrowFunctionExpression(node) ||
((t.isFunctionExpression(node) || t.isClassExpression(node)) && !node.id)
@@ -121,8 +121,7 @@ export function transformOptionalChain(
for (let i = optionals.length - 1; i >= 0; i--) {
const node = optionals[i] as unknown as
| t.MemberExpression
| t.CallExpression;
t.MemberExpression | t.CallExpression;
const isCall = t.isCallExpression(node);
@@ -136,21 +136,19 @@ const memberExpressionOptimisationVisitor: Visitor<State> = {
!state.deopted &&
!(
// ex: `args[0] = "whatever"`
(
(grandparentPath.isAssignmentExpression() &&
parentPath.node === grandparentPath.node.left) || // ex: `[args[0]] = ["whatever"]`
grandparentPath.isLVal() || // ex: `for (rest[0] in this)`
// ex: `for (rest[0] of this)`
grandparentPath.isForXStatement() || // ex: `++args[0]`
// ex: `args[0]--`
grandparentPath.isUpdateExpression() || // ex: `delete args[0]`
grandparentPath.isUnaryExpression({ operator: "delete" }) || // ex: `args[0]()`
// ex: `new args[0]()`
// ex: `new args[0]`
((grandparentPath.isCallExpression() ||
grandparentPath.isNewExpression()) &&
parentPath.node === grandparentPath.node.callee)
)
(grandparentPath.isAssignmentExpression() &&
parentPath.node === grandparentPath.node.left) || // ex: `[args[0]] = ["whatever"]`
grandparentPath.isLVal() || // ex: `for (rest[0] in this)`
// ex: `for (rest[0] of this)`
grandparentPath.isForXStatement() || // ex: `++args[0]`
// ex: `args[0]--`
grandparentPath.isUpdateExpression() || // ex: `delete args[0]`
grandparentPath.isUnaryExpression({ operator: "delete" }) || // ex: `args[0]()`
// ex: `new args[0]()`
// ex: `new args[0]`
((grandparentPath.isCallExpression() ||
grandparentPath.isNewExpression()) &&
parentPath.node === grandparentPath.node.callee)
);
if (argsOptEligible) {
if (parentPath.node.computed) {
@@ -135,8 +135,7 @@ export default declare((api, opt: Options) => {
const { name } = node.left.id;
let privateElement:
| NodePath<t.ClassPrivateMethod | t.ClassPrivateProperty>
| undefined;
NodePath<t.ClassPrivateMethod | t.ClassPrivateProperty> | undefined;
const outerClass = path.findParent(path => {
if (!path.isClass()) return false;
@@ -224,7 +224,7 @@ export default declare((api, options: Options) => {
const { targetScope } = visitorState;
// Only hoist if it would give us an advantage.
for (let currentScope = jsxScope; ; ) {
for (let currentScope = jsxScope; ;) {
if (targetScope === currentScope) return;
if (isHoistingScope(currentScope)) break;
@@ -1307,8 +1307,7 @@ export class Emitter {
t.updateExpression(
path.node.operator,
self.explodeExpression(path.get("argument")) as
| t.Identifier
| t.MemberExpression,
t.Identifier | t.MemberExpression,
path.node.prefix,
),
);
@@ -474,8 +474,7 @@ function standardizeSuperProperty(
const assignmentPath = superProp.parentPath;
const op = assignmentPath.node.operator.slice(0, -1) as
| LogicalOp
| BinaryOp;
LogicalOp | BinaryOp;
const value = assignmentPath.node.right;
+1 -5
View File
@@ -377,11 +377,7 @@ interface NodePathOverwrites {
this: NodePath_Final,
): asserts this is NodePath_Final<
(
| t.Loop
| t.WithStatement
| t.Function
| t.LabeledStatement
| t.CatchClause
t.Loop | t.WithStatement | t.Function | t.LabeledStatement | t.CatchClause
) & { body: t.BlockStatement }
>;
/**
@@ -3,9 +3,7 @@ import type * as t from "@babel/types";
export interface VirtualTypeAliases {
BindingIdentifier: t.Identifier;
BlockScoped:
| t.FunctionDeclaration
| t.ClassDeclaration
| t.VariableDeclaration;
t.FunctionDeclaration | t.ClassDeclaration | t.VariableDeclaration;
ExistentialTypeParam: t.ExistsTypeAnnotation;
Expression: t.Expression;
Flow: t.Flow | t.ImportDeclaration | t.ExportDeclaration | t.ImportSpecifier;
+1 -2
View File
@@ -1244,8 +1244,7 @@ class Scope {
hasBinding(
name: string,
opts?:
| boolean
| { noGlobals?: boolean; noUids?: boolean; upToScope?: Scope },
boolean | { noGlobals?: boolean; noUids?: boolean; upToScope?: Scope },
) {
if (!name) return false;
// TODO: Only accept the object form.
+1 -1
View File
@@ -19,7 +19,7 @@ function _visitPaths(
let stop = false;
let visitIndex = 0;
for (; visitIndex < paths.length; ) {
for (; visitIndex < paths.length;) {
const path = paths[visitIndex];
visitIndex++;
+1 -2
View File
@@ -64,8 +64,7 @@ export interface VisitorBase<S>
export type Visitor<S = unknown> = VisitorBase<S> | ExplodedVisitor<S>;
export type VisitNode<S, P extends t.Node> =
| VisitNodeFunction<S, P>
| VisitNodeObject<S, P>;
VisitNodeFunction<S, P> | VisitNodeObject<S, P>;
export type VisitNodeFunction<S, P extends t.Node> = (
this: S,
@@ -405,9 +405,7 @@ export interface CallExpression extends BaseNode {
callee: Expression | Super | Import | V8IntrinsicIdentifier;
arguments: (Expression | SpreadElement | ArgumentPlaceholder)[];
typeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
}
export interface CatchClause extends BaseNode {
@@ -586,17 +584,14 @@ export interface MemberExpressionNonComputed extends BaseNode {
property: Identifier | PrivateName;
}
export type MemberExpression =
| MemberExpressionComputed
| MemberExpressionNonComputed;
MemberExpressionComputed | MemberExpressionNonComputed;
export interface NewExpression extends BaseNode {
type: "NewExpression";
callee: Expression;
arguments: (Expression | SpreadElement | ArgumentPlaceholder)[];
typeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
}
export interface Program extends BaseNode {
@@ -655,11 +650,7 @@ export interface ObjectPropertyNonComputed extends BaseNode {
decorators?: Decorator[] | null;
computed: false;
key:
| Identifier
| StringLiteral
| NumericLiteral
| BigIntLiteral
| PrivateName;
Identifier | StringLiteral | NumericLiteral | BigIntLiteral | PrivateName;
}
export type ObjectProperty = ObjectPropertyComputed | ObjectPropertyNonComputed;
@@ -841,9 +832,7 @@ export interface ClassExpression extends BaseNode {
implements?: (TSClassImplements | ClassImplements)[] | null;
mixins?: InterfaceExtends | null;
superTypeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | null;
}
@@ -858,9 +847,7 @@ export interface ClassDeclaration extends BaseNode {
implements?: (TSClassImplements | ClassImplements)[] | null;
mixins?: InterfaceExtends | null;
superTypeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
typeParameters?: TypeParameterDeclaration | TSTypeParameterDeclaration | null;
}
@@ -901,9 +888,7 @@ export interface ExportNamedDeclaration extends BaseNode {
| TypeAlias
| null;
specifiers: (
| ExportSpecifier
| ExportDefaultSpecifier
| ExportNamespaceSpecifier
ExportSpecifier | ExportDefaultSpecifier | ExportNamespaceSpecifier
)[];
source?: StringLiteral | null;
attributes?: ImportAttribute[] | null;
@@ -937,9 +922,7 @@ export interface ForOfStatement extends BaseNode {
export interface ImportDeclaration extends BaseNode {
type: "ImportDeclaration";
specifiers: (
| ImportSpecifier
| ImportDefaultSpecifier
| ImportNamespaceSpecifier
ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier
)[];
source: StringLiteral;
attributes?: ImportAttribute[] | null;
@@ -1041,9 +1024,7 @@ export interface TaggedTemplateExpression extends BaseNode {
tag: Expression;
quasi: TemplateLiteral;
typeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
}
export interface TemplateElement extends BaseNode {
@@ -1105,8 +1086,7 @@ export interface OptionalMemberExpressionNonComputed extends BaseNode {
property: Identifier | PrivateName;
}
export type OptionalMemberExpression =
| OptionalMemberExpressionComputed
| OptionalMemberExpressionNonComputed;
OptionalMemberExpressionComputed | OptionalMemberExpressionNonComputed;
export interface OptionalCallExpression extends BaseNode {
type: "OptionalCallExpression";
@@ -1114,9 +1094,7 @@ export interface OptionalCallExpression extends BaseNode {
arguments: (Expression | SpreadElement | ArgumentPlaceholder)[];
optional: boolean;
typeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
}
export interface ClassPropertyComputed extends BaseNode {
@@ -1606,11 +1584,7 @@ export interface JSXAttribute extends BaseNode {
type: "JSXAttribute";
name: JSXIdentifier | JSXNamespacedName;
value?:
| JSXElement
| JSXFragment
| StringLiteral
| JSXExpressionContainer
| null;
JSXElement | JSXFragment | StringLiteral | JSXExpressionContainer | null;
}
export interface JSXClosingElement extends BaseNode {
@@ -1623,11 +1597,7 @@ export interface JSXElement extends BaseNode {
openingElement: JSXOpeningElement;
closingElement?: JSXClosingElement | null;
children: (
| JSXText
| JSXExpressionContainer
| JSXSpreadChild
| JSXElement
| JSXFragment
JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment
)[];
}
@@ -1668,9 +1638,7 @@ export interface JSXOpeningElement extends BaseNode {
attributes: (JSXAttribute | JSXSpreadAttribute)[];
selfClosing: boolean;
typeArguments?:
| TypeParameterInstantiation
| TSTypeParameterInstantiation
| null;
TypeParameterInstantiation | TSTypeParameterInstantiation | null;
}
export interface JSXSpreadAttribute extends BaseNode {
@@ -1688,11 +1656,7 @@ export interface JSXFragment extends BaseNode {
openingFragment: JSXOpeningFragment;
closingFragment: JSXClosingFragment;
children: (
| JSXText
| JSXExpressionContainer
| JSXSpreadChild
| JSXElement
| JSXFragment
JSXText | JSXExpressionContainer | JSXSpreadChild | JSXElement | JSXFragment
)[];
}
@@ -1769,15 +1733,10 @@ export interface ClassAccessorPropertyNonComputed extends BaseNode {
variance?: Variance | null;
computed: false;
key:
| Identifier
| StringLiteral
| NumericLiteral
| BigIntLiteral
| PrivateName;
Identifier | StringLiteral | NumericLiteral | BigIntLiteral | PrivateName;
}
export type ClassAccessorProperty =
| ClassAccessorPropertyComputed
| ClassAccessorPropertyNonComputed;
ClassAccessorPropertyComputed | ClassAccessorPropertyNonComputed;
export interface Decorator extends BaseNode {
type: "Decorator";
@@ -1863,8 +1822,7 @@ export interface TSDeclareMethodNonComputed extends BaseNode {
key: Identifier | StringLiteral | NumericLiteral | BigIntLiteral;
}
export type TSDeclareMethod =
| TSDeclareMethodComputed
| TSDeclareMethodNonComputed;
TSDeclareMethodComputed | TSDeclareMethodNonComputed;
export interface TSQualifiedName extends BaseNode {
type: "TSQualifiedName";
@@ -2484,10 +2442,7 @@ export type Terminatorless =
| YieldExpression
| AwaitExpression;
export type CompletionStatement =
| BreakStatement
| ContinueStatement
| ReturnStatement
| ThrowStatement;
BreakStatement | ContinueStatement | ReturnStatement | ThrowStatement;
export type Conditional = ConditionalExpression | IfStatement;
export type Loop =
| DoWhileStatement
@@ -2497,9 +2452,7 @@ export type Loop =
| ForOfStatement;
export type While = DoWhileStatement | WhileStatement;
export type ExpressionWrapper =
| ExpressionStatement
| ParenthesizedExpression
| TypeCastExpression;
ExpressionStatement | ParenthesizedExpression | TypeCastExpression;
export type For = ForInStatement | ForStatement | ForOfStatement;
export type ForXStatement = ForInStatement | ForOfStatement;
export type Function =
@@ -2620,16 +2573,10 @@ export type UserWhitespacable =
export type Method = ObjectMethod | ClassMethod | ClassPrivateMethod;
export type ObjectMember = ObjectMethod | ObjectProperty;
export type Property =
| ObjectProperty
| ClassProperty
| ClassPrivateProperty
| ClassAccessorProperty;
ObjectProperty | ClassProperty | ClassPrivateProperty | ClassAccessorProperty;
export type UnaryLike = UnaryExpression | SpreadElement;
export type Pattern =
| AssignmentPattern
| ArrayPattern
| ObjectPattern
| VoidPattern;
AssignmentPattern | ArrayPattern | ObjectPattern | VoidPattern;
export type Class = ClassExpression | ClassDeclaration;
export type ImportOrExportDeclaration =
| ExportAllDeclaration
@@ -2637,9 +2584,7 @@ export type ImportOrExportDeclaration =
| ExportNamedDeclaration
| ImportDeclaration;
export type ExportDeclaration =
| ExportAllDeclaration
| ExportDefaultDeclaration
| ExportNamedDeclaration;
ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration;
export type ModuleSpecifier =
| ExportSpecifier
| ImportDefaultSpecifier
@@ -2770,15 +2715,9 @@ export type FlowDeclaration =
| TypeAlias;
export type FlowPredicate = DeclaredPredicate | InferredPredicate;
export type EnumBody =
| EnumBooleanBody
| EnumNumberBody
| EnumStringBody
| EnumSymbolBody;
EnumBooleanBody | EnumNumberBody | EnumStringBody | EnumSymbolBody;
export type EnumMember =
| EnumBooleanMember
| EnumNumberMember
| EnumStringMember
| EnumDefaultedMember;
EnumBooleanMember | EnumNumberMember | EnumStringMember | EnumDefaultedMember;
export type JSX =
| JSXAttribute
| JSXClosingElement
@@ -2988,10 +2927,7 @@ export interface Aliases {
}
export type DeprecatedAliases =
| NumberLiteral
| RegexLiteral
| RestProperty
| SpreadProperty;
NumberLiteral | RegexLiteral | RestProperty | SpreadProperty;
export interface ParentMaps {
AnyTypeAnnotation:
@@ -4252,9 +4188,7 @@ export interface ParentMaps {
| WhileStatement
| WithStatement;
EnumDefaultedMember:
| DeclareExportDeclaration
| EnumStringBody
| EnumSymbolBody;
DeclareExportDeclaration | EnumStringBody | EnumSymbolBody;
EnumNumberBody: DeclareExportDeclaration | EnumDeclaration;
EnumNumberMember: DeclareExportDeclaration | EnumNumberBody;
EnumStringBody: DeclareExportDeclaration | EnumDeclaration;
@@ -4989,9 +4923,7 @@ export interface ParentMaps {
| JSXNamespacedName
| JSXOpeningElement;
JSXMemberExpression:
| JSXClosingElement
| JSXMemberExpression
| JSXOpeningElement;
JSXClosingElement | JSXMemberExpression | JSXOpeningElement;
JSXNamespacedName: JSXAttribute | JSXClosingElement | JSXOpeningElement;
JSXOpeningElement: JSXElement;
JSXOpeningFragment: JSXFragment;
@@ -258,11 +258,7 @@ export function callExpression(
}
export function catchClause(
param:
| t.Identifier
| t.ArrayPattern
| t.ObjectPattern
| null
| undefined = null,
t.Identifier | t.ArrayPattern | t.ObjectPattern | null | undefined = null,
body: t.BlockStatement,
): t.CatchClause {
const node: t.CatchClause = {
@@ -1107,9 +1103,7 @@ export function exportNamedDeclaration(
| t.TypeAlias
| null = null,
specifiers: (
| t.ExportSpecifier
| t.ExportDefaultSpecifier
| t.ExportNamespaceSpecifier
t.ExportSpecifier | t.ExportDefaultSpecifier | t.ExportNamespaceSpecifier
)[] = [],
source: t.StringLiteral | null = null,
attributes: t.ImportAttribute[] | null = null,
@@ -1173,9 +1167,7 @@ export function forOfStatement(
}
export function importDeclaration(
specifiers: (
| t.ImportSpecifier
| t.ImportDefaultSpecifier
| t.ImportNamespaceSpecifier
t.ImportSpecifier | t.ImportDefaultSpecifier | t.ImportNamespaceSpecifier
)[],
source: t.StringLiteral,
attributes: t.ImportAttribute[] | null = null,
@@ -2321,10 +2313,7 @@ export function voidTypeAnnotation(): t.VoidTypeAnnotation {
export function enumDeclaration(
id: t.Identifier,
body:
| t.EnumBooleanBody
| t.EnumNumberBody
| t.EnumStringBody
| t.EnumSymbolBody,
t.EnumBooleanBody | t.EnumNumberBody | t.EnumStringBody | t.EnumSymbolBody,
): t.EnumDeclaration {
const node: t.EnumDeclaration = {
type: "EnumDeclaration",
@@ -7,10 +7,7 @@ import cleanJSXElementLiteralChild from "../../utils/react/cleanJSXElementLitera
import type * as t from "../../index.ts";
type ReturnedChild =
| t.JSXSpreadChild
| t.JSXElement
| t.JSXFragment
| t.Expression;
t.JSXSpreadChild | t.JSXElement | t.JSXFragment | t.Expression;
export default function buildChildren(
node: t.JSXElement | t.JSXFragment,
+5 -5
View File
@@ -7662,7 +7662,7 @@ __metadata:
open: "npm:^11.0.0"
p-limit: "npm:^7.2.0"
pkg-pr-new: "npm:^0.0.54"
prettier: "npm:^3.8.1"
prettier: "npm:^3.9.5"
publint: "npm:^0.3.17"
rollup: "npm:^4.18.0"
rollup-plugin-dts: "patch:rollup-plugin-dts@npm%3A6.1.0#~/.yarn/patches/rollup-plugin-dts-npm-6.1.0-6d41e665a7.patch"
@@ -14684,12 +14684,12 @@ __metadata:
languageName: node
linkType: hard
"prettier@npm:^3.8.1":
version: 3.8.3
resolution: "prettier@npm:3.8.3"
"prettier@npm:^3.9.5":
version: 3.9.5
resolution: "prettier@npm:3.9.5"
bin:
prettier: bin/prettier.cjs
checksum: 10/4b3b12cbb29e4c96bed936e5d070167552500c18d37676fb3e0caae6199c42860662608e4dc116230698f6e2bb0267ef2548158224c92d40f188d309d72fdd6f
checksum: 10/b6587f1582ba653ce5207ee227aff646500e5098646931088f176d1ab090b1f47d5a333f1facd634e9aa7dcb15c45940e2cec13a5962534cf0200617517b67b6
languageName: node
linkType: hard