Skip to content

Commit

Permalink
Use Biome unused imports and top-level hooks rules (#1626)
Browse files Browse the repository at this point in the history
* Use unused import and top-level hooks rule

* Remove unused imports

* Remove enabled argument from UserFeedback (fixes top-level hooks error)

It's also better to disable the component by just not rendering it,
instead of dealing with enabled state.
  • Loading branch information
robines authored Dec 16, 2024
1 parent f6f38b8 commit 5cd8ee9
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 19 deletions.
6 changes: 5 additions & 1 deletion biome.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@
"linter": {
"enabled": true,
"rules": {
"recommended": true
"recommended": true,
"correctness": {
"noUnusedImports": "error",
"useHookAtTopLevel": "error"
}
}
},
"formatter": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function App() {

return (
<HelmetProvider>
<UserFeedback enabled={true} />
<UserFeedback />
{goatCounterCode && (
<Helmet>
{/* Helmet is linked to <head>. Used to add scripts. */}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/DatePicker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Icon } from '@iconify/react';
import classNames from 'classnames';
import { format } from 'date-fns';
import React, { forwardRef, useMemo } from 'react';
import { forwardRef, useMemo } from 'react';
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { MiniCalendar } from '~/Components';
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/Dropdown/Dropdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentMeta, ComponentStory, Meta, StoryObj } from '@storybook/react';
import type { Meta, StoryObj } from '@storybook/react';
import { Dropdown } from './Dropdown';

// Local component config.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { useTranslation } from 'react-i18next';
import { InputField, TimeDisplay } from '~/Components';
import { TimeDisplay } from '~/Components';
import { CrudButtons } from '~/Components/CrudButtons/CrudButtons';
import { Dropdown, type DropdownOption } from '~/Components/Dropdown/Dropdown';
import { Table } from '~/Components/Table';
import { Text } from '~/Components/Text/Text';
import { putRecruitmentApplicationForGang } from '~/api';
import type { RecruitmentApplicationDto, RecruitmentApplicationStateDto } from '~/dto';
import { useCustomNavigate } from '~/hooks';
import { KEY } from '~/i18n/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
} as ComponentMeta<typeof UserFeedback>;

const Template: ComponentStory<typeof UserFeedback> = () => {
return <UserFeedback enabled={true} />;
return <UserFeedback />;
};

export const Primary = Template.bind({});
10 changes: 1 addition & 9 deletions frontend/src/Components/UserFeedback/UserFeedback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,15 @@ import { useTextItem } from '~/hooks';
import { KEY } from '~/i18n/constants';
import styles from './UserFeedback.module.scss';

type UserFeedbackProps = {
enabled: boolean;
};

type FormProps = {
text: string;
contact_email?: string;
};

export function UserFeedback({ enabled }: UserFeedbackProps) {
export function UserFeedback() {
const { t } = useTranslation();
const [isOpen, setIsOpen] = useState(false);

if (!enabled) {
return <div />;
}

const handleFormSubmit = (formData: FormProps) => {
postFeedback({
...formData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
import { toast } from 'react-toastify';
import { getRecruitmentSharedInterviewGroups, getRecruitmentStats } from '~/api';
import type { RecruitmentSharedInterviewGroupDto, RecruitmentStatsDto } from '~/dto';
import { getRecruitmentSharedInterviewGroups } from '~/api';
import type { RecruitmentSharedInterviewGroupDto } from '~/dto';
import { KEY } from '~/i18n/constants';
import styles from './RecruitmentInterviewGroupsList.module.scss';
import { RecruitmentInterviewGroupComponent } from './components/RecruitmentInterviewGroupComponent/RecruitmentInterviewGroupComponent';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExpandableHeader, Table } from '~/Components';
import type { RecruitmentSharedInterviewGroupDto, RecruitmentStatsDto } from '~/dto';
import type { RecruitmentSharedInterviewGroupDto } from '~/dto';
import { dbT } from '~/utils';
import styles from './RecruitmentInterviewGroupComponent.module.scss';

Expand Down

0 comments on commit 5cd8ee9

Please sign in to comment.