Skip to content

Commit d9c5895

Browse files
committed
chore: Fix eslint & typescript errors
- Update nx - Add eslint to workspace - Reorganized tsconfigs - Fix errors
1 parent 57637ab commit d9c5895

File tree

17 files changed

+435
-698
lines changed

17 files changed

+435
-698
lines changed

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ export const defaultESLintIgnores = [
1010
"**/jest.config.js",
1111
"**/eslint.config.js",
1212
"**/payload-types.ts",
13-
"dev/src/app/(payload)/",
13+
"packages/dev/src/app/(payload)/",
1414
"**/dist/",
1515
"**/build/",
1616
"**/node_modules/",
1717
"**/temp/",
18+
"examples/",
1819
];
1920

2021
export default [
@@ -31,7 +32,6 @@ export default [
3132
"perfectionist/sort-jsx-props": "off",
3233
},
3334
},
34-
// TODO: Bring in '@payloadcms/eslint-plugin' for 'payload/proper-payload-logger-usage' rule
3535
{
3636
ignores: defaultESLintIgnores,
3737
},

examples/basic/eslint.config.mjs

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
import { dirname } from 'path'
2-
import { fileURLToPath } from 'url'
3-
import { FlatCompat } from '@eslint/eslintrc'
1+
import { FlatCompat } from "@eslint/eslintrc";
2+
import { dirname } from "path";
3+
import { fileURLToPath } from "url";
44

5-
const __filename = fileURLToPath(import.meta.url)
6-
const __dirname = dirname(__filename)
5+
const __filename = fileURLToPath(import.meta.url);
6+
const __dirname = dirname(__filename);
77

88
const compat = new FlatCompat({
99
baseDirectory: __dirname,
10-
})
10+
});
1111

1212
const eslintConfig = [
13-
...compat.extends('next/core-web-vitals', 'next/typescript'),
13+
...compat.extends("next/core-web-vitals", "next/typescript"),
14+
{
15+
ignores: ["src/app/(payload)/"],
16+
},
1417
{
1518
rules: {
16-
'@typescript-eslint/ban-ts-comment': 'warn',
17-
'@typescript-eslint/no-empty-object-type': 'warn',
18-
'@typescript-eslint/no-explicit-any': 'warn',
19-
'@typescript-eslint/no-unused-vars': [
20-
'warn',
19+
"@typescript-eslint/ban-ts-comment": "warn",
20+
"@typescript-eslint/no-empty-object-type": "warn",
21+
"@typescript-eslint/no-explicit-any": "warn",
22+
"@typescript-eslint/no-unused-vars": [
23+
"warn",
2124
{
22-
vars: 'all',
23-
args: 'after-used',
25+
vars: "all",
26+
args: "after-used",
2427
ignoreRestSiblings: false,
25-
argsIgnorePattern: '^_',
26-
varsIgnorePattern: '^_',
27-
destructuredArrayIgnorePattern: '^_',
28-
caughtErrorsIgnorePattern: '^(_|ignore)',
28+
argsIgnorePattern: "^_",
29+
varsIgnorePattern: "^_",
30+
destructuredArrayIgnorePattern: "^_",
31+
caughtErrorsIgnorePattern: "^(_|ignore)",
2932
},
3033
],
3134
},
3235
},
33-
]
36+
];
3437

35-
export default eslintConfig
38+
export default eslintConfig;

examples/basic/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,20 @@
2323
"next": "15.1.6",
2424
"next-auth": "5.0.0-beta.25",
2525
"payload": "^3.21.0",
26+
"payload-authjs": "workspace:*",
2627
"react": "19.0.0",
2728
"react-dom": "19.0.0",
28-
"sharp": "0.33.5",
29-
"payload-authjs": "workspace:*"
29+
"sharp": "0.33.5"
3030
},
3131
"devDependencies": {
3232
"@eslint/eslintrc": "^3.2.0",
33+
"@next/eslint-plugin-next": "^15.1.6",
3334
"@types/node": "^22.13.1",
3435
"@types/react": "19.0.8",
3536
"@types/react-dom": "19.0.3",
36-
"eslint": "^9.19.0",
37+
"eslint": "^9.20.0",
3738
"eslint-config-next": "15.1.6",
39+
"eslint-plugin-react-hooks": "^5.1.0",
3840
"typescript": "5.7.3"
3941
},
4042
"engines": {

examples/basic/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4-
"lib": ["DOM", "DOM.Iterable", "ES2022"],
4+
"target": "ESNext",
5+
"module": "ESNext",
6+
"moduleResolution": "bundler",
7+
"lib": ["DOM", "DOM.Iterable", "ESNext"],
58
"allowJs": true,
69
"skipLibCheck": true,
710
"strict": true,
811
"noEmit": true,
912
"esModuleInterop": true,
10-
"module": "esnext",
11-
"moduleResolution": "bundler",
1213
"resolveJsonModule": true,
1314
"isolatedModules": true,
1415
"jsx": "preserve",
@@ -21,8 +22,7 @@
2122
"paths": {
2223
"@/*": ["./src/*"],
2324
"@payload-config": ["./src/payload.config.ts"]
24-
},
25-
"target": "ES2022"
25+
}
2626
},
2727
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
2828
"exclude": ["node_modules"]

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
"dev": "nx run dev:dev"
99
},
1010
"devDependencies": {
11-
"@nx/eslint": "20.4.0",
12-
"@nx/js": "20.4.0",
13-
"@nx/next": "20.4.0",
14-
"@nx/react": "20.4.0",
11+
"@nx/eslint": "20.4.2",
12+
"@nx/js": "20.4.2",
13+
"@nx/next": "20.4.2",
14+
"@nx/react": "20.4.2",
1515
"@payloadcms/eslint-config": "3.9.0",
16-
"nx": "20.4.0",
17-
"prettier": "^3.4.2",
16+
"eslint": "^9.20.0",
17+
"nx": "20.4.2",
18+
"prettier": "^3.5.0",
1819
"typescript": "^5.7.3"
1920
},
2021
"nx": {},

packages/dev/src/app/(app)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { SignInOrOutButtons } from "../components/auth/SignInOrOutButtons";
1010
import ExampleList from "../components/ExampleList";
1111
import { Tabs } from "../components/general/Tabs";
1212

13-
const Page = async () => {
13+
const Page = () => {
1414
return (
1515
<main className="container mt-5">
1616
<SignInOrOutButtons />

packages/dev/src/auth.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const authConfig: NextAuthConfig = {
3636
// Default fields (@see https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/github.ts#L176)
3737
id: profile.id.toString(),
3838
name: profile.name ?? profile.login,
39-
email: profile.email!,
39+
email: profile.email,
4040
image: profile.avatar_url,
4141
// Custom fields
4242
additionalUserDatabaseField: `Create by github provider profile callback at ${new Date().toISOString()}`,

packages/dev/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ export const { handlers, signIn, signOut, auth } = NextAuth(
1010
/**
1111
* Update user on every sign in
1212
*/
13-
signIn: async ({ adapter, payload, user, profile }) => {
14-
payload?.logger.info("signIn event");
13+
signIn: async ({ adapter, user, profile }) => {
1514
if (!user.id || !profile) {
1615
return;
1716
}

packages/dev/src/payload/components/Greeting.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
"use client";
22

33
import { Banner, useAuth } from "@payloadcms/ui";
4-
import { User } from "payload/generated-types";
4+
import { type User } from "payload/generated-types";
55

66
/**
77
* Greeting banner that displays the current user
88
*/
99
const Greeting = () => {
1010
const { user } = useAuth<User>();
1111

12-
if (!user) return null;
12+
if (!user) {
13+
return null;
14+
}
1315

1416
return (
1517
<Banner type="success">

packages/dev/tsconfig.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,14 @@
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
44
"baseUrl": ".",
5-
"target": "ESNext",
5+
"moduleResolution": "bundler",
66
"lib": ["DOM", "DOM.Iterable", "ESNext"],
7+
"jsx": "preserve",
78
"allowJs": true,
8-
"strict": true,
9+
"resolveJsonModule": true,
910
"esModuleInterop": true,
10-
"jsx": "preserve",
1111
"noEmit": true,
1212
"incremental": true,
13-
"module": "ESNext",
14-
"moduleResolution": "bundler",
15-
"resolveJsonModule": true,
1613
"isolatedModules": true,
1714
"plugins": [
1815
{
@@ -28,6 +25,6 @@
2825
"payload-authjs/client": ["../payload-authjs/src/client.ts"]
2926
}
3027
},
31-
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
28+
"include": ["**/*.ts", "**/*.tsx", ".next/types/**/*.ts", "postcss.config.mjs"],
3229
"exclude": ["node_modules", "dist", "build"]
3330
}

0 commit comments

Comments
 (0)