Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier 3.0 #8030

Merged
merged 5 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,17 @@
"eslint-plugin-github": "^4.8.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jsdoc": "^40.1.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-prettier": "^5.0.0-alpha.2",
"lerna": "^3.22.1",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.3",
"prettier": "^3.0.0",
"typescript": "~5.1.6"
},
"engines": {
"node": "^16.13 || ^18.12"
},
"prettier": {
"arrowParens": "avoid",
"trailingComma": "all",
"singleQuote": true
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/agoric-cli/src/commands/inter.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const makeFormatters = assets => {
* @param {(_: T) => string} f
* @returns { (x: T | null | undefined ) => string | undefined }
*/
const maybe = f => x => x ? f(x) : undefined;
const maybe = f => x => (x ? f(x) : undefined);

return {
amount,
Expand Down
20 changes: 11 additions & 9 deletions packages/agoric-cli/src/commands/psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,17 @@ export const makePsmCommand = logger => {
.option('--giveMinted <DOLLARS>', 'amount of minted tokens to give', Number)
.option('--feePct [%]', 'Gas fee percentage', Number)
.option('--offerId <string>', 'Offer id', String, `swap-${Date.now()}`)
.action(async function (
/** @type {Parameters<typeof Offers.psm.swap>[2]} */ opts,
) {
console.warn('running with options', opts);
const { agoricNames, lookupPsmInstance } = await rpcTools();
const instance = await lookupPsmInstance(opts.pair);
const offer = Offers.psm.swap(agoricNames, instance, opts);
outputExecuteOfferAction(offer);
});
.action(
async function (
/** @type {Parameters<typeof Offers.psm.swap>[2]} */ opts,
) {
console.warn('running with options', opts);
const { agoricNames, lookupPsmInstance } = await rpcTools();
const instance = await lookupPsmInstance(opts.pair);
const offer = Offers.psm.swap(agoricNames, instance, opts);
outputExecuteOfferAction(offer);
Comment on lines +158 to +162
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh... indenting the whole body of the function is mildly annoying. If I saw this while writing code, I might shift things around.

},
);

psm
.command('proposePauseOffers')
Expand Down
8 changes: 4 additions & 4 deletions packages/cosmic-proto/dist/agoric/swingset/msgs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,15 +506,15 @@ interface Rpc {
data: Uint8Array,
): Promise<Uint8Array>;
}
declare type Builtin =
type Builtin =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ugh. this code is generated by some protobuf tool. next time we run that tool (yarn generate) it's going to say declare again, IIUC. I wonder if this is a known issue upstream in the protobuf tool.

cc @kriskowal @mhofman

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was generated by yarn rebuild which runs yarn generate. I put this into a separate commit, before changing Prettier: 87a2df6

| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export declare type DeepPartial<T> = T extends Builtin
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
Expand All @@ -527,8 +527,8 @@ export declare type DeepPartial<T> = T extends Builtin
[K in keyof T]?: DeepPartial<T[K]>;
}
: Partial<T>;
declare type KeysOfUnion<T> = T extends T ? keyof T : never;
export declare type Exact<P, I extends P> = P extends Builtin
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & {
[K in keyof P]: Exact<P[K], I[K]>;
Expand Down
30 changes: 15 additions & 15 deletions packages/cosmic-proto/dist/agoric/swingset/msgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ export const MsgDeliverInbound = {
fromJSON(object) {
return {
messages: Array.isArray(object?.messages)
? object.messages.map((e) => String(e))
? object.messages.map(e => String(e))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again, this is generated code. Any clues on why our lint tools didn't complain about it when it was originally merged?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the generated code after being prettiered (yarn rebuild runs prettier). The change in b46c46 is to use the same Prettier config for this package as for agoric-sdk, i.e. "arrowParens": "avoid"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, are you saying the codegen steps already re-format generated code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

"rebuild": "rm -rf gen && mkdir -p gen && yarn generate && tsc --build && yarn prettier -w dist/agoric && rm -rf gen",

: [],
nums: Array.isArray(object?.nums)
? object.nums.map((e) => Long.fromValue(e))
? object.nums.map(e => Long.fromValue(e))
: [],
ack: isSet(object.ack) ? Long.fromValue(object.ack) : Long.UZERO,
submitter: isSet(object.submitter)
Expand All @@ -78,12 +78,12 @@ export const MsgDeliverInbound = {
toJSON(message) {
const obj = {};
if (message.messages) {
obj.messages = message.messages.map((e) => e);
obj.messages = message.messages.map(e => e);
} else {
obj.messages = [];
}
if (message.nums) {
obj.nums = message.nums.map((e) => (e || Long.UZERO).toString());
obj.nums = message.nums.map(e => (e || Long.UZERO).toString());
} else {
obj.nums = [];
}
Expand All @@ -97,8 +97,8 @@ export const MsgDeliverInbound = {
},
fromPartial(object) {
const message = createBaseMsgDeliverInbound();
message.messages = object.messages?.map((e) => e) || [];
message.nums = object.nums?.map((e) => Long.fromValue(e)) || [];
message.messages = object.messages?.map(e => e) || [];
message.nums = object.nums?.map(e => Long.fromValue(e)) || [];
message.ack =
object.ack !== undefined && object.ack !== null
? Long.fromValue(object.ack)
Expand Down Expand Up @@ -378,7 +378,7 @@ export const MsgProvision = {
? bytesFromBase64(object.address)
: new Uint8Array(),
powerFlags: Array.isArray(object?.powerFlags)
? object.powerFlags.map((e) => String(e))
? object.powerFlags.map(e => String(e))
: [],
submitter: isSet(object.submitter)
? bytesFromBase64(object.submitter)
Expand All @@ -393,7 +393,7 @@ export const MsgProvision = {
message.address !== undefined ? message.address : new Uint8Array(),
));
if (message.powerFlags) {
obj.powerFlags = message.powerFlags.map((e) => e);
obj.powerFlags = message.powerFlags.map(e => e);
} else {
obj.powerFlags = [];
}
Expand All @@ -407,7 +407,7 @@ export const MsgProvision = {
const message = createBaseMsgProvision();
message.nickname = object.nickname ?? '';
message.address = object.address ?? new Uint8Array();
message.powerFlags = object.powerFlags?.map((e) => e) || [];
message.powerFlags = object.powerFlags?.map(e => e) || [];
message.submitter = object.submitter ?? new Uint8Array();
return message;
},
Expand Down Expand Up @@ -588,35 +588,35 @@ export class MsgClientImpl {
InstallBundle(request) {
const data = MsgInstallBundle.encode(request).finish();
const promise = this.rpc.request(this.service, 'InstallBundle', data);
return promise.then((data) =>
return promise.then(data =>
MsgInstallBundleResponse.decode(new _m0.Reader(data)),
);
}
DeliverInbound(request) {
const data = MsgDeliverInbound.encode(request).finish();
const promise = this.rpc.request(this.service, 'DeliverInbound', data);
return promise.then((data) =>
return promise.then(data =>
MsgDeliverInboundResponse.decode(new _m0.Reader(data)),
);
}
WalletAction(request) {
const data = MsgWalletAction.encode(request).finish();
const promise = this.rpc.request(this.service, 'WalletAction', data);
return promise.then((data) =>
return promise.then(data =>
MsgWalletActionResponse.decode(new _m0.Reader(data)),
);
}
WalletSpendAction(request) {
const data = MsgWalletSpendAction.encode(request).finish();
const promise = this.rpc.request(this.service, 'WalletSpendAction', data);
return promise.then((data) =>
return promise.then(data =>
MsgWalletSpendActionResponse.decode(new _m0.Reader(data)),
);
}
Provision(request) {
const data = MsgProvision.encode(request).finish();
const promise = this.rpc.request(this.service, 'Provision', data);
return promise.then((data) =>
return promise.then(data =>
MsgProvisionResponse.decode(new _m0.Reader(data)),
);
}
Expand Down Expand Up @@ -653,7 +653,7 @@ function base64FromBytes(arr) {
return globalThis.Buffer.from(arr).toString('base64');
} else {
const bin = [];
arr.forEach((byte) => {
arr.forEach(byte => {
bin.push(String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(''));
Expand Down
8 changes: 4 additions & 4 deletions packages/cosmic-proto/dist/agoric/swingset/query.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,15 @@ interface Rpc {
data: Uint8Array,
): Promise<Uint8Array>;
}
declare type Builtin =
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export declare type DeepPartial<T> = T extends Builtin
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
Expand All @@ -395,8 +395,8 @@ export declare type DeepPartial<T> = T extends Builtin
[K in keyof T]?: DeepPartial<T[K]>;
}
: Partial<T>;
declare type KeysOfUnion<T> = T extends T ? keyof T : never;
export declare type Exact<P, I extends P> = P extends Builtin
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & {
[K in keyof P]: Exact<P[K], I[K]>;
Expand Down
8 changes: 4 additions & 4 deletions packages/cosmic-proto/dist/agoric/swingset/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,21 +280,21 @@ export class QueryClientImpl {
Params(request) {
const data = QueryParamsRequest.encode(request).finish();
const promise = this.rpc.request(this.service, 'Params', data);
return promise.then((data) =>
return promise.then(data =>
QueryParamsResponse.decode(new _m0.Reader(data)),
);
}
Egress(request) {
const data = QueryEgressRequest.encode(request).finish();
const promise = this.rpc.request(this.service, 'Egress', data);
return promise.then((data) =>
return promise.then(data =>
QueryEgressResponse.decode(new _m0.Reader(data)),
);
}
Mailbox(request) {
const data = QueryMailboxRequest.encode(request).finish();
const promise = this.rpc.request(this.service, 'Mailbox', data);
return promise.then((data) =>
return promise.then(data =>
QueryMailboxResponse.decode(new _m0.Reader(data)),
);
}
Expand Down Expand Up @@ -331,7 +331,7 @@ function base64FromBytes(arr) {
return globalThis.Buffer.from(arr).toString('base64');
} else {
const bin = [];
arr.forEach((byte) => {
arr.forEach(byte => {
bin.push(String.fromCharCode(byte));
});
return globalThis.btoa(bin.join(''));
Expand Down
8 changes: 4 additions & 4 deletions packages/cosmic-proto/dist/agoric/swingset/swingset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,15 +539,15 @@ export declare const ExtensionSnapshotterArtifactPayload: {
object: I,
): ExtensionSnapshotterArtifactPayload;
};
declare type Builtin =
type Builtin =
| Date
| Function
| Uint8Array
| string
| number
| boolean
| undefined;
export declare type DeepPartial<T> = T extends Builtin
export type DeepPartial<T> = T extends Builtin
? T
: T extends Long
? string | number | Long
Expand All @@ -560,8 +560,8 @@ export declare type DeepPartial<T> = T extends Builtin
[K in keyof T]?: DeepPartial<T[K]>;
}
: Partial<T>;
declare type KeysOfUnion<T> = T extends T ? keyof T : never;
export declare type Exact<P, I extends P> = P extends Builtin
type KeysOfUnion<T> = T extends T ? keyof T : never;
export type Exact<P, I extends P> = P extends Builtin
? P
: P & {
[K in keyof P]: Exact<P[K], I[K]>;
Expand Down
Loading