Skip to content

Commit

Permalink
Add eslint-plugin-react-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikzogg committed Mar 15, 2024
1 parent 6d603fc commit 2518600
Show file tree
Hide file tree
Showing 9 changed files with 183 additions and 148 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'plugin:import/typescript',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:tailwindcss/recommended',
],
overrides: [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-react": "^7.34.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-tailwindcss": "^3.14.3",
"jsdom": "^24.0.0",
"prettier": "^2.8.8",
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion src/component/form/pet-filters-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const PetFiltersForm: FC<PetFiltersFormProps> = ({

useEffect(() => {
setPetFilters(initialPetFilters);
}, [initialPetFilters]);
}, [initialPetFilters, setPetFilters]);

return (
<form
Expand Down
2 changes: 1 addition & 1 deletion src/component/form/pet-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const PetForm: FC<PetFormProps> = ({ submitPet, initialPet, httpError }:
if (initialPet) {
setPet(initialPet);
}
}, [initialPet]);
}, [initialPet, setPet]);

return (
<form
Expand Down
25 changes: 13 additions & 12 deletions src/component/page/pet/list.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { FC } from 'react';
import { useEffect, useMemo } from 'react';
import { useCallback, useEffect, useMemo } from 'react';
import { de } from 'date-fns/locale';
import { format } from 'date-fns';
import { useNavigate, useLocation } from 'react-router-dom';
Expand Down Expand Up @@ -42,18 +42,19 @@ const List: FC = () => {

const query = useMemo(() => querySchema.parse(qs.parse(location.search.substring(1))), [location]);

const petListRequest: PetListRequest = {
offset: query.page * limit - limit,
limit,
filters: query.filters,
sort: query.sort,
};

const queryString = qs.stringify(petListRequest);
const petListRequest: PetListRequest = useMemo(
() => ({
offset: query.page * limit - limit,
limit,
filters: query.filters,
sort: query.sort,
}),
[query.filters, query.page, query.sort],
);

const fetchPetList = async () => {
const fetchPetList = useCallback(async () => {
actions.listModel(petListRequest);
};
}, [actions, petListRequest]);

const deletePet = async (id: string) => {
if (await actions.deleteModel(id)) {
Expand All @@ -77,7 +78,7 @@ const List: FC = () => {
document.title = pageTitle;

fetchPetList();
}, [queryString]);
}, [fetchPetList]);

if (!petList && !httpError) {
return <div></div>;
Expand Down
2 changes: 1 addition & 1 deletion src/component/page/pet/read.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const Read: FC = () => {
document.title = pageTitle;

actions.readModel(id);
}, [id]);
}, [actions, id]);

if (!pet && !httpError) {
return <div></div>;
Expand Down
2 changes: 1 addition & 1 deletion src/component/page/pet/update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const Update: FC = () => {
document.title = pageTitle;

actions.readModel(id);
}, [id]);
}, [actions, id]);

if (!pet && !httpError) {
return <div></div>;
Expand Down
Loading

0 comments on commit 2518600

Please sign in to comment.