Skip to content

Commit

Permalink
added the eslint with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Kashyap1ankit committed Nov 17, 2024
1 parent 2dc0afa commit 6699bcd
Show file tree
Hide file tree
Showing 31 changed files with 562 additions and 195 deletions.
111 changes: 110 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,112 @@
{
"extends": "next/core-web-vitals"
"parser": "@typescript-eslint/parser",

"plugins": ["@typescript-eslint", "prettier"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"strict": 0,
"no-underscore-dangle": 0,
"no-mixed-requires": 0,
"no-process-exit": 0,
"no-warning-comments": 0,
"no-use-before-define": 0,
"curly": 0,
"no-multi-spaces": 0,
"no-alert": 0,
"consistent-return": 0,
"consistent-this": [0, "self"],
"func-style": 0,
"max-nested-callbacks": 0,
"camelcase": 0,
"no-dupe-class-members": 0,
"no-debugger": 1,
"no-empty": 1,
"no-invalid-regexp": 1,
"no-unused-expressions": 1,
"no-native-reassign": 1,
"no-fallthrough": 1,
"eqeqeq": 2,
"no-undef": 0,
"no-dupe-keys": 2,
"no-empty-character-class": 2,
"no-self-compare": 2,
"valid-typeof": 2,
"handle-callback-err": 2,
"no-shadow-restricted-names": 2,
"no-new-require": 2,
"no-mixed-spaces-and-tabs": 2,
"block-scoped-var": 2,
"no-else-return": 2,
"no-throw-literal": 2,
"no-void": 2,
"radix": 2,
"wrap-iife": [2, "outside"],
"no-shadow": 0,
"no-path-concat": 2,
"valid-jsdoc": [
0,
{
"requireReturn": false,
"requireParamDescription": false,
"requireReturnDescription": false
}
],
"no-spaced-func": 2,
"semi-spacing": 2,
"key-spacing": [2, { "beforeColon": false, "afterColon": true }],
"no-lonely-if": 2,
"no-floating-decimal": 2,
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"comma-style": [2, "last"],
"no-multiple-empty-lines": [2, { "max": 1 }],
"no-nested-ternary": 2,
"operator-assignment": [2, "always"],
"padded-blocks": [2, "never"],
"quote-props": [2, "as-needed"],
"keyword-spacing": [2, { "before": true, "after": true, "overrides": {} }],
"space-before-blocks": [2, "always"],
"array-bracket-spacing": [2, "never"],
"computed-property-spacing": [2, "never"],
"space-in-parens": [2, "never"],
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"wrap-regex": 2,
"linebreak-style": 0,
"semi": [2, "always"],
"arrow-spacing": [2, { "before": true, "after": true }],
"no-class-assign": 2,
"no-const-assign": 2,
"no-this-before-super": 2,
"no-var": 2,
"object-shorthand": [2, "always"],
"prefer-arrow-callback": 2,
"prefer-const": 2,
"prefer-spread": 2,
"prefer-template": 2,
"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-use-before-define": ["off"],
"@typescript-eslint/no-empty-function": "off",
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-unnecessary-type-constraint": "off",
"@typescript-eslint/ban-types": "off"
},
"overrides": [
{
"files": ["test/**", "*.spec.ts", "*.test.ts"],
"rules": {
"prefer-arrow-callback": 0,
"@typescript-eslint/no-non-null-assertion": 0,
"@typescript-eslint/no-unused-vars": 0
}
}
]
}
5 changes: 3 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
npx prettier . --check
npx prettier . --write
npm run format:check
npm run format:fix
npm run lint
git add .
4 changes: 3 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
build
coverage
coverage
dist
.next
14 changes: 7 additions & 7 deletions app/actions/posts/bookmark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export async function HandleBookmakrClick(userId: string, postId: string) {

const checkForBookmark = await prisma.bookmark.findFirst({
where: {
postId: postId,
userId: userId,
postId,
userId,
},
});

Expand All @@ -34,8 +34,8 @@ export async function HandleBookmakrClick(userId: string, postId: string) {

const createNewBookmark = await prisma.bookmark.create({
data: {
postId: postId,
userId: userId,
postId,
userId,
},
});

Expand Down Expand Up @@ -63,8 +63,8 @@ export async function CheckForBookmark(userId: string, postId: string) {

const checkForBookmark = await prisma.bookmark.findFirst({
where: {
postId: postId,
userId: userId,
postId,
userId,
},
});

Expand Down Expand Up @@ -92,7 +92,7 @@ export async function GetBookmarkByUserId(userId: string) {

const getUserBookmarks = await prisma.bookmark.findMany({
where: {
userId: userId,
userId,
},

select: {
Expand Down
7 changes: 5 additions & 2 deletions app/actions/posts/cron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function deleteExpiredJobs() {
},
});

for (let job of allJobs) {
for (const job of allJobs) {
const diff = Math.floor(calculateDayDiff(job.createdAt));

if (diff >= 7) {
Expand All @@ -26,7 +26,10 @@ async function deleteExpiredJobs() {
}
}
} catch (error) {
console.log(error);
return {
status: 400,
message: (error as Error).message,
};
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/actions/posts/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export async function GetPostByAuthorId(authorId: string) {

const getPost = await prisma.post.findMany({
where: {
authorId: authorId,
authorId,
},

select: {
Expand Down Expand Up @@ -175,7 +175,7 @@ export async function DestroyPost(postId: string, authorId: string) {
const isUserAuthor = await prisma.post.findFirst({
where: {
id: postId,
authorId: authorId,
authorId,
},
});

Expand Down Expand Up @@ -255,7 +255,7 @@ export async function UploadImage(data: FormData) {
} catch (error) {
return {
status: 200,
message: "File unot ploaded",
message: (error as Error).message,
public_id: null,
secure_url: null,
};
Expand Down
2 changes: 1 addition & 1 deletion app/actions/users/checkUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export async function GetAllUserAdmin(userId: string) {
} catch (error) {
return {
status: 404,
message: "Users fetched",
message: (error as Error).message,
data: [],
};
}
Expand Down
10 changes: 5 additions & 5 deletions app/actions/users/updateUserInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ export async function UpdateUserInfo(

const updatedUser = await prisma.user.update({
where: {
id: id,
id,
},
data: {
bio: bio,
instagram_url: instagram_url,
linkedin_url: linkedin_url,
twitter_url: twitter_url,
bio,
instagram_url,
linkedin_url,
twitter_url,
},
});

Expand Down
2 changes: 1 addition & 1 deletion app/api/jobs/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import prisma from "@/db";
import { NextRequest, NextResponse } from "next/server";

export async function POST(req: NextRequest, res: NextResponse) {
export async function POST(req: NextRequest) {
try {
const { experience, job, location } = await req.json();

Expand Down
2 changes: 2 additions & 0 deletions components/Admin/Users/DeleteModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function DeleteUserAdminModal({ userId }: { userId: string }) {

const [modalOpen, setModalOpen] = useState(false);
const [loading, setLoading] = useState(false);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [_, setError] = useState({
status: false,
message: "",
Expand All @@ -34,6 +35,7 @@ export default function DeleteUserAdminModal({ userId }: { userId: string }) {
if (response.status !== 201) throw new Error(response.message);
setModalOpen(false);
} catch (error) {
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
setError({
status: true,
message: (error as Error).message,
Expand Down
2 changes: 1 addition & 1 deletion components/Auth/Signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function SigninForm() {
window.location.href = res?.url || "/jobs";
}
} catch (error) {
toast("Username / Password mismatched");
toast((error as Error).message);
} finally {
setSubmitting(false);
reset();
Expand Down
2 changes: 0 additions & 2 deletions components/Auth/Signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
EyeOff,
Lock,
Mail,
X,
} from "lucide-react";
import { CreateUser } from "@/app/actions/users/signup";
import Link from "next/link";
Expand All @@ -29,7 +28,6 @@ import TextDivider from "../ui/text-divider";
import { FcGoogle } from "react-icons/fc";

export default function SignupForm() {
const [items, setItems] = useState<string[] | undefined>([]);
const router = useRouter();
const [currentIndex, setCurrentIndex] = useState(0);
const {
Expand Down
2 changes: 1 addition & 1 deletion components/Job/Create/CreateForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function CreateForm() {
const [logo, setLogo] = useState<File | null>(null);

async function handleLogoChange(e: ChangeEvent<HTMLInputElement>) {
let selectedFile = e.target.files ? e.target.files[0] : null;
const selectedFile = e.target.files ? e.target.files[0] : null;
if (selectedFile === undefined) return; //if user opens the model to select the file but came back without choosing an thing so holding prev val
setLogo(selectedFile);
}
Expand Down
2 changes: 1 addition & 1 deletion components/Job/Create/TipTap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const Tiptap = ({ className, name, setValue, edit, content }: any) => {
setValue(name, value, { shouldValidate: true });
}
},
content: content,
content,
});

//setting the default color to white
Expand Down
11 changes: 2 additions & 9 deletions components/Job/JobSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,9 @@ import {
} from "@/components/ui/sheet";
import { JobLisitingType } from "@/types/types";
import { fraunces, poppins, roboto_slab } from "@/utils/fonts/font";
import {
BadgeIndianRupee,
BriefcaseBusiness,
Code,
Pin,
X,
} from "lucide-react";
import { BriefcaseBusiness, Pin, X } from "lucide-react";
import { useState } from "react";
import { TbClick, TbHandClick } from "react-icons/tb";
import { TbHandClick } from "react-icons/tb";
import Tiptap from "./Create/TipTap";
import { Button } from "../ui/button";
import Link from "next/link";
Expand All @@ -42,7 +36,6 @@ export default function JobSheetComp({
salary_max,
experience_level,
apply_link,
createdAt,
}: JobLisitingType) {
const [applySheet, setApplySheet] = useState(false);
return (
Expand Down
4 changes: 1 addition & 3 deletions components/Job/MoreDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { toast } from "sonner";
import { allJobListings, bookmarkedPosts } from "@/store/store";
import { useRecoilState, useSetRecoilState } from "recoil";
import { DestroyPost } from "@/app/actions/posts/jobs";
import { useRouter } from "next/navigation";

export function BookmarkPostComp({ postId }: { postId: string }) {
const [bookmarked, setBookmarked] = useRecoilState(bookmarkedPosts(postId));
Expand Down Expand Up @@ -40,7 +39,7 @@ export function BookmarkPostComp({ postId }: { postId: string }) {
const response = await CheckForBookmark(session.data?.user?.id, postId);
if (response.status !== 200) throw new Error(response.message);
setBookmarked(true);
} catch (error) {
} catch {
setBookmarked(false);
}
};
Expand Down Expand Up @@ -71,7 +70,6 @@ export function DeletePostComp({
authorId: string;
}) {
const session: any = useSession();
const router = useRouter();
const setAllJobs = useSetRecoilState(allJobListings);

async function handlePostDelete() {
Expand Down
2 changes: 1 addition & 1 deletion components/Job/filterCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function FilterSideBar() {
if (finalData.status !== 200) throw new Error(finalData.message);
setError(false);
setAllJobs(finalData.data);
} catch (error) {
} catch {
setError(true);
} finally {
setLoading(false);
Expand Down
Loading

0 comments on commit 6699bcd

Please sign in to comment.