Skip to content

Commit

Permalink
Bump prettier from 2.8.8 to 3.0.0 (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
dependabot[bot] authored Aug 1, 2023
1 parent 211c651 commit 19e7883
Show file tree
Hide file tree
Showing 161 changed files with 1,148 additions and 1,143 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ lint: node_modules $(BUILD)/connect-web $(GEN)/connect-web-bench ## Lint all fil

.PHONY: format
format: node_modules $(BIN)/license-header ## Format all files, adding license headers
npx prettier --write '**/*.{json,js,jsx,ts,tsx,css}' --loglevel error
npx prettier --write '**/*.{json,js,jsx,ts,tsx,css}' --log-level error
comm -23 \
<(git ls-files --cached --modified --others --no-empty-directory --exclude-standard | sort -u | grep -v $(LICENSE_IGNORE) ) \
<(git ls-files --deleted | sort -u) | \
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-node": "^11.1.0",
"prettier": "^2.8.8",
"prettier": "^3.0.0",
"typescript": "5.0.3"
}
}
6 changes: 3 additions & 3 deletions packages/connect-express/src/express-connect-middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ interface ExpressConnectMiddlewareOptions extends ConnectRouterOptions {
* Adds your Connect RPCs to an Express server.
*/
export function expressConnectMiddleware(
options: ExpressConnectMiddlewareOptions
options: ExpressConnectMiddlewareOptions,
): express.Handler {
if (options.acceptCompression === undefined) {
options.acceptCompression = [compressionGzip, compressionBrotli];
Expand All @@ -69,7 +69,7 @@ export function expressConnectMiddleware(
return function handler(
req: express.Request,
res: express.Response,
next: express.NextFunction
next: express.NextFunction,
) {
// Strip the query parameter when matching paths.
const uHandler = paths.get(req.url.split("?", 2)[0]);
Expand All @@ -86,7 +86,7 @@ export function expressConnectMiddleware(
// eslint-disable-next-line no-console
console.error(
`handler for rpc ${uHandler.method.name} of ${uHandler.service.typeName} failed`,
reason
reason,
);
});
};
Expand Down
20 changes: 10 additions & 10 deletions packages/connect-fastify/src/fastify-connect-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interface FastifyConnectPluginOptions extends ConnectRouterOptions {
export function fastifyConnectPlugin(
instance: FastifyInstance,
opts: FastifyConnectPluginOptions,
done: (err?: Error) => void
done: (err?: Error) => void,
) {
if (opts.routes === undefined) {
done();
Expand Down Expand Up @@ -82,8 +82,8 @@ export function fastifyConnectPlugin(
const uRes = await uHandler(
universalRequestFromNodeRequest(
req.raw,
req.body as JsonValue | undefined
)
req.body as JsonValue | undefined,
),
);
// Fastify maintains response headers on the reply object and only moves them to
// the raw response during reply.send, but we are not using reply.send with this plugin.
Expand All @@ -101,10 +101,10 @@ export function fastifyConnectPlugin(
// eslint-disable-next-line no-console
console.error(
`handler for rpc ${uHandler.method.name} of ${uHandler.service.typeName} failed`,
e
e,
);
}
}
},
);
}

Expand All @@ -125,26 +125,26 @@ function addNoopContentTypeParsers(instance: FastifyInstance): void {
protoGrpc.contentTypeProto,
protoGrpc.contentTypeJson,
],
noopContentTypeParser
noopContentTypeParser,
);
instance.addContentTypeParser(
protoGrpc.contentTypeRegExp,
noopContentTypeParser
noopContentTypeParser,
);
instance.addContentTypeParser(
protoGrpcWeb.contentTypeRegExp,
noopContentTypeParser
noopContentTypeParser,
);
instance.addContentTypeParser(
protoConnect.contentTypeRegExp,
noopContentTypeParser
noopContentTypeParser,
);
}

function noopContentTypeParser(
_req: unknown,
_payload: unknown,
done: (err: null, body?: undefined) => void
done: (err: null, body?: undefined) => void,
) {
done(null, undefined);
}
6 changes: 3 additions & 3 deletions packages/connect-next/src/connect-nextjs-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { JsonValue } from "@bufbuild/protobuf";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type NextApiHandler<T = any> = (
req: NextApiRequest,
res: NextApiResponse<T>
res: NextApiResponse<T>,
) => unknown | Promise<unknown>;

interface NextJsApiRouterOptions extends ConnectRouterOptions {
Expand Down Expand Up @@ -83,14 +83,14 @@ export function nextJsApiRouter(options: NextJsApiRouterOptions): ApiRoute {
}
try {
const uRes = await uHandler(
universalRequestFromNodeRequest(req, req.body as JsonValue | undefined)
universalRequestFromNodeRequest(req, req.body as JsonValue | undefined),
);
await universalResponseToNodeResponse(uRes, res);
} catch (e) {
// eslint-disable-next-line no-console
console.error(
`handler for rpc ${uHandler.method.name} of ${uHandler.service.typeName} failed`,
e
e,
);
}
}
Expand Down
28 changes: 14 additions & 14 deletions packages/connect-node-test/src/badweather/broken-input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("broken input", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.unaryCall
TestService.methods.unaryCall,
),
method: "POST",
ctype: "application/json",
Expand All @@ -54,19 +54,19 @@ describe("broken input", () => {
undefined,
new ConnectError(
`HTTP ${res.status}`,
codeFromHttpStatus(res.status)
)
codeFromHttpStatus(res.status),
),
),
};
});
const { status, error } = await unaryRequest(
new TextEncoder().encode("this is not json")
new TextEncoder().encode("this is not json"),
);
expect(status).toBe(400);
expect(error.code).toBe(Code.InvalidArgument);
if (serverName == "@bufbuild/connect-node (h2c)") {
expect(error.rawMessage).toMatch(
/^cannot decode grpc.testing.SimpleRequest from JSON: Unexpected token '?h'?.*JSON/
/^cannot decode grpc.testing.SimpleRequest from JSON: Unexpected token '?h'?.*JSON/,
);
}
});
Expand Down Expand Up @@ -97,7 +97,7 @@ describe("broken input", () => {
const v = new DataView(
body.buffer,
body.byteOffset,
body.byteLength
body.byteLength,
);
v.setUint8(0, 0b00000000); // first byte is flags
v.setUint32(1, json.byteLength); // 4 bytes message length
Expand All @@ -108,7 +108,7 @@ describe("broken input", () => {
// Error messages tend to change across Node versions. Should this happen again, this link is useful to
// build the correct RegExp: https://regex101.com/r/By9VEN/1
expect(endStream.error?.rawMessage).toMatch(
/^cannot decode grpc.testing.Streaming(Input|Output)CallRequest from JSON: Unexpected token '?h'?.*JSON/
/^cannot decode grpc.testing.Streaming(Input|Output)CallRequest from JSON: Unexpected token '?h'?.*JSON/,
);
}
});
Expand All @@ -117,51 +117,51 @@ describe("broken input", () => {
const v = new DataView(
body.buffer,
body.byteOffset,
body.byteLength
body.byteLength,
);
v.setUint8(0, 0b00000000); // first byte is flags
v.setUint32(1, 1024); // 4 bytes message length
const { status, endStream } = await streamingRequest(body);
expect(status).toBe(200);
expect(endStream.error?.code).toBe(Code.InvalidArgument);
expect(endStream.error?.rawMessage).toBe(
"protocol error: promised 1024 bytes in enveloped message, got 0 bytes"
"protocol error: promised 1024 bytes in enveloped message, got 0 bytes",
);
});
it("should raise HTTP 400 for short message", async () => {
const body = new Uint8Array(6);
const v = new DataView(
body.buffer,
body.byteOffset,
body.byteLength
body.byteLength,
);
v.setUint8(0, 0b00000000); // first byte is flags
v.setUint32(1, 1024); // 4 bytes message length
const { status, endStream } = await streamingRequest(body);
expect(status).toBe(200);
expect(endStream.error?.code).toBe(Code.InvalidArgument);
expect(endStream.error?.rawMessage).toMatch(
"^protocol error: promised 1024 bytes in enveloped message, got (1|less) bytes"
"^protocol error: promised 1024 bytes in enveloped message, got (1|less) bytes",
);
});
it("should raise HTTP 400 for short envelope", async () => {
const body = new Uint8Array(1);
const v = new DataView(
body.buffer,
body.byteOffset,
body.byteLength
body.byteLength,
);
v.setUint8(0, 0b00000000); // first byte is flags
const { status, endStream } = await streamingRequest(body);
expect(status).toBe(200);
expect(endStream.error?.code).toBe(Code.InvalidArgument);
expect(endStream.error?.rawMessage).toMatch(
"^protocol error: incomplete envelope"
"^protocol error: incomplete envelope",
);
});
});
}
}
},
);

afterAll(async () => await servers.stop());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("unsupported content encoding", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.unaryCall
TestService.methods.unaryCall,
),
method: "POST",
headers: {
Expand All @@ -54,12 +54,12 @@ describe("unsupported content encoding", () => {
undefined,
new ConnectError(
`HTTP ${res.status}`,
codeFromHttpStatus(res.status)
)
codeFromHttpStatus(res.status),
),
);
expect(err.code).toBe(Code.Unimplemented);
expect(err.rawMessage).toMatch(
/^unknown compression "banana": supported encodings are gzip(,[a-z]+)*$/
/^unknown compression "banana": supported encodings are gzip(,[a-z]+)*$/,
);
});
});
Expand All @@ -69,7 +69,7 @@ describe("unsupported content encoding", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.streamingInputCall
TestService.methods.streamingInputCall,
),
method: "POST",
headers: {
Expand All @@ -82,11 +82,11 @@ describe("unsupported content encoding", () => {
const endStream = endStreamFromJson(res.body.subarray(5));
expect(endStream.error?.code).toBe(Code.Unimplemented);
expect(endStream.error?.rawMessage).toMatch(
/^unknown compression "banana": supported encodings are gzip(,[a-z]+)*$/
/^unknown compression "banana": supported encodings are gzip(,[a-z]+)*$/,
);
});
});
}
},
);

afterAll(async () => await servers.stop());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("unsupported media type", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.unaryCall
TestService.methods.unaryCall,
),
method: "POST",
ctype: "text/csv",
Expand All @@ -46,7 +46,7 @@ describe("unsupported media type", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.unaryCall
TestService.methods.unaryCall,
),
method: "POST",
ctype: "application/connect+proto",
Expand All @@ -62,7 +62,7 @@ describe("unsupported media type", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.streamingInputCall
TestService.methods.streamingInputCall,
),
method: "POST",
ctype: "text/csv",
Expand All @@ -76,7 +76,7 @@ describe("unsupported media type", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.streamingInputCall
TestService.methods.streamingInputCall,
),
method: "POST",
ctype: "application/proto",
Expand All @@ -86,7 +86,7 @@ describe("unsupported media type", () => {
expect(res.body.byteLength).toBe(0);
});
});
}
},
);

afterAll(async () => await servers.stop());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("unsupported method", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.unaryCall
TestService.methods.unaryCall,
),
method: "GET",
ctype: "application/json",
Expand All @@ -46,7 +46,7 @@ describe("unsupported method", () => {
url: createMethodUrl(
server.getUrl(),
TestService,
TestService.methods.unaryCall
TestService.methods.unaryCall,
),
method: "PUT",
ctype: "application/json",
Expand All @@ -56,7 +56,7 @@ describe("unsupported method", () => {
expect(res.body.byteLength).toBe(0);
});
});
}
},
);

afterAll(async () => await servers.stop());
Expand Down
Loading

0 comments on commit 19e7883

Please sign in to comment.