Skip to content

Commit 6ef044c

Browse files
authored
Tooling phoenix (kamp-us#444)
Update eslint, tsconfig & prettier. here is what i did: i moved the packages/apps we don't use anymore to deprecated folder apps/pano apps/home packages/kampus-ui packages/pano-button i removed packages/kampus-eslint-config and packages/kampus-tsconfig created config folder and added it as workspaces folder in package.json. I thought we can host the configs over there. redid the prettier config based on https://github.com/t3-oss/create-t3-turbo/blob/main/prettier.config.cjs
1 parent 1963f4d commit 6ef044c

File tree

230 files changed

+11122
-16692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+11122
-16692
lines changed

.eslintrc.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
/** @type {import("eslint").Linter.Config} */
22
const config = {
33
root: true,
4-
extends: ["@kampus/eslint-config/next"],
4+
extends: ["@kampus/eslint-config"], // uses the config in `config/eslint`
55
parser: "@typescript-eslint/parser",
6+
ignorePatterns: ["**/*.generated.ts"],
7+
parserOptions: {
8+
ecmaVersion: "latest",
9+
tsconfigRootDir: __dirname,
10+
project: ["./tsconfig.json", "./apps/*/tsconfig.json", "./packages/*/tsconfig.json"],
11+
},
612
settings: {
713
next: {
814
rootDir: ["apps/kampus", "apps/gql"],

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
2+
__generated__
23

34
.next
45

.prettierrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

apps/gql/app/graphql/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { createSchema, createYoga } from "graphql-yoga";
21
import { readFileSync } from "node:fs";
32
import { join } from "node:path";
3+
import { createSchema, createYoga } from "graphql-yoga";
4+
45
import { createClients } from "~/clients";
56
import { createLoaders } from "~/loaders";
67
import { resolvers } from "~/schema/resolvers";
@@ -12,7 +13,7 @@ const { handleRequest } = createYoga({
1213
schema: createSchema({ typeDefs, resolvers }),
1314
logging: "debug",
1415
graphiql: true,
15-
context: async () => ({
16+
context: () => ({
1617
loaders: createLoaders(clients),
1718
}),
1819

apps/gql/clients/prisma.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { PrismaClient } from "@kampus-db/pano-prisma";
2+
23
import { env } from "~/env";
34

45
export function createPrismaClient() {

apps/gql/loaders/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { type Clients } from "~/clients/types";
12
import { createSozlukLoaders } from "./sozluk";
23
import { type DataLoaders } from "./types";
34
import { createUsersLoader } from "./users";
4-
import { type Clients } from "~/clients/types";
55

66
export const createLoaders = (clients: Clients): DataLoaders => {
77
return {

apps/gql/loaders/sozluk.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { allTerms } from "@kampus/sozluk-content";
21
import DataLoader from "dataloader";
3-
import { LoaderKey } from "./utils/loader-key";
2+
3+
import { allTerms } from "@kampus/sozluk-content";
4+
45
import { type Clients } from "~/clients/types";
56
import { type SozlukTerm } from "~/schema/types.generated";
7+
import { LoaderKey } from "./utils/loader-key";
68

79
export const createSozlukLoaders = (clients: Clients) => {
810
return {
@@ -14,6 +16,7 @@ export type SozlukTermsLoader = DataLoader<SozlukTermLoaderKey, SozlukTerm>;
1416
export class SozlukTermLoaderKey extends LoaderKey<"id", string> {}
1517

1618
function createTermsLoader(_: Clients) {
19+
// eslint-disable-next-line @typescript-eslint/require-await
1720
return new DataLoader<SozlukTermLoaderKey, SozlukTerm>(async (keys) => {
1821
console.log({ keys });
1922

apps/gql/loaders/users.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
import DataLoader from "dataloader";
2-
import { LoaderKey } from "./utils/loader-key";
2+
33
import { type Clients } from "~/clients/types";
44
import { type User } from "~/schema/types.generated";
5+
import { LoaderKey } from "./utils/loader-key";
56

67
export type UsersLoader = DataLoader<UserLoaderKey, User>;
78

89
export class UserLoaderKey extends LoaderKey<"id" | "username", string> {}
910

1011
export const createUsersLoader = (clients: Clients): UsersLoader =>
1112
new DataLoader<UserLoaderKey, User>(async (keys) => {
12-
const request: Record<string, string[]> = {
13-
ids: [],
14-
usernames: [],
15-
};
13+
const ids: string[] = [];
14+
const usernames: string[] = [];
1615

1716
keys.forEach((key) => {
1817
const { identifier, value } = key;
1918
if (identifier === "id") {
20-
request.ids.push(value);
19+
ids.push(value);
2120
} else if (identifier === "username") {
22-
request.usernames.push(value);
21+
usernames.push(value);
2322
}
2423
});
2524

2625
const users = await clients.prisma.user.findMany({
2726
where: {
28-
OR: [{ id: { in: request.ids } }, { username: { in: request.usernames } }],
27+
OR: [{ id: { in: ids } }, { username: { in: usernames } }],
2928
deletedAt: null,
3029
},
3130
});

apps/gql/schema/resolvers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { type Resolvers } from "../types.generated";
12
import { term } from "./Query/SozlukQuery/term";
23
import { user } from "./Query/user";
3-
import { type Resolvers } from "../types.generated";
44

55
export const resolvers = {
66
Query: {

apps/gql/schema/types.generated.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { GraphQLResolveInfo } from "graphql";
2+
23
import { KampusGQLContext } from "./types";
4+
35
export type Maybe<T> = T | null;
46
export type InputMaybe<T> = Maybe<T>;
57
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };

0 commit comments

Comments
 (0)