From 147f7242aaa82324028ff38c49bd6e3283bdfd8a Mon Sep 17 00:00:00 2001 From: RizqiSyahrendra Date: Wed, 5 Feb 2025 17:43:24 +0700 Subject: [PATCH] fix: tsc and lint check --- src/app/(main)/blog/[slug]/page.tsx | 3 - .../Blocks/Form/RichText/nodeFormat.tsx | 114 ++++++++---------- .../Blocks/Form/RichText/serialize.tsx | 1 - src/components/Blocks/Form/index.tsx | 4 +- src/components/Blogs/BlogWidget.tsx | 5 +- src/components/Header.tsx | 4 +- src/utils/addScroll.ts | 2 +- src/utils/toKebabCase.ts | 10 +- 8 files changed, 63 insertions(+), 80 deletions(-) diff --git a/src/app/(main)/blog/[slug]/page.tsx b/src/app/(main)/blog/[slug]/page.tsx index c49f7fc..880a761 100644 --- a/src/app/(main)/blog/[slug]/page.tsx +++ b/src/app/(main)/blog/[slug]/page.tsx @@ -1,6 +1,3 @@ -import BlogComments from "@/components/Blogs/BlogComments"; -import BlogWidget from "@/components/Blogs/BlogWidget"; -import CommentForm from "@/components/CommentForm"; import { fetchBlogDetail } from "@/services/payload/blog"; import { RichText } from "@payloadcms/richtext-lexical/react"; import { Metadata } from "next"; diff --git a/src/components/Blocks/Form/RichText/nodeFormat.tsx b/src/components/Blocks/Form/RichText/nodeFormat.tsx index e5579fb..7a3b416 100644 --- a/src/components/Blocks/Form/RichText/nodeFormat.tsx +++ b/src/components/Blocks/Form/RichText/nodeFormat.tsx @@ -1,8 +1,8 @@ // @ts-nocheck //This copy-and-pasted from lexical here here: https://github.com/facebook/lexical/blob/c2ceee223f46543d12c574e62155e619f9a18a5d/packages/lexical/src/LexicalConstants.ts -import type { ElementFormatType, TextFormatType } from '@payloadcms/richtext-lexical/lexical' -import type { TextDetailType, TextModeType } from 'lexical/nodes/LexicalTextNode' +import type { ElementFormatType, TextFormatType } from "@payloadcms/richtext-lexical/lexical"; +import type { TextDetailType, TextModeType } from "lexical/nodes/LexicalTextNode"; /** * Copyright (c) Meta Platforms, Inc. and affiliates. @@ -13,71 +13,63 @@ import type { TextDetailType, TextModeType } from 'lexical/nodes/LexicalTextNode */ // DOM -export const DOM_ELEMENT_TYPE = 1 -export const DOM_TEXT_TYPE = 3 +export const DOM_ELEMENT_TYPE = 1; +export const DOM_TEXT_TYPE = 3; // Reconciling -export const NO_DIRTY_NODES = 0 -export const HAS_DIRTY_NODES = 1 -export const FULL_RECONCILE = 2 +export const NO_DIRTY_NODES = 0; +export const HAS_DIRTY_NODES = 1; +export const FULL_RECONCILE = 2; // Text node modes -export const IS_NORMAL = 0 -export const IS_TOKEN = 1 -export const IS_SEGMENTED = 2 +export const IS_NORMAL = 0; +export const IS_TOKEN = 1; +export const IS_SEGMENTED = 2; // IS_INERT = 3 // Text node formatting -export const IS_BOLD = 1 -export const IS_ITALIC = 1 << 1 -export const IS_STRIKETHROUGH = 1 << 2 -export const IS_UNDERLINE = 1 << 3 -export const IS_CODE = 1 << 4 -export const IS_SUBSCRIPT = 1 << 5 -export const IS_SUPERSCRIPT = 1 << 6 -export const IS_HIGHLIGHT = 1 << 7 +export const IS_BOLD = 1; +export const IS_ITALIC = 1 << 1; +export const IS_STRIKETHROUGH = 1 << 2; +export const IS_UNDERLINE = 1 << 3; +export const IS_CODE = 1 << 4; +export const IS_SUBSCRIPT = 1 << 5; +export const IS_SUPERSCRIPT = 1 << 6; +export const IS_HIGHLIGHT = 1 << 7; export const IS_ALL_FORMATTING = - IS_BOLD | - IS_ITALIC | - IS_STRIKETHROUGH | - IS_UNDERLINE | - IS_CODE | - IS_SUBSCRIPT | - IS_SUPERSCRIPT | - IS_HIGHLIGHT + IS_BOLD | IS_ITALIC | IS_STRIKETHROUGH | IS_UNDERLINE | IS_CODE | IS_SUBSCRIPT | IS_SUPERSCRIPT | IS_HIGHLIGHT; // Text node details -export const IS_DIRECTIONLESS = 1 -export const IS_UNMERGEABLE = 1 << 1 +export const IS_DIRECTIONLESS = 1; +export const IS_UNMERGEABLE = 1 << 1; // Element node formatting -export const IS_ALIGN_LEFT = 1 -export const IS_ALIGN_CENTER = 2 -export const IS_ALIGN_RIGHT = 3 -export const IS_ALIGN_JUSTIFY = 4 -export const IS_ALIGN_START = 5 -export const IS_ALIGN_END = 6 +export const IS_ALIGN_LEFT = 1; +export const IS_ALIGN_CENTER = 2; +export const IS_ALIGN_RIGHT = 3; +export const IS_ALIGN_JUSTIFY = 4; +export const IS_ALIGN_START = 5; +export const IS_ALIGN_END = 6; // Reconciliation -export const NON_BREAKING_SPACE = '\u00A0' -const ZERO_WIDTH_SPACE = '\u200b' +export const NON_BREAKING_SPACE = "\u00A0"; +// const ZERO_WIDTH_SPACE = '\u200b' -export const DOUBLE_LINE_BREAK = '\n\n' +export const DOUBLE_LINE_BREAK = "\n\n"; // For FF, we need to use a non-breaking space, or it gets composition // in a stuck state. -const RTL = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC' +const RTL = "\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC"; const LTR = - 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6' + - '\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C' + - '\uFE00-\uFE6F\uFEFD-\uFFFF' + "A-Za-z\u00C0-\u00D6\u00D8-\u00F6" + + "\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u200E\u2C00-\uFB1C" + + "\uFE00-\uFE6F\uFEFD-\uFFFF"; -// eslint-disable-next-line -export const RTL_REGEX = new RegExp('^[^' + LTR + ']*[' + RTL + ']') -// eslint-disable-next-line -export const LTR_REGEX = new RegExp('^[^' + RTL + ']*[' + LTR + ']') +export const RTL_REGEX = new RegExp("^[^" + LTR + "]*[" + RTL + "]"); + +export const LTR_REGEX = new RegExp("^[^" + RTL + "]*[" + LTR + "]"); export const TEXT_TYPE_TO_FORMAT: Record = { bold: IS_BOLD, @@ -88,39 +80,39 @@ export const TEXT_TYPE_TO_FORMAT: Record = { subscript: IS_SUBSCRIPT, superscript: IS_SUPERSCRIPT, underline: IS_UNDERLINE, -} +}; export const DETAIL_TYPE_TO_DETAIL: Record = { directionless: IS_DIRECTIONLESS, unmergeable: IS_UNMERGEABLE, -} +}; -export const ELEMENT_TYPE_TO_FORMAT: Record, number> = { +export const ELEMENT_TYPE_TO_FORMAT: Record, number> = { center: IS_ALIGN_CENTER, end: IS_ALIGN_END, justify: IS_ALIGN_JUSTIFY, left: IS_ALIGN_LEFT, right: IS_ALIGN_RIGHT, start: IS_ALIGN_START, -} +}; export const ELEMENT_FORMAT_TO_TYPE: Record = { - [IS_ALIGN_CENTER]: 'center', - [IS_ALIGN_END]: 'end', - [IS_ALIGN_JUSTIFY]: 'justify', - [IS_ALIGN_LEFT]: 'left', - [IS_ALIGN_RIGHT]: 'right', - [IS_ALIGN_START]: 'start', -} + [IS_ALIGN_CENTER]: "center", + [IS_ALIGN_END]: "end", + [IS_ALIGN_JUSTIFY]: "justify", + [IS_ALIGN_LEFT]: "left", + [IS_ALIGN_RIGHT]: "right", + [IS_ALIGN_START]: "start", +}; export const TEXT_MODE_TO_TYPE: Record = { normal: IS_NORMAL, segmented: IS_SEGMENTED, token: IS_TOKEN, -} +}; export const TEXT_TYPE_TO_MODE: Record = { - [IS_NORMAL]: 'normal', - [IS_SEGMENTED]: 'segmented', - [IS_TOKEN]: 'token', -} + [IS_NORMAL]: "normal", + [IS_SEGMENTED]: "segmented", + [IS_TOKEN]: "token", +}; diff --git a/src/components/Blocks/Form/RichText/serialize.tsx b/src/components/Blocks/Form/RichText/serialize.tsx index a5de3d7..0152ec8 100644 --- a/src/components/Blocks/Form/RichText/serialize.tsx +++ b/src/components/Blocks/Form/RichText/serialize.tsx @@ -142,7 +142,6 @@ export function serializeLexical({ nodes }: Props): JSX.Element { aria-checked={node.checked ? "true" : "false"} className={` ${node.checked ? "" : ""}`} key={index} - // eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role role="checkbox" tabIndex={-1} value={node?.value} diff --git a/src/components/Blocks/Form/index.tsx b/src/components/Blocks/Form/index.tsx index 16fca54..fa2195d 100644 --- a/src/components/Blocks/Form/index.tsx +++ b/src/components/Blocks/Form/index.tsx @@ -51,10 +51,10 @@ export const FormBlock: React.FC< const { control, formState: { errors }, - getValues, handleSubmit, register, - setValue, + // getValues, + // setValue, } = formMethods; const [isLoading, setIsLoading] = useState(false); diff --git a/src/components/Blogs/BlogWidget.tsx b/src/components/Blogs/BlogWidget.tsx index 53d2bfa..ef09513 100644 --- a/src/components/Blogs/BlogWidget.tsx +++ b/src/components/Blogs/BlogWidget.tsx @@ -4,10 +4,7 @@ import { categories } from "@/data/categories"; import { tags } from "@/data/tags"; import React from "react"; -export default function BlogWidget({ - btnClass = "btn btn-mod btn-color btn-medium btn-round btn-hover-anim form-control", - inputClass = "newsletter-field form-control input-md round mb-10", -}) { +export default function BlogWidget() { return ( <>
diff --git a/src/components/Header.tsx b/src/components/Header.tsx index 5ece90f..1271d9c 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,10 +1,8 @@ "use client"; +import Nav2 from "@/components/Nav"; import { toggleMobileMenu } from "@/utils/toggleMobileMenu"; import Image from "next/image"; import Link from "next/link"; -import React from "react"; -import Nav2 from "@/components/Nav"; -import LanguageSelect from "@/components/LanguageSelect"; export default function Header1Multipage({ links }: any) { return ( diff --git a/src/utils/addScroll.ts b/src/utils/addScroll.ts index ad14256..32257af 100644 --- a/src/utils/addScroll.ts +++ b/src/utils/addScroll.ts @@ -2,7 +2,7 @@ const addScrollspy = (defalutClass = "", linksContainer = ".scrollspy-link", act const section = document.querySelectorAll(".scrollSpysection"); const sections = {}; - const i = 0; + // const i = 0; Array.prototype.forEach.call(section, function (e) { // @ts-ignore diff --git a/src/utils/toKebabCase.ts b/src/utils/toKebabCase.ts index de45cfb..4b29d1d 100644 --- a/src/utils/toKebabCase.ts +++ b/src/utils/toKebabCase.ts @@ -1,5 +1,5 @@ -export const toKebabCase = (string) => - string - ?.replace(/([a-z])([A-Z])/g, '$1-$2') - .replace(/\s+/g, '-') - .toLowerCase() +export const toKebabCase = (text: string) => + text + ?.replace(/([a-z])([A-Z])/g, "$1-$2") + .replace(/\s+/g, "-") + .toLowerCase();