c7861be520
Once this is merged, oxlint is at a pretty sensible baseline. **Enable `no-unused-vars`, `typescript/consistent-type-imports`, and `import/no-duplicates` lint rules** Turns on three previously-disabled oxlint rules across the monorepo and fixes all violations: - **`no-unused-vars`** – enabled as an error with standard ignore patterns: unused function arguments are ignored by default (`args: "none"`), variables/caught errors/destructured array elements prefixed with `_` are allowed, and rest siblings are permitted. - **`typescript/consistent-type-imports`** – enforced as an error; all type-only imports now use the `import type` syntax. - **`import/no-duplicates`** – enforced as an error; duplicate import statements from the same module have been merged. The remaining commits clean up the violations found across the codebase: removing unused variables/imports/type aliases, adding `_` prefixes to intentionally unused bindings, fixing duplicate imports, and converting value imports to `import type` where appropriate.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { AuthenticatedEnvironment } from "~/services/apiAuth.server";
|
|
import { env } from "~/env.server";
|
|
import type { MarQS } from "./marqs/index.server";
|
|
|
|
export type QueueSizeGuardResult = {
|
|
isWithinLimits: boolean;
|
|
maximumSize?: number;
|
|
queueSize?: number;
|
|
};
|
|
|
|
export async function guardQueueSizeLimitsForEnv(
|
|
environment: AuthenticatedEnvironment,
|
|
marqs?: MarQS,
|
|
itemsToAdd: number = 1
|
|
): Promise<QueueSizeGuardResult> {
|
|
const maximumSize = getMaximumSizeForEnvironment(environment);
|
|
|
|
if (typeof maximumSize === "undefined") {
|
|
return { isWithinLimits: true };
|
|
}
|
|
|
|
if (!marqs) {
|
|
return { isWithinLimits: true, maximumSize };
|
|
}
|
|
|
|
const queueSize = await marqs.lengthOfEnvQueue(environment);
|
|
const projectedSize = queueSize + itemsToAdd;
|
|
|
|
return {
|
|
isWithinLimits: projectedSize <= maximumSize,
|
|
maximumSize,
|
|
queueSize,
|
|
};
|
|
}
|
|
|
|
function getMaximumSizeForEnvironment(environment: AuthenticatedEnvironment): number | undefined {
|
|
if (environment.type === "DEVELOPMENT") {
|
|
return environment.organization.maximumDevQueueSize ?? env.MAXIMUM_DEV_QUEUE_SIZE;
|
|
} else {
|
|
return environment.organization.maximumDeployedQueueSize ?? env.MAXIMUM_DEPLOYED_QUEUE_SIZE;
|
|
}
|
|
}
|