Files
Chris Arderne c7861be520 chore: activate no-unused-vars and import linters (#4096)
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.
2026-07-02 11:37:05 +01:00

52 lines
1.7 KiB
TypeScript

import type { RuntimeEnvironmentType } from "@trigger.dev/database";
import { env } from "~/env.server";
/**
* Organization fields needed for queue limit calculation.
*/
export type QueueLimitOrganization = {
maximumDevQueueSize: number | null;
maximumDeployedQueueSize: number | null;
};
/**
* Calculates the queue size limit for an environment based on its type and organization settings.
*
* Resolution order:
* 1. Organization-level override (set by billing sync or admin)
* 2. Environment variable fallback
* 3. null if neither is set
*
* @param environmentType - The type of the runtime environment
* @param organization - Organization with queue limit fields
* @returns The queue size limit, or null if unlimited
*/
export function getQueueSizeLimit(
environmentType: RuntimeEnvironmentType,
organization: QueueLimitOrganization
): number | null {
if (environmentType === "DEVELOPMENT") {
return organization.maximumDevQueueSize ?? env.MAXIMUM_DEV_QUEUE_SIZE ?? null;
}
return organization.maximumDeployedQueueSize ?? env.MAXIMUM_DEPLOYED_QUEUE_SIZE ?? null;
}
/**
* Determines the source of the queue size limit for display purposes.
*
* @param environmentType - The type of the runtime environment
* @param organization - Organization with queue limit fields
* @returns "plan" if org has a value (typically set by billing), "default" if using env var fallback
*/
export function getQueueSizeLimitSource(
environmentType: RuntimeEnvironmentType,
organization: QueueLimitOrganization
): "plan" | "default" {
if (environmentType === "DEVELOPMENT") {
return organization.maximumDevQueueSize !== null ? "plan" : "default";
}
return organization.maximumDeployedQueueSize !== null ? "plan" : "default";
}