Skip to content

Commit

Permalink
refactor: fix eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marcalexiei committed Dec 14, 2024
1 parent 7e5d219 commit 00bdec3
Show file tree
Hide file tree
Showing 24 changed files with 115 additions and 111 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const ERROR = 2
/* eslint-enable @typescript-eslint/no-unused-vars */

module.exports = {
reportUnusedDisableDirectives: true,
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
Expand Down Expand Up @@ -42,5 +43,7 @@ module.exports = {
// jsx-ally
"jsx-a11y/no-onchange": WARN,
"import/no-anonymous-default-export": OFF,
// next
"@next/next/no-img-element": OFF,
},
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"devDependencies": {
"@next/bundle-analyzer": "^13.4.5",
"@types/react-helmet": "^6.1.6",
"@types/react": "^18.3.11",
"@typescript-eslint/eslint-plugin": "^5.59.11",
"@typescript-eslint/parser": "^5.59.11",
"cross-env": "^7.0.3",
Expand All @@ -60,7 +61,8 @@
"dev": "next dev",
"format": "prettier . --check",
"format:fix": "prettier . --write",
"lint": "next lint --fix",
"lint": "next lint",
"lint:fix": "next lint --fix",
"now-build": "pnpm run build",
"start": "next start",
"typecheck": "tsc --noEmit",
Expand Down
21 changes: 14 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion src/components/ApiFormState.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { memo } from "react"
import API from "../data/api"
import typographyStyles from "../styles/typography.module.css"
import FormStateTable from "./FormStateTable"
import TabGroup from "./TabGroup"
import CodeArea from "./CodeArea"
import formStateUseEffect from "./codeExamples/formStateUseEffect"
import formStateUseEffectTs from "./codeExamples/formStateUseEffectTs"

function ApiFormState({ api }: { api: any }) {
function ApiFormState({ api }: { api: typeof API }) {
return (
<>
<code className={typographyStyles.codeHeading}>
Expand Down
3 changes: 2 additions & 1 deletion src/components/ApiRefTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { useState } from "react"
import CodeArea from "./CodeArea"
import generic from "../data/generic"
import apiData from "../data/api"
import typographyStyles from "../styles/typography.module.css"
import tableStyles from "../styles/table.module.css"
import styles from "./ApiRefTable.module.css"
import register from "./codeExamples/register"
import registerTs from "./codeExamples/registerTs"

export default function ApiRefTable({ api }: { api: any }) {
export default function ApiRefTable({ api }: { api: typeof apiData }) {
const [isStandard, toggleOption] = useState(true)

return (
Expand Down
10 changes: 5 additions & 5 deletions src/components/BuilderPage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { useState, useRef, useEffect, memo, RefObject } from "react"
import { useRouter } from "next/router"
import { Animate } from "react-simple-animate"
import { useForm } from "react-hook-form"
import SortableContainer from "./SortableContainer"
Expand All @@ -16,10 +18,8 @@ import containerStyles from "../styles/container.module.css"
import typographyStyles from "../styles/typography.module.css"
import CodeArea from "./CodeArea"
import ClipBoard from "./ClipBoard"
import { useState, useRef, useEffect, memo, RefObject } from "react"
import styles from "./BuilderPage.module.css"
import { BeekaiBuilderPage } from "./BeekaiBuilderPage"
import { useRouter } from "next/router"

const errorStyle = {
border: `1px solid ${colors.secondary}`,
Expand Down Expand Up @@ -110,15 +110,15 @@ function BuilderPage({

useEffect(() => {
setValue("toggle", shouldToggleOn)
}, [shouldToggleOn])
}, [setValue, shouldToggleOn])

useEffect(() => {
if (editFormData.type) setValue("type", editFormData.type)
}, [editFormData.type])
}, [editFormData.type, setValue])

useEffect(() => {
setValue("required", editFormData.required)
}, [editIndex])
}, [editFormData.required, editIndex, setValue])

const child = (
<div className={containerStyles.container}>
Expand Down
1 change: 0 additions & 1 deletion src/components/CodeCompareSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { memo } from "react"
import reactHookFormCode from "./codeExamples/reactHookFormCode"
import CodeArea from "./CodeArea"
import { AnimateGroup, Animate } from "react-simple-animate"
import colors from "../styles/colors"
import home from "../data/home"
import typographyStyles from "../styles/typography.module.css"
import containerStyles from "../styles/container.module.css"
Expand Down
8 changes: 4 additions & 4 deletions src/components/DevToolFeaturesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { memo } from "react"
import { AnimateGroup, AnimateKeyframes } from "react-simple-animate"
import home from "../data/home"
import generic from "../data/generic"
import type devToolsContent from "../data/devtools"
import typographyStyles from "../styles/typography.module.css"
import styles from "./DevToolFeaturesList.module.css"
import { AnimateKeyframesProps } from "react-simple-animate/dist/types"
Expand All @@ -18,16 +19,15 @@ const animationKeyFramesProps: AnimateKeyframesProps = {
}

interface Props {
isPlayFeature: boolean
content: any
content: typeof devToolsContent
}

function FeaturesList({ isPlayFeature, content }: Props) {
const FeaturesList = ({ content }: Props) => {
return (
<div className={styles.features}>
<h2 className={typographyStyles.title}>{generic.features}</h2>

<AnimateGroup play={isPlayFeature}>
<AnimateGroup play>
<div className={styles.featuresContent}>
<article>
<AnimateKeyframes {...animationKeyFramesProps} sequenceIndex={0}>
Expand Down
9 changes: 3 additions & 6 deletions src/components/DevTools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CodeArea from "./CodeArea"
import code from "./codeExamples/devTool"
import copyClipBoard from "./utils/copyClipBoard"
import generic from "../data/generic"
import content from "../data/devtools"
import typographyStyles from "../styles/typography.module.css"
import containerStyles from "../styles/container.module.css"
import buttonStyles from "../styles/button.module.css"
Expand All @@ -27,11 +28,7 @@ const DevTool = dynamic<DevtoolUIProps>(
}
)

interface Props {
content: any
}

export default function DevTools({ content }: Props) {
export default function DevTools() {
const methods = useForm({
mode: "onChange",
})
Expand Down Expand Up @@ -68,7 +65,7 @@ export default function DevTools({ content }: Props) {
)}
/>

<DevToolFeaturesList isPlayFeature content={content} />
<DevToolFeaturesList content={content} />

<div className={containerStyles.centerContent}>
<h1 className={typographyStyles.h1}>
Expand Down
7 changes: 4 additions & 3 deletions src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ function Form({
methods,
devTool,
}: {
onSubmit: (data: any) => void
submitData: any
onSubmit: (data: Record<string, unknown>) => void
submitData: Record<string, unknown>
toggleBuilder: (state: boolean) => void
formUpdated: boolean
methods: UseFormReturn<FieldValues, any, undefined>
methods: UseFormReturn<FieldValues, Record<string, unknown>, undefined>
devTool?: boolean
}) {
const { register, handleSubmit, watch, formState, reset } = methods
Expand Down Expand Up @@ -138,6 +138,7 @@ function Form({
JSON.stringify(
Object.entries(errors).reduce(
// @ts-expect-error needed for previous
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(previous, [key, { ref, ...rest }]) => {
previous[key] = rest
return previous
Expand Down
19 changes: 1 addition & 18 deletions src/components/FormStateApi.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import typographyStyles from "../styles/typography.module.css"
import API from "../data/api"
import Link from "next/link"
import { ReactNode } from "react"

export const FormStateApi = ({
api,
columnIndent,
}: {
api?: {
formState: {
isDirty: ReactNode | string
dirtyFields: ReactNode | string
defaultValues: ReactNode | string
touched: ReactNode | string
isSubmitted: ReactNode | string
isSubmitSuccessful: ReactNode | string
isSubmitting: ReactNode | string
submitCount: ReactNode | string
isValid: ReactNode | string
isValidating: ReactNode | string
isLoading: ReactNode | string
validatingFields: ReactNode | string
disabled: ReactNode | string
}
}
api?: Pick<typeof API, "formState">
columnIndent?: boolean
}) => (
<>
Expand Down
3 changes: 2 additions & 1 deletion src/components/FormStateTable.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import generic from "../data/generic"
import API from "../data/api"
import typographyStyles from "../styles/typography.module.css"
import tableStyles from "../styles/table.module.css"
import { FormStateApi } from "./FormStateApi"

export default function FormStateTable({ api }) {
export default function FormStateTable({ api }: { api: typeof API }) {
return (
<>
<h2 className={typographyStyles.subTitle} id="return">
Expand Down
3 changes: 2 additions & 1 deletion src/components/SortableContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Sortable from "react-sortablejs"
import { Animate } from "react-simple-animate"
import type { GlobalState } from "little-state-machine"
import colors from "../styles/colors"
import generic from "../data/generic"
import originalFormData from "../state/formData"
Expand All @@ -14,7 +15,7 @@ export default function SortableContainer({
reset,
}: {
updateFormData: (data: object) => void
formData: any
formData: GlobalState["formData"]
editIndex: number
setEditIndex: (payload: number) => void
setFormData: (payload: object) => void
Expand Down
3 changes: 1 addition & 2 deletions src/components/UseController.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import api from "../data/api"
import typographyStyles from "../styles/typography.module.css"
import Footer from "./Footer"
import containerStyles from "../styles/container.module.css"
Expand All @@ -21,7 +20,7 @@ export default function UseController() {

<main>
<section>
<UseControllerContent api={api} />
<UseControllerContent />

<StarRepo />
</section>
Expand Down
5 changes: 3 additions & 2 deletions src/components/UseControllerContent.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import CodeArea from "./CodeArea"
import api from "../data/api"
import generic from "../data/generic"
import CodeArea from "./CodeArea"
import useController from "./codeExamples/useController"
import useControllerTs from "./codeExamples/useControllerTs"
import tableStyles from "../styles/table.module.css"
Expand All @@ -9,7 +10,7 @@ import TabGroup from "./TabGroup"
import useControllerCheckboxes from "./codeExamples/useControllerCheckboxes"
import { SelectNav } from "./selectNav"

export default function UseControllerContent({ api }: { api: any }) {
export default function UseControllerContent() {
return (
<>
<SelectNav
Expand Down
8 changes: 4 additions & 4 deletions src/components/UseControllerMethods.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ const UseControllerMethods = ({
<td>
<code>name</code>
</td>
<tr>
<td>
<code className={typographyStyles.typeText}>string</code>
</tr>
</td>
<td>
<p>Input's name being registered.</p>
</td>
Expand All @@ -137,9 +137,9 @@ const UseControllerMethods = ({
<td>
<code>ref</code>
</td>
<tr>
<td>
<code className={typographyStyles.typeText}>React.Ref</code>
</tr>
</td>
<td>
<p>
A ref used to connect hook form to the input. Assign{" "}
Expand Down
3 changes: 1 addition & 2 deletions src/components/UseFieldArray.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import api from "../data/api"
import typographyStyles from "../styles/typography.module.css"
import Footer from "./Footer"
import containerStyles from "../styles/container.module.css"
Expand All @@ -19,7 +18,7 @@ export default function UseFieldArray() {

<main>
<section>
<UseFieldArrayContent api={api} />
<UseFieldArrayContent />

<StarRepo />
</section>
Expand Down
Loading

0 comments on commit 00bdec3

Please sign in to comment.