Skip to content

Commit 470be5e

Browse files
feat: Install eslint-plugin-unused-imports and eslint-plugin-import and fix issues
1 parent f542e74 commit 470be5e

36 files changed

+152
-623
lines changed

.eslintrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"ignorePatterns": [
3+
"node_modules",
4+
".next",
5+
"dist",
6+
".open-next",
7+
".wrangler",
8+
"*.config.js",
9+
"*.config.mjs",
10+
"*.config.ts"
11+
]
12+
}

eslint.config.mjs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { dirname } from "path";
22
import { fileURLToPath } from "url";
33
import { FlatCompat } from "@eslint/eslintrc";
4+
import unusedImports from "eslint-plugin-unused-imports";
5+
import importPlugin from "eslint-plugin-import";
46

57
const __filename = fileURLToPath(import.meta.url);
68
const __dirname = dirname(__filename);
@@ -11,6 +13,55 @@ const compat = new FlatCompat({
1113

1214
const eslintConfig = [
1315
...compat.extends("next/core-web-vitals", "next/typescript"),
16+
{
17+
plugins: {
18+
"unused-imports": unusedImports,
19+
import: importPlugin,
20+
},
21+
rules: {
22+
// Turn off the base @typescript-eslint/no-unused-vars rule
23+
"@typescript-eslint/no-unused-vars": "off",
24+
// Use the unused-imports plugin to handle unused vars
25+
"unused-imports/no-unused-imports": "error",
26+
"unused-imports/no-unused-vars": [
27+
"error",
28+
{
29+
vars: "all",
30+
varsIgnorePattern: "^_",
31+
args: "after-used",
32+
argsIgnorePattern: "^_",
33+
},
34+
],
35+
// eslint-plugin-import rules
36+
"import/no-unused-modules": [
37+
"error",
38+
{
39+
unusedExports: true,
40+
missingExports: false,
41+
},
42+
],
43+
},
44+
},
45+
// Disable unused-modules rule for Next.js app directory files
46+
{
47+
files: [
48+
"src/app/**/page.tsx",
49+
"src/app/**/layout.tsx",
50+
"src/app/**/template.tsx",
51+
"src/app/**/loading.tsx",
52+
"src/app/**/error.tsx",
53+
"src/app/**/not-found.tsx",
54+
"src/app/**/route.ts",
55+
"src/app/**/default.tsx",
56+
"src/middleware.ts",
57+
"*.config.ts",
58+
"*.config.js",
59+
"*.config.mjs",
60+
],
61+
rules: {
62+
"import/no-unused-modules": "off",
63+
},
64+
},
1465
];
1566

1667
export default eslintConfig;

opencode.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$schema": "https://opencode.ai/config.json",
3+
"mcp": {
4+
"gh_grep": {
5+
"type": "remote",
6+
"url": "https://mcp.grep.app"
7+
}
8+
}
9+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@
8989
"drizzle-kit": "^0.31.5",
9090
"eslint": "^9",
9191
"eslint-config-next": "15.4.6",
92+
"eslint-plugin-import": "^2.32.0",
93+
"eslint-plugin-unused-imports": "^4.3.0",
9294
"react-email": "3.0.6",
9395
"tailwindcss": "^4.1.14",
9496
"tw-animate-css": "^1.4.0",

pnpm-lock.yaml

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions/team-actions.ts

Lines changed: 1 addition & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
"use server";
22

33
import { z } from "zod";
4-
import { createTeam, deleteTeam, getTeam, getUserTeams, updateTeam } from "@/server/teams";
4+
import { createTeam, getUserTeams } from "@/server/teams";
55
import { ZSAError, createServerAction } from "zsa";
66

7-
// Update team schema
8-
const updateTeamSchema = z.object({
9-
teamId: z.string().min(1, "Team ID is required"),
10-
data: z.object({
11-
name: z.string().min(1, "Name is required").max(100, "Name is too long").optional(),
12-
description: z.string().max(1000, "Description is too long").optional(),
13-
avatarUrl: z.string().url("Invalid avatar URL").max(600, "URL is too long").optional(),
14-
billingEmail: z.string().email("Invalid email").max(255, "Email is too long").optional(),
15-
settings: z.string().max(10000, "Settings are too large").optional(),
16-
}),
17-
});
18-
19-
const deleteTeamSchema = z.object({
20-
teamId: z.string().min(1, "Team ID is required"),
21-
});
22-
23-
const getTeamSchema = z.object({
24-
teamId: z.string().min(1, "Team ID is required"),
25-
});
26-
277
const createTeamSchema = z.object({
288
name: z.string().min(1, "Name is required").max(100, "Name is too long"),
299
description: z.string().max(1000, "Description is too long").optional(),
@@ -49,52 +29,6 @@ export const createTeamAction = createServerAction()
4929
}
5030
});
5131

52-
/**
53-
* Update team details server action
54-
*/
55-
export const updateTeamAction = createServerAction()
56-
.input(updateTeamSchema)
57-
.handler(async ({ input }) => {
58-
try {
59-
const result = await updateTeam(input);
60-
return { success: true, data: result };
61-
} catch (error) {
62-
console.error("Failed to update team:", error);
63-
64-
if (error instanceof ZSAError) {
65-
throw error;
66-
}
67-
68-
throw new ZSAError(
69-
"INTERNAL_SERVER_ERROR",
70-
"Failed to update team"
71-
);
72-
}
73-
});
74-
75-
/**
76-
* Delete team server action
77-
*/
78-
export const deleteTeamAction = createServerAction()
79-
.input(deleteTeamSchema)
80-
.handler(async ({ input }) => {
81-
try {
82-
await deleteTeam(input.teamId);
83-
return { success: true };
84-
} catch (error) {
85-
console.error("Failed to delete team:", error);
86-
87-
if (error instanceof ZSAError) {
88-
throw error;
89-
}
90-
91-
throw new ZSAError(
92-
"INTERNAL_SERVER_ERROR",
93-
"Failed to delete team"
94-
);
95-
}
96-
});
97-
9832
/**
9933
* Get all teams for the current user
10034
*/
@@ -116,26 +50,3 @@ export const getUserTeamsAction = createServerAction()
11650
);
11751
}
11852
});
119-
120-
/**
121-
* Get a team by ID
122-
*/
123-
export const getTeamAction = createServerAction()
124-
.input(getTeamSchema)
125-
.handler(async ({ input }) => {
126-
try {
127-
const team = await getTeam(input.teamId);
128-
return { success: true, data: team };
129-
} catch (error) {
130-
console.error(`Failed to get team ${input.teamId}:`, error);
131-
132-
if (error instanceof ZSAError) {
133-
throw error;
134-
}
135-
136-
throw new ZSAError(
137-
"INTERNAL_SERVER_ERROR",
138-
"Failed to get team"
139-
);
140-
}
141-
});

src/actions/team-membership-actions.ts

Lines changed: 6 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22

33
import { createServerAction, ZSAError } from "zsa";
44
import { z } from "zod";
5-
import { acceptTeamInvitation, cancelTeamInvitation, getTeamInvitations, getTeamMembers, inviteUserToTeam, removeTeamMember, updateTeamMemberRole, getPendingInvitationsForCurrentUser } from "@/server/team-members";
5+
import {
6+
acceptTeamInvitation,
7+
inviteUserToTeam,
8+
removeTeamMember,
9+
getPendingInvitationsForCurrentUser
10+
} from "@/server/team-members";
611
import { withRateLimit, RATE_LIMITS } from "@/utils/with-rate-limit";
712

813
// Invite user schema
@@ -13,27 +18,11 @@ const inviteUserSchema = z.object({
1318
isSystemRole: z.boolean().optional().default(true),
1419
});
1520

16-
// Update member role schema
17-
const updateMemberRoleSchema = z.object({
18-
teamId: z.string().min(1, "Team ID is required"),
19-
userId: z.string().min(1, "User ID is required"),
20-
roleId: z.string().min(1, "Role is required"),
21-
isSystemRole: z.boolean().optional().default(true),
22-
});
23-
24-
const teamIdSchema = z.object({
25-
teamId: z.string().min(1, "Team ID is required"),
26-
});
27-
2821
const removeMemberSchema = z.object({
2922
teamId: z.string().min(1, "Team ID is required"),
3023
userId: z.string().min(1, "User ID is required"),
3124
});
3225

33-
const invitationIdSchema = z.object({
34-
invitationId: z.string().min(1, "Invitation ID is required"),
35-
});
36-
3726
const invitationTokenSchema = z.object({
3827
token: z.string().min(1, "Invitation token is required"),
3928
});
@@ -66,52 +55,6 @@ export const inviteUserAction = createServerAction()
6655
);
6756
});
6857

69-
/**
70-
* Get team members action
71-
*/
72-
export const getTeamMembersAction = createServerAction()
73-
.input(teamIdSchema)
74-
.handler(async ({ input }) => {
75-
try {
76-
const members = await getTeamMembers(input.teamId);
77-
return { success: true, data: members };
78-
} catch (error) {
79-
console.error("Failed to get team members:", error);
80-
81-
if (error instanceof ZSAError) {
82-
throw error;
83-
}
84-
85-
throw new ZSAError(
86-
"INTERNAL_SERVER_ERROR",
87-
"Failed to get team members"
88-
);
89-
}
90-
});
91-
92-
/**
93-
* Update a team member's role
94-
*/
95-
export const updateMemberRoleAction = createServerAction()
96-
.input(updateMemberRoleSchema)
97-
.handler(async ({ input }) => {
98-
try {
99-
await updateTeamMemberRole(input);
100-
return { success: true };
101-
} catch (error) {
102-
console.error("Failed to update member role:", error);
103-
104-
if (error instanceof ZSAError) {
105-
throw error;
106-
}
107-
108-
throw new ZSAError(
109-
"INTERNAL_SERVER_ERROR",
110-
"Failed to update member role"
111-
);
112-
}
113-
});
114-
11558
/**
11659
* Remove a team member
11760
*/
@@ -135,52 +78,6 @@ export const removeTeamMemberAction = createServerAction()
13578
}
13679
});
13780

138-
/**
139-
* Get pending team invitations
140-
*/
141-
export const getTeamInvitationsAction = createServerAction()
142-
.input(teamIdSchema)
143-
.handler(async ({ input }) => {
144-
try {
145-
const invitations = await getTeamInvitations(input.teamId);
146-
return { success: true, data: invitations };
147-
} catch (error) {
148-
console.error("Failed to get team invitations:", error);
149-
150-
if (error instanceof ZSAError) {
151-
throw error;
152-
}
153-
154-
throw new ZSAError(
155-
"INTERNAL_SERVER_ERROR",
156-
"Failed to get team invitations"
157-
);
158-
}
159-
});
160-
161-
/**
162-
* Cancel a team invitation
163-
*/
164-
export const cancelInvitationAction = createServerAction()
165-
.input(invitationIdSchema)
166-
.handler(async ({ input }) => {
167-
try {
168-
await cancelTeamInvitation(input.invitationId);
169-
return { success: true };
170-
} catch (error) {
171-
console.error("Failed to cancel invitation:", error);
172-
173-
if (error instanceof ZSAError) {
174-
throw error;
175-
}
176-
177-
throw new ZSAError(
178-
"INTERNAL_SERVER_ERROR",
179-
"Failed to cancel invitation"
180-
);
181-
}
182-
});
183-
18481
/**
18582
* Accept a team invitation
18683
*/

0 commit comments

Comments
 (0)