Fix warnings

Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
Émile Ré
2025-12-03 19:04:21 +04:00
parent 86ec5c5a3e
commit 44336c2a35
19 changed files with 48 additions and 51 deletions

View File

@@ -4,7 +4,6 @@ import js from "@eslint/js";
import { defineConfig } from "eslint/config";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
export default defineConfig([
@@ -21,14 +20,9 @@ export default defineConfig([
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
]);

View File

@@ -45,7 +45,6 @@
"babel-plugin-relay": "^19.0.0",
"eslint": "^9.25.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"graphql": "^16.11.0",
"prettier": "^3.5.3",

View File

@@ -103,7 +103,7 @@ function LinkedAuditsDialogContent(props: Omit<Props, "children">) {
);
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const audits = data.audits?.edges?.map((edge) => edge.node) ?? [];
const audits = useMemo(() => data.audits?.edges?.map((edge) => edge.node) ?? [], [data.audits]);
const linkedIds = useMemo(() => {
return new Set(props.linkedAudits?.map((a) => a.id) ?? []);
}, [props.linkedAudits]);

View File

@@ -97,7 +97,7 @@ function LinkedDocumentsDialogContent(props: Omit<Props, "children">) {
);
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const documents = data.documents?.edges?.map((edge) => edge.node) ?? [];
const documents = useMemo(() => data.documents?.edges?.map((edge) => edge.node) ?? [], [data.documents]);
const linkedIds = useMemo(() => {
return new Set(props.linkedDocuments?.map((m) => m.id) ?? []);
}, [props.linkedDocuments]);

View File

@@ -49,7 +49,7 @@ function LinkedMeasuresDialogContent(props: Omit<Props, "children">) {
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const [category, setCategory] = useState<string | null>(null);
const measures = data.measures?.edges?.map((edge) => edge.node) ?? [];
const measures = useMemo(() => data.measures?.edges?.map((edge) => edge.node) ?? [], [data.measures]);
const linkedIds = useMemo(() => {
return new Set(props.linkedMeasures?.map((m) => m.id) ?? []);
}, [props.linkedMeasures]);

View File

@@ -103,7 +103,7 @@ function LinkedObligationsDialogContent(props: Omit<Props, "children">) {
);
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const obligations = data.obligations?.edges?.map((edge) => edge.node) ?? [];
const obligations = useMemo(() => data.obligations?.edges?.map((edge) => edge.node) ?? [], [data.obligations]);
const linkedIds = useMemo(() => {
return new Set(props.linkedObligations?.map((o) => o.id) ?? []);
}, [props.linkedObligations]);

View File

@@ -73,7 +73,7 @@ function LinkedRisksDialogContent(props: Omit<Props, "children">) {
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const [category, setCategory] = useState<string | null>(null);
const risks = data.organization?.risks?.edges?.map((edge) => edge.node) ?? [];
const risks = useMemo(() => data.organization?.risks?.edges?.map((edge) => edge.node) ?? [], [data.organization?.risks]);
const linkedIds = useMemo(() => {
return new Set(props.linkedRisks?.map((r) => r.id) ?? []);
}, [props.linkedRisks]);

View File

@@ -102,7 +102,7 @@ function LinkedSnapshotsDialogContent(props: Omit<Props, "children">) {
const { __ } = useTranslate();
const [search, setSearch] = useState("");
const snapshots = data.snapshots?.edges?.map((edge) => edge.node) ?? [];
const snapshots = useMemo(() => data.snapshots?.edges?.map((edge) => edge.node) ?? [], [data.snapshots]);
const linkedIds = useMemo(() => {
return new Set(props.linkedSnapshots?.map((s) => s.id) ?? []);
}, [props.linkedSnapshots]);

View File

@@ -73,7 +73,7 @@ export const useDeleteFrameworkMutation = (
}
);
},
[framework, connectionId, commitDelete]
[framework, connectionId, commitDelete, confirm, __]
);
};

View File

@@ -68,7 +68,7 @@ export function useMutationWithToasts<T extends MutationParameters>(
})
);
},
[mutate, toast, __]
[mutate, toast, __, baseOptions]
);
return [mutateWithToast, isLoading] as const;

View File

@@ -120,10 +120,11 @@ function SignatureList(props: {
version: Version;
selectedStates: SignatureState[];
}) {
const { version: propVersion, selectedStates } = props;
const [version, refetch] = useRefetchableFragment<
DocumentSignaturesTabRefetchQuery,
DocumentSignaturesTab_version$key
>(versionFragment, props.version);
>(versionFragment, propVersion);
const signatures = version.signatures?.edges?.map((edge) => edge.node) ?? [];
const { __ } = useTranslate();
const signatureMap = new Map(signatures.map((s) => [s.signedBy.id, s]));
@@ -140,10 +141,10 @@ function SignatureList(props: {
}
const filter =
props.selectedStates.length > 0 ? { states: props.selectedStates } : null;
selectedStates.length > 0 ? { states: selectedStates } : null;
refetch({ signatureFilter: filter });
}, [JSON.stringify(props.selectedStates), refetch]);
}, [selectedStates, refetch]);
if (!version.signatures) {
return (
@@ -163,11 +164,11 @@ function SignatureList(props: {
// When a filter is active, only show people who have signatures in the filtered results
const filteredPeople =
props.selectedStates.length > 0
selectedStates.length > 0
? people.filter((p) => signatureMap.has(p.id))
: people;
if (filteredPeople.length === 0 && props.selectedStates.length > 0) {
if (filteredPeople.length === 0 && selectedStates.length > 0) {
return (
<div className="text-center text-sm text-txt-tertiary py-3">
{__("No signatures match the selected filters")}

View File

@@ -52,7 +52,7 @@ function DownloadLink({ evidenceId, onClose }: Props) {
useEffect(() => {
downloadFile(evidence.file?.downloadUrl, evidence.file?.fileName ?? "evidence");
onClose();
}, [evidence]);
}, [evidence.file?.downloadUrl, evidence.file?.fileName, onClose]);
return null;
}

View File

@@ -101,7 +101,7 @@ function EvidencePreviewContent({
return () => {
abortController.abort();
};
}, [evidence.file?.downloadUrl, isUriFile]);
}, [evidence.file?.downloadUrl, isUriFile, onClose, __, toast]);
if (!evidence.file?.downloadUrl) {
return null;

View File

@@ -88,7 +88,7 @@ export function EditContactDialog({ contactId, contact, onClose }: Props) {
useEffect(() => {
dialogRef.current?.open();
}, []);
}, [dialogRef]);
return (
<Dialog

View File

@@ -80,7 +80,7 @@ export function EditServiceDialog({ serviceId, service, onClose }: Props) {
useEffect(() => {
dialogRef.current?.open();
}, []);
}, [dialogRef]);
return (
<Dialog

View File

@@ -123,7 +123,7 @@ export default function VendorOverviewTab() {
{ name: "securityPageUrl", label: __("Security page URL") },
{ name: "trustPageUrl", label: __("Trust page URL") },
] as const,
[],
[__],
);
usePageTitle(vendor.name + " - " + __("Overview"));

1
package-lock.json generated
View File

@@ -54,7 +54,6 @@
"babel-plugin-relay": "^19.0.0",
"eslint": "^9.25.0",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-refresh": "^0.4.19",
"globals": "^16.0.0",
"graphql": "^16.11.0",
"prettier": "^3.5.3",

View File

@@ -1,28 +1,31 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";
export default tseslint.config(
{ ignores: ['dist'] },
{ ignores: ["dist"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
tsconfigRootDir: import.meta.dirname,
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
)
);

View File

@@ -8,6 +8,7 @@ import { input } from "../Input/Input";
import clsx from "clsx";
type Props = TextareaHTMLAttributes<HTMLTextAreaElement> & {
variant?: "bordered" | "ghost" | "title";
autogrow?: boolean;
ref?: RefCallback<HTMLTextAreaElement>;
};