Files
triggerdotdev--trigger.dev/apps/webapp/app/presenters/ProjectPresenter.server.ts
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

78 lines
2.0 KiB
TypeScript

import type { PrismaClient } from "~/db.server";
import { prisma } from "~/db.server";
import type { Project } from "~/models/project.server";
import { displayableEnvironment } from "~/models/runtimeEnvironment.server";
import type { User } from "~/models/user.server";
import { sortEnvironments } from "~/utils/environmentSort";
export class ProjectPresenter {
#prismaClient: PrismaClient;
constructor(prismaClient: PrismaClient = prisma) {
this.#prismaClient = prismaClient;
}
public async call({
userId,
id,
}: Pick<Project, "id"> & {
userId: User["id"];
}) {
const project = await this.#prismaClient.project.findFirst({
select: {
id: true,
slug: true,
name: true,
organizationId: true,
createdAt: true,
updatedAt: true,
deletedAt: true,
version: true,
externalRef: true,
environments: {
select: {
id: true,
slug: true,
type: true,
orgMember: {
select: {
user: {
select: {
id: true,
name: true,
displayName: true,
},
},
},
},
apiKey: true,
},
},
},
where: { id, deletedAt: null, organization: { members: { some: { userId } } } },
});
if (!project) {
return undefined;
}
return {
id: project.id,
slug: project.slug,
ref: project.externalRef,
name: project.name,
organizationId: project.organizationId,
createdAt: project.createdAt,
updatedAt: project.updatedAt,
deletedAt: project.deletedAt,
version: project.version,
environments: sortEnvironments(
project.environments.map((environment) => ({
...displayableEnvironment(environment, userId),
userId: environment.orgMember?.user.id,
}))
),
};
}
}