mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-04-04 13:21:05 +08:00
Update ESLint configuration and schemas to use Zod library
- Changed ESLint configuration to target TypeScript files and added parser options for better integration. - Updated various schemas across the application to replace `nestjs-zod/z` imports with `zod` for consistency. - Refactored password validation in authentication schemas to use `z.string()` instead of `z.password()`. - Enhanced date handling in user and resume schemas by introducing a new `dateSchema` utility. - Updated `.ncurc.json` to target minor upgrades for dependencies.
This commit is contained in:
parent
6fb0a72a56
commit
0053d696ff
@ -1,6 +1,7 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/raineorshine/npm-check-updates/main/src/types/RunOptions.json",
|
||||
"upgrade": true,
|
||||
"target": "minor",
|
||||
"install": "always",
|
||||
"packageManager": "pnpm",
|
||||
"reject": [
|
||||
|
@ -3,11 +3,14 @@
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"extends": [
|
||||
"plugin:tailwindcss/recommended",
|
||||
"plugin:@tanstack/eslint-plugin-query/recommended"
|
||||
],
|
||||
"parserOptions": {
|
||||
"projectService": "./apps/client/tsconfig.json"
|
||||
},
|
||||
"settings": {
|
||||
"tailwindcss": {
|
||||
"callees": ["cn", "clsx", "cva"],
|
||||
@ -39,8 +42,59 @@
|
||||
"lingui/no-unlocalized-strings": [
|
||||
2,
|
||||
{
|
||||
"ignoreFunction": ["cn"],
|
||||
"ignoreAttribute": ["alt"]
|
||||
"ignore": [
|
||||
// Ignore strings which are a single "word" (no spaces)
|
||||
// and doesn't start with an uppercase letter
|
||||
"^(?![A-Z])\\S+$",
|
||||
// Ignore UPPERCASE literals
|
||||
// Example: const test = "FOO"
|
||||
"^[A-Z0-9_-]+$"
|
||||
],
|
||||
"ignoreNames": [
|
||||
// Ignore matching className (case-insensitive)
|
||||
{ "regex": { "pattern": "className", "flags": "i" } },
|
||||
// Ignore UPPERCASE names
|
||||
// Example: test.FOO = "ola!"
|
||||
{ "regex": { "pattern": "^[A-Z0-9_-]+$" } },
|
||||
"id",
|
||||
"src",
|
||||
"srcSet",
|
||||
"styleName",
|
||||
"placeholder",
|
||||
"alt",
|
||||
"type",
|
||||
"width",
|
||||
"height",
|
||||
"displayName",
|
||||
"Authorization"
|
||||
],
|
||||
"ignoreFunctions": [
|
||||
"cn",
|
||||
"cva",
|
||||
"track",
|
||||
"Error",
|
||||
"console.*",
|
||||
"*headers.set",
|
||||
"*.addEventListener",
|
||||
"*.removeEventListener",
|
||||
"*.postMessage",
|
||||
"*.getElementById",
|
||||
"*.dispatch",
|
||||
"*.commit",
|
||||
"*.includes",
|
||||
"*.indexOf",
|
||||
"*.endsWith",
|
||||
"*.startsWith",
|
||||
"require"
|
||||
],
|
||||
// Following settings require typed linting https://typescript-eslint.io/getting-started/typed-linting/
|
||||
"useTsTypes": true,
|
||||
"ignoreMethodsOnTypes": [
|
||||
// Ignore specified methods on Map and Set types
|
||||
"Map.get",
|
||||
"Map.has",
|
||||
"Set.has"
|
||||
]
|
||||
}
|
||||
],
|
||||
"lingui/t-call-in-function": 2,
|
||||
|
@ -18,7 +18,7 @@ import {
|
||||
verticalListSortingStrategy,
|
||||
} from "@dnd-kit/sortable";
|
||||
import { CSS } from "@dnd-kit/utilities";
|
||||
import { t, Trans } from "@lingui/macro";
|
||||
import { t } from "@lingui/macro";
|
||||
import { ArrowCounterClockwise, DotsSixVertical, Plus, TrashSimple } from "@phosphor-icons/react";
|
||||
import { defaultMetadata } from "@reactive-resume/schema";
|
||||
import { Button, Portal, Tooltip } from "@reactive-resume/ui";
|
||||
@ -92,9 +92,7 @@ type SectionProps = {
|
||||
};
|
||||
|
||||
const Section = ({ id, isDragging = false }: SectionProps) => {
|
||||
const name = useResumeStore((state) =>
|
||||
get(state.resume.data.sections, `${id}.name`, id),
|
||||
) as string;
|
||||
const name = useResumeStore((state) => get(state.resume.data.sections, `${id}.name`, id));
|
||||
|
||||
return (
|
||||
<div
|
||||
@ -229,13 +227,12 @@ export const LayoutSection = () => {
|
||||
|
||||
const main = page[0];
|
||||
const sidebar = page[1];
|
||||
const pageNumber = pageIndex + 1;
|
||||
|
||||
return (
|
||||
<div key={pageIndex} className="rounded border p-3 pb-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<p className="mb-3 text-xs font-bold">
|
||||
<Trans>Page {pageIndex + 1}</Trans>
|
||||
</p>
|
||||
<p className="mb-3 text-xs font-bold">{t`Page ${pageNumber}`}</p>
|
||||
|
||||
{pageIndex !== 0 && (
|
||||
<Tooltip content={t`Remove Page`}>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const payloadSchema = z.object({
|
||||
id: idSchema,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const configSchema = z.object({
|
||||
NODE_ENV: z.enum(["development", "production"]).default("production"),
|
||||
|
@ -114,7 +114,7 @@ export class ResumeService {
|
||||
title: updateResumeDto.title,
|
||||
slug: updateResumeDto.slug,
|
||||
visibility: updateResumeDto.visibility,
|
||||
data: updateResumeDto.data as unknown as Prisma.JsonObject,
|
||||
data: updateResumeDto.data as Prisma.JsonObject,
|
||||
},
|
||||
where: { userId_id: { userId, id } },
|
||||
});
|
||||
|
@ -12,6 +12,7 @@
|
||||
"@reactive-resume/utils": "*",
|
||||
"@reactive-resume/schema": "*",
|
||||
"nestjs-zod": "^3.0.0",
|
||||
"@swc/helpers": "~0.5.11"
|
||||
"@swc/helpers": "~0.5.11",
|
||||
"zod": "^3.24.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const forgotPasswordSchema = z.object({ email: z.string().email() });
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { usernameSchema } from "../user";
|
||||
|
||||
export const loginSchema = z
|
||||
.object({
|
||||
identifier: z.string().transform((value) => value.toLowerCase()),
|
||||
password: z.password().min(6),
|
||||
password: z.string().min(6),
|
||||
})
|
||||
.refine(
|
||||
(value) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const messageSchema = z.object({ message: z.string() });
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
const authProvidersSchema = z.array(z.enum(["email", "github", "google"]));
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { userSchema } from "../user";
|
||||
|
||||
export const registerSchema = userSchema
|
||||
.pick({ name: true, email: true, username: true, locale: true })
|
||||
.extend({ password: z.password().min(6) });
|
||||
.extend({ password: z.string().min(6) });
|
||||
|
||||
export class RegisterDto extends createZodDto(registerSchema) {}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const resetPasswordSchema = z.object({
|
||||
token: z.string(),
|
||||
password: z.password().min(6),
|
||||
password: z.string().min(6),
|
||||
});
|
||||
|
||||
export class ResetPasswordDto extends createZodDto(resetPasswordSchema) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { userSchema } from "../user";
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const twoFactorSchema = z.object({
|
||||
code: z
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const updatePasswordSchema = z.object({
|
||||
password: z.string().min(6),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const contributorSchema = z.object({
|
||||
id: z.number(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const featureSchema = z.object({
|
||||
isSignupsDisabled: z.boolean().default(false),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { kebabCase } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const createResumeSchema = z.object({
|
||||
title: z.string().min(1),
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const deleteResumeSchema = z.object({
|
||||
id: idSchema,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { resumeDataSchema } from "@reactive-resume/schema";
|
||||
import { kebabCase } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const importResumeSchema = z.object({
|
||||
title: z.string().optional(),
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { defaultResumeData, idSchema, resumeDataSchema } from "@reactive-resume/schema";
|
||||
import { dateSchema } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { userSchema } from "../user";
|
||||
|
||||
@ -13,8 +14,8 @@ export const resumeSchema = z.object({
|
||||
locked: z.boolean().default(false),
|
||||
userId: idSchema,
|
||||
user: userSchema.optional(),
|
||||
createdAt: z.date().or(z.dateString()),
|
||||
updatedAt: z.date().or(z.dateString()),
|
||||
createdAt: dateSchema,
|
||||
updatedAt: dateSchema,
|
||||
});
|
||||
|
||||
export class ResumeDto extends createZodDto(resumeSchema) {}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const urlSchema = z.object({ url: z.string().url() });
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const secretsSchema = z.object({
|
||||
id: idSchema,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
export const statisticsSchema = z.object({
|
||||
views: z.number().int().default(0),
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { idSchema } from "@reactive-resume/schema";
|
||||
import { dateSchema } from "@reactive-resume/utils";
|
||||
import { createZodDto } from "nestjs-zod/dto";
|
||||
import { z } from "nestjs-zod/z";
|
||||
import { z } from "zod";
|
||||
|
||||
import { secretsSchema } from "../secrets";
|
||||
|
||||
@ -26,8 +27,8 @@ export const userSchema = z.object({
|
||||
emailVerified: z.boolean().default(false),
|
||||
twoFactorEnabled: z.boolean().default(false),
|
||||
provider: z.enum(["email", "github", "google"]).default("email"),
|
||||
createdAt: z.date().or(z.dateString()),
|
||||
updatedAt: z.date().or(z.dateString()),
|
||||
createdAt: dateSchema,
|
||||
updatedAt: dateSchema,
|
||||
});
|
||||
|
||||
export class UserDto extends createZodDto(userSchema) {}
|
||||
|
@ -14,6 +14,7 @@
|
||||
"unique-names-generator": "^4.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"tailwind-merge": "^2.3.0",
|
||||
"@swc/helpers": "~0.5.11"
|
||||
"@swc/helpers": "~0.5.11",
|
||||
"zod": "^3.24.1"
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,10 @@
|
||||
import dayjs from "dayjs";
|
||||
import { z } from "zod";
|
||||
|
||||
export const dateSchema = z.union([z.date(), z.string().datetime()]).transform((value) => {
|
||||
if (typeof value === "string") return dayjs(value).toDate();
|
||||
return value;
|
||||
});
|
||||
|
||||
export const sortByDate = <T>(a: T, b: T, key: keyof T, desc = true) => {
|
||||
if (!a[key] || !b[key]) return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user