Skip to content

Commit 0c2da1f

Browse files
committed
fix: resolve linting errors in firebase-functions.ts
- Mark runStdioDiscovery() promise with void operator - Move handleQuitquitquit function to program root - Fix TypeScript warnings for error handling - Add eslint-disable comment for Express async handler
1 parent 62e37ba commit 0c2da1f

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

src/bin/firebase-functions.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,34 +59,40 @@ async function runStdioDiscovery() {
5959
process.exit(0);
6060
} catch (e) {
6161
console.error("Failed to generate manifest from function source:", e);
62-
process.stderr.write(`__FIREBASE_FUNCTIONS_MANIFEST_ERROR__:${e.message}\n`);
62+
const errorMessage = e instanceof Error ? e.message : String(e);
63+
process.stderr.write(`__FIREBASE_FUNCTIONS_MANIFEST_ERROR__:${errorMessage}\n`);
6364
process.exit(1);
6465
}
6566
}
6667

67-
if (process.env.FUNCTIONS_CONTROL_API === "true" && process.env.FUNCTIONS_DISCOVERY_MODE === "stdio") {
68-
runStdioDiscovery();
68+
function handleQuitquitquit(req: express.Request, res: express.Response, server: http.Server) {
69+
res.send("ok");
70+
server.close();
71+
}
72+
73+
if (
74+
process.env.FUNCTIONS_CONTROL_API === "true" &&
75+
process.env.FUNCTIONS_DISCOVERY_MODE === "stdio"
76+
) {
77+
void runStdioDiscovery();
6978
} else {
7079
let server: http.Server = undefined;
7180
const app = express();
7281

73-
function handleQuitquitquit(req: express.Request, res: express.Response) {
74-
res.send("ok");
75-
server.close();
76-
}
77-
78-
app.get("/__/quitquitquit", handleQuitquitquit);
79-
app.post("/__/quitquitquit", handleQuitquitquit);
82+
app.get("/__/quitquitquit", (req, res) => handleQuitquitquit(req, res, server));
83+
app.post("/__/quitquitquit", (req, res) => handleQuitquitquit(req, res, server));
8084

8185
if (process.env.FUNCTIONS_CONTROL_API === "true") {
86+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
8287
app.get("/__/functions.yaml", async (req, res) => {
8388
try {
8489
const stack = await loadStack(functionsDir);
8590
res.setHeader("content-type", "text/yaml");
8691
res.send(JSON.stringify(stackToWire(stack)));
8792
} catch (e) {
8893
console.error(e);
89-
res.status(400).send(`Failed to generate manifest from function source: ${e}`);
94+
const errorMessage = e instanceof Error ? e.message : String(e);
95+
res.status(400).send(`Failed to generate manifest from function source: ${errorMessage}`);
9096
}
9197
});
9298
}

0 commit comments

Comments
 (0)