Skip to content

Commit 9624783

Browse files
authored
eslint ignores (#216)
1 parent 0dc1a4b commit 9624783

File tree

19 files changed

+50
-29
lines changed

19 files changed

+50
-29
lines changed

.eslintrc.cjs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
// eslint-disable-next-line no-undef
22
module.exports = {
33
root: true,
4-
ignorePatterns: ["dist"],
4+
ignorePatterns: ["dist", "examples/nextjs"],
5+
parserOptions: {
6+
ecmaVersion: "latest",
7+
sourceType: "module",
8+
},
9+
env: {
10+
browser: true,
11+
node: true,
12+
},
513
plugins: ["@typescript-eslint"],
6-
extends: [
7-
"eslint:recommended",
8-
"plugin:@typescript-eslint/recommended",
9-
"prettier",
10-
],
14+
extends: ["eslint:recommended", "prettier"],
1115
overrides: [
1216
{
1317
files: ["*.ts"],
@@ -18,6 +22,7 @@ module.exports = {
1822
project: ["./tsconfig.json"],
1923
},
2024
extends: [
25+
"plugin:@typescript-eslint/recommended",
2126
"plugin:@typescript-eslint/recommended-requiring-type-checking",
2227
],
2328
rules: {

e2e/protos/__snapshots__/test.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ Groups are not supported. Found group optionalgroup
2525

2626
exports[`TwirpScript Compiler generates JavaScript 2`] = `
2727
[
28-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/javascript/twirpscript/empty.pb.js",
29-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/javascript/twirpscript/services.pb.js",
30-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/javascript/google/protobuf/map_unittest.pb.js",
31-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/javascript/google/protobuf/unittest.pb.js",
28+
"/dist/javascript/twirpscript/empty.pb.js",
29+
"/dist/javascript/twirpscript/services.pb.js",
30+
"/dist/javascript/google/protobuf/map_unittest.pb.js",
31+
"/dist/javascript/google/protobuf/unittest.pb.js",
3232
]
3333
`;
3434

@@ -23470,10 +23470,10 @@ Groups are not supported. Found group optionalgroup
2347023470

2347123471
exports[`TwirpScript Compiler generates TypeScript 2`] = `
2347223472
[
23473-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/typescript/twirpscript/empty.pb.ts",
23474-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/typescript/twirpscript/services.pb.ts",
23475-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/typescript/google/protobuf/map_unittest.pb.ts",
23476-
"/Users/tatethurston/TwirpScript/e2e/protos/dist/typescript/google/protobuf/unittest.pb.ts",
23473+
"/dist/typescript/twirpscript/empty.pb.ts",
23474+
"/dist/typescript/twirpscript/services.pb.ts",
23475+
"/dist/typescript/google/protobuf/map_unittest.pb.ts",
23476+
"/dist/typescript/google/protobuf/unittest.pb.ts",
2347723477
]
2347823478
`;
2347923479

e2e/protos/test.ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,24 @@ import { mkdirSync, readFileSync, readdirSync, rmdirSync } from "fs";
33
import { join } from "path";
44

55
describe("TwirpScript Compiler", () => {
6+
const TYPESCRIPT_DEST = join(__dirname, "dist/typescript");
7+
const JAVASCRIPT_DEST = join(__dirname, "dist/javascript");
8+
69
beforeAll(() => {
7-
mkdirSync(join(__dirname, "dist/typescript"), { recursive: true });
8-
mkdirSync(join(__dirname, "dist/javascript"), { recursive: true });
10+
mkdirSync(TYPESCRIPT_DEST, { recursive: true });
11+
mkdirSync(JAVASCRIPT_DEST, { recursive: true });
912
});
1013

1114
afterAll(() => {
12-
rmdirSync(join(__dirname, "dist/typescript"), { recursive: true });
13-
rmdirSync(join(__dirname, "dist/javascript"), { recursive: true });
15+
rmdirSync(TYPESCRIPT_DEST, { recursive: true });
16+
rmdirSync(JAVASCRIPT_DEST, { recursive: true });
1417
});
1518

1619
it("generates TypeScript", () => {
1720
const child = spawnSync(
1821
`protoc \
1922
--plugin=protoc-gen-twirpscript=./node_modules/twirpscript/dist/compiler.js \
20-
--twirpscript_out=./dist/typescript \
23+
--twirpscript_out=${TYPESCRIPT_DEST} \
2124
--twirpscript_opt=language=typescript \
2225
$(find . -name '*.proto')`,
2326
{
@@ -28,13 +31,13 @@ describe("TwirpScript Compiler", () => {
2831
);
2932

3033
expect(child.output).toMatchSnapshot();
31-
const files = readdirSync(join(__dirname, "dist/typescript"), {
34+
const files = readdirSync(join(TYPESCRIPT_DEST), {
3235
recursive: true,
3336
withFileTypes: true,
3437
})
3538
.filter((f) => f.isFile())
3639
.map((f) => join(f.path, f.name));
37-
expect(files).toMatchSnapshot();
40+
expect(files.map((f) => f.replace(__dirname, ""))).toMatchSnapshot();
3841
files.forEach((file) =>
3942
expect(readFileSync(file, { encoding: "utf8" })).toMatchSnapshot(),
4043
);
@@ -44,7 +47,7 @@ describe("TwirpScript Compiler", () => {
4447
const child = spawnSync(
4548
`protoc \
4649
--plugin=protoc-gen-twirpscript=./node_modules/twirpscript/dist/compiler.js \
47-
--twirpscript_out=./dist/javascript \
50+
--twirpscript_out=${JAVASCRIPT_DEST} \
4851
--twirpscript_opt=language=javascript \
4952
$(find . -name '*.proto')`,
5053
{
@@ -55,13 +58,13 @@ describe("TwirpScript Compiler", () => {
5558
);
5659

5760
expect(child.output).toMatchSnapshot();
58-
const files = readdirSync(join(__dirname, "dist/javascript"), {
61+
const files = readdirSync(JAVASCRIPT_DEST, {
5962
recursive: true,
6063
withFileTypes: true,
6164
})
6265
.filter((f) => f.isFile())
6366
.map((f) => join(f.path, f.name));
64-
expect(files).toMatchSnapshot();
67+
expect(files.map((f) => f.replace(__dirname, ""))).toMatchSnapshot();
6568
files.forEach((file) =>
6669
expect(readFileSync(file, { encoding: "utf8" })).toMatchSnapshot(),
6770
);

examples/authentication/src/server/middleware/requireAuthentication.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export function requireAuthentication({
1111
exceptions,
1212
}: RequireAuthenticationOpts): Middleware<Context, IncomingMessage> {
1313
return async (req, ctx, next) => {
14-
for (let exception of exceptions) {
14+
for (const exception of exceptions) {
1515
if (ctx.service?.name === exception) {
1616
ctx.currentUser = unauthenticatedUser;
1717
return next();

examples/authentication/src/server/services/haberdasher/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ describe("Haberdasher", () => {
99
expect(haberdasher.MakeHat(size, ctx)).toEqual(
1010
expect.objectContaining({
1111
inches: size.inches,
12+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1213
name: expect.stringMatching("tate"),
1314
}),
1415
);

examples/aws-lambda/cdk.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
/* eslint-disable @typescript-eslint/no-unused-vars */
12
import { App, Stack, StackProps } from "@aws-cdk/core";
23
import * as lambda from "@aws-cdk/aws-lambda";
34
import * as apigateway from "@aws-cdk/aws-apigateway";
45

56
export class AwsLambdaStack extends Stack {
6-
constructor(scope: any, id: string, props?: StackProps) {
7+
constructor(scope: unknown, id: string, props?: StackProps) {
78
super(scope, id, props);
89

910
const handler = new lambda.Function(this, "TwirpHandler", {

examples/aws-lambda/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { MakeHat } from "./haberdasher.pb";
44
client.baseURL = "https://jr8wrw06og.execute-api.us-west-1.amazonaws.com";
55
client.prefix = "/prod/twirp";
66

7-
(async function () {
7+
void (async function () {
88
try {
99
const hat = await MakeHat({ inches: 12 });
1010
console.log(hat);

examples/javascript-fullstack/src/server/haberdasher/test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-undef */
12
import { haberdasher } from ".";
23

34
describe("Haberdasher", () => {

examples/javascript-fullstack/src/server/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,6 @@ app.use(async (req, _ctx, next) => {
3434
});
3535

3636
createServer(app).listen(PORT, () =>
37+
// eslint-disable-next-line no-undef
3738
console.log(`Server listening on port ${PORT}`),
3839
);

examples/server-to-server/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ async function main() {
1515
console.log();
1616
}
1717

18-
main();
18+
void main();

examples/server-to-server/src/server/haberdasher/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-undef */
12
import { haberdasher } from ".";
23

34
describe("Haberdasher", () => {

packages/twirpscript/src/autogenerate/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment */
12
import { RUNTIME_MIN_CODE_GEN_SUPPORTED_VERSION } from "../runtime/index.js";
23
import {
34
printComments,

packages/twirpscript/src/cli/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ const compiler = join(
1212
`compiler.${isWindows ? "cmd" : "js"}`,
1313
);
1414

15+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
1516
void main({ compiler: { path: compiler }, logger: { name: "TwirpScript" } });

packages/twirpscript/src/compile.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import { compile as protocompile } from "protoscript/plugin";
22
import { plugin } from "./autogenerate/index.js";
33

44
export const compile: typeof protocompile = (input) =>
5+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
56
protocompile(input, [plugin]);

packages/twirpscript/src/compiler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env node
22
import { compiler } from "protoscript/plugin";
33
import { compile } from "./compile.js";
4+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
45
await compiler(compile);

packages/twirpscript/src/node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const nodeHttpTransport: RpcTransport = (url, options) => {
2727
});
2828
};
2929
res.on("error", reject);
30-
res.on("data", (chunk) => chunks.push(chunk));
30+
res.on("data", (chunk: Buffer) => chunks.push(chunk));
3131
res.on("end", onResolve);
3232
},
3333
).on("error", reject);

packages/twirpscript/src/runtime/client/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-assignment */
12
import {
23
client,
34
JSONrequest,

packages/twirpscript/src/runtime/error/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
12
import type { RpcTransportResponse } from "../client/index.js";
23

34
export interface TwirpError {

packages/twirpscript/src/runtime/server/requestLogging/test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-explicit-any */
12
import { withRequestLogging, timingField } from "./index.js";
23
import { createEventEmitter } from "../../eventEmitter/index.js";
34
import { ServerHooks } from "../index.js";
@@ -41,6 +42,7 @@ describe("withRequestLogging", () => {
4142
});
4243

4344
it("responseSent", () => {
45+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4446
ee.emit("responseSent", { [timingField]: Date.now() - 10 }, {
4547
statusCode: 200,
4648
} as any);

0 commit comments

Comments
 (0)