chore: Improves linting rule to catch mishandled promises (#5506)
This commit is contained in:
@@ -5,6 +5,14 @@
|
||||
"parserOptions": {
|
||||
"project": "./tsconfig.json"
|
||||
},
|
||||
"rules": {
|
||||
"@typescript-eslint/no-misused-promises": [
|
||||
"error",
|
||||
{
|
||||
"checksVoidReturn": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["scripts/*"],
|
||||
|
||||
@@ -53,6 +53,7 @@ export class ViewsExtension implements Extension {
|
||||
|
||||
// Set up an interval to update the last viewed at timestamp continuously
|
||||
// while the user is connected. This should only be done once per socket.
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
const interval = setInterval(updateView, 30 * Second);
|
||||
|
||||
this.intervalsBySocket.set(socketId, interval);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable @typescript-eslint/no-misused-promises */
|
||||
/* eslint-disable import/order */
|
||||
import env from "./env";
|
||||
|
||||
@@ -69,8 +70,8 @@ async function start(id: number, disconnect: () => void) {
|
||||
const app = new Koa();
|
||||
const server = stoppable(
|
||||
useHTTPS
|
||||
? https.createServer(ssl, app.callback())
|
||||
: http.createServer(app.callback()),
|
||||
? https.createServer(ssl, void app.callback())
|
||||
: http.createServer(void app.callback()),
|
||||
ShutdownHelper.connectionGraceTimeout
|
||||
);
|
||||
const router = new Router();
|
||||
@@ -162,8 +163,8 @@ async function start(id: number, disconnect: () => void) {
|
||||
ShutdownHelper.add("metrics", ShutdownOrder.last, () => Metrics.flush());
|
||||
|
||||
// Handle shutdown signals
|
||||
process.once("SIGTERM", () => ShutdownHelper.execute());
|
||||
process.once("SIGINT", () => ShutdownHelper.execute());
|
||||
process.once("SIGTERM", () => void ShutdownHelper.execute());
|
||||
process.once("SIGINT", () => void ShutdownHelper.execute());
|
||||
}
|
||||
|
||||
void throng({
|
||||
|
||||
@@ -1573,21 +1573,18 @@ describe("#documents.search", () => {
|
||||
},
|
||||
});
|
||||
|
||||
return new Promise((resolve) => {
|
||||
// setTimeout is needed here because SearchQuery is saved asynchronously
|
||||
// in order to not slow down the response time.
|
||||
setTimeout(async () => {
|
||||
const searchQuery = await SearchQuery.findAll({
|
||||
where: {
|
||||
query: "my term",
|
||||
},
|
||||
});
|
||||
expect(searchQuery.length).toBe(1);
|
||||
expect(searchQuery[0].results).toBe(0);
|
||||
expect(searchQuery[0].source).toBe("app");
|
||||
resolve(undefined);
|
||||
}, 100);
|
||||
// setTimeout is needed here because SearchQuery is saved asynchronously
|
||||
// in order to not slow down the response time.
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
|
||||
const searchQuery = await SearchQuery.findAll({
|
||||
where: {
|
||||
query: "my term",
|
||||
},
|
||||
});
|
||||
expect(searchQuery.length).toBe(1);
|
||||
expect(searchQuery[0].results).toBe(0);
|
||||
expect(searchQuery[0].source).toBe("app");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ export default function init() {
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(() => run(TaskSchedule.Daily), Day);
|
||||
setInterval(() => run(TaskSchedule.Hourly), Hour);
|
||||
setInterval(() => void run(TaskSchedule.Daily), Day);
|
||||
setInterval(() => void run(TaskSchedule.Hourly), Hour);
|
||||
|
||||
// Just give everything time to startup before running the first time. Not
|
||||
// _technically_ required to function.
|
||||
|
||||
@@ -86,7 +86,7 @@ export default function init(app: Koa = new Koa(), server?: Server) {
|
||||
|
||||
// Monitor server connections
|
||||
if (server) {
|
||||
setInterval(async () => {
|
||||
setInterval(() => {
|
||||
server.getConnections((err, count) => {
|
||||
if (err) {
|
||||
return;
|
||||
|
||||
@@ -53,6 +53,7 @@ export function createQueue(
|
||||
});
|
||||
|
||||
if (env.ENVIRONMENT !== "test") {
|
||||
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
||||
setInterval(async () => {
|
||||
Metrics.gauge(`${prefix}.count`, await queue.count());
|
||||
Metrics.gauge(`${prefix}.delayed_count`, await queue.getDelayedCount());
|
||||
|
||||
Reference in New Issue
Block a user