Update to Prettier 2.3 (#13288)

This commit is contained in:
Sosuke Suzuki
2021-05-10 22:34:13 +09:00
committed by GitHub
parent 5ae3a6c2a4
commit b2d9156cc6
45 changed files with 262 additions and 364 deletions

View File

@@ -373,9 +373,8 @@ export default class StatementParser extends ExpressionParser {
}
takeDecorators(node: N.HasDecorators): void {
const decorators = this.state.decoratorStack[
this.state.decoratorStack.length - 1
];
const decorators =
this.state.decoratorStack[this.state.decoratorStack.length - 1];
if (decorators.length) {
node.decorators = decorators;
this.resetStartLocationFromNode(node, decorators[0]);
@@ -388,9 +387,8 @@ export default class StatementParser extends ExpressionParser {
}
parseDecorators(allowExport?: boolean): void {
const currentContextDecorators = this.state.decoratorStack[
this.state.decoratorStack.length - 1
];
const currentContextDecorators =
this.state.decoratorStack[this.state.decoratorStack.length - 1];
while (this.match(tt.at)) {
const decorator = this.parseDecorator();
currentContextDecorators.push(decorator);
@@ -2067,9 +2065,8 @@ export default class StatementParser extends ExpressionParser {
}
}
const currentContextDecorators = this.state.decoratorStack[
this.state.decoratorStack.length - 1
];
const currentContextDecorators =
this.state.decoratorStack[this.state.decoratorStack.length - 1];
// If node.declaration is a class, it will take all decorators in the current context.
// Thus we should throw if we see non-empty decorators here.
if (currentContextDecorators.length) {

View File

@@ -150,6 +150,5 @@ export const mixinPlugins: { [name: string]: MixinPlugin } = {
placeholders,
};
export const mixinPluginNames: $ReadOnlyArray<string> = Object.keys(
mixinPlugins,
);
export const mixinPluginNames: $ReadOnlyArray<string> =
Object.keys(mixinPlugins);

View File

@@ -1350,9 +1350,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
return this.finishNode(node, "FunctionTypeParam");
}
flowParseFunctionTypeParams(
params: N.FlowFunctionTypeParam[] = [],
): {
flowParseFunctionTypeParams(params: N.FlowFunctionTypeParam[] = []): {
params: N.FlowFunctionTypeParam[],
rest: ?N.FlowFunctionTypeParam,
_this: ?N.FlowFunctionTypeParam,
@@ -3131,7 +3129,8 @@ export default (superClass: Class<Parser>): Class<Parser> =>
node.callee = base;
const result = this.tryParse(() => {
node.typeArguments = this.flowParseTypeParameterInstantiationCallOrNew();
node.typeArguments =
this.flowParseTypeParameterInstantiationCallOrNew();
this.expect(tt.parenL);
node.arguments = this.parseCallExpressionArguments(tt.parenR, false);
if (subscriptState.optionalChainMember) node.optional = false;

View File

@@ -537,13 +537,11 @@ export default (superClass: Class<Parser>): Class<Parser> =>
this.expect(tt.parenL);
signature.parameters = this.tsParseBindingListForSignature();
if (returnTokenRequired) {
signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(
returnToken,
);
signature.typeAnnotation =
this.tsParseTypeOrTypePredicateAnnotation(returnToken);
} else if (this.match(returnToken)) {
signature.typeAnnotation = this.tsParseTypeOrTypePredicateAnnotation(
returnToken,
);
signature.typeAnnotation =
this.tsParseTypeOrTypePredicateAnnotation(returnToken);
}
}

View File

@@ -1176,9 +1176,10 @@ export type TsSignatureDeclarationOrIndexSignatureBase = NodeBase & {
typeAnnotation: ?TsTypeAnnotation,
};
export type TsSignatureDeclarationBase = TsSignatureDeclarationOrIndexSignatureBase & {
typeParameters: ?TsTypeParameterDeclaration,
};
export type TsSignatureDeclarationBase =
TsSignatureDeclarationOrIndexSignatureBase & {
typeParameters: ?TsTypeParameterDeclaration,
};
// ================
// TypeScript type members (for type literal / interface / class)