Skip to content

Commit

Permalink
Biome fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cskrov committed Sep 10, 2024
1 parent b9945f4 commit 53d59f4
Show file tree
Hide file tree
Showing 21 changed files with 85 additions and 68 deletions.
10 changes: 9 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@
"noUnusedTemplateLiteral": {
"level": "warn",
"fix": "unsafe"
},
"noUselessElse": {
"level": "warn",
"fix": "safe"
},
"useTemplate": {
"level": "warn",
"fix": "safe"
}
}
}
Expand All @@ -54,6 +62,6 @@
}
},
"files": {
"ignore": ["dist/**"]
"ignore": ["dist/**", "node_modules/**"]
}
}
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"start": "vite & tsc --watch",
"build": "vite build",
"typecheck": "tsc",
"lint": "biome check"
"lint": "biome check --fix"
},
"license": "MIT",
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/app/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ export const Router = () => (
<Route element={<ProtectedRoute roles={[Role.KABAL_SAKSBEHANDLING, Role.KABAL_ROL]} />}>
<Route path="oppgaver" element={<OppgaverPage />} />
<Route path="mineoppgaver" element={<MineOppgaverPage />} />
<Route path="klagebehandling/:id" element={<KlagebehandlingPage />} />
<Route path="ankebehandling/:id" element={<AnkebehandlingPage />} />
<Route path="trygderettsankebehandling/:id" element={<TrygderettsankebehandlingPage />} />
<Route path="klagebehandling/:oppgaveId" element={<KlagebehandlingPage />} />
<Route path="ankebehandling/:oppgaveId" element={<AnkebehandlingPage />} />
<Route path="trygderettsankebehandling/:oppgaveId" element={<TrygderettsankebehandlingPage />} />
</Route>

<Route element={<ProtectedRoute roles={[Role.KABAL_INNSYN_EGEN_ENHET, Role.KABAL_KROL]} />}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const BehandlingSection = ({ label, children, testid }: Props) => {
return <StyledBehandlingSection data-testid={testid}>{children}</StyledBehandlingSection>;
}

const id = 'behandling-section-' + label.toLowerCase().replaceAll(/\s/g, '-');
const id = `behandling-section-${label.toLowerCase().replaceAll(/\s/g, '-')}`;

return (
<StyledBehandlingSection data-testid={testid}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const splitBeskrivelse = (beskrivelse: string): GosysBeskrivelseEntry[] =
// If it is not a header, it is a continuation of the previous entry.
if (header === null) {
if (current !== null) {
current.content += '\n' + trimmedLine;
current.content += `\n${trimmedLine}`;
}

// Ignore line.
Expand All @@ -29,7 +29,7 @@ export const splitBeskrivelse = (beskrivelse: string): GosysBeskrivelseEntry[] =
result.push(current);
} else if (current !== null) {
// If it is not a header and we have a current entry, it is a continuation of the previous entry.
current.content += '\n' + trimmedLine;
current.content += `\n${trimmedLine}`;
}
// Otherwise, ignore line.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const EditUtfallResultat = ({ utfall, oppgaveId }: UtfallResultatProps) => {
if (isUtfall(value)) {
updateUtfall({ oppgaveId, utfallId: value });

if (oppgave !== undefined && oppgave.resultat.extraUtfallIdSet.includes(value)) {
if (oppgave?.resultat.extraUtfallIdSet.includes(value)) {
updateEkstraUtfall({
oppgaveId,
extraUtfallIdSet: oppgave.resultat.extraUtfallIdSet.filter((id) => id !== value),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/header/user-menu/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ const getShortVersion = (version: string): string => {
return version;
}

return version.substring(0, 7) + '...';
return `${version.substring(0, 7)}...`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const AvailableTexts = ({ onAdd, onRemove, usedIds, textType }: Available
</StyledButton>

<Modal
header={{ heading: typeLabel + ' tekster' }}
header={{ heading: `${typeLabel} tekster` }}
width={1200}
open={open}
onClose={onClose}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/settings/abbreviations/example.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { styled } from 'styled-components';
interface Props {
title: string;
children: React.ReactNode;
examples: React.ReactNode[];
examples: React.ReactElement<{ key: string }>[];
recommended?: boolean;
}

Expand All @@ -22,8 +22,8 @@ export const AbbrevationExample = ({ title, children, examples, recommended = fa
{children}
</BodyShort>
<List as="ol" size="small">
{examples.map((example, index) => (
<List.Item key={index}>{example}</List.Item>
{examples.map((example) => (
<List.Item key={example.key}>{example}</List.Item>
))}
</List>
</section>
Expand Down
76 changes: 38 additions & 38 deletions frontend/src/components/settings/abbreviations/explanation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AbbrevationExample } from '@app/components/settings/abbreviations/example';
import { pushEvent } from '@app/observability';
import { BodyShort, ReadMore, Tag, Tooltip } from '@navikt/ds-react';
import { useCallback } from 'react';
import { Fragment, useCallback } from 'react';

export const AbbreviationsExplanation = () => {
const onOpenChange = useCallback((open: boolean) => {
Expand Down Expand Up @@ -48,15 +48,15 @@ export const AbbreviationsExplanation = () => {
title="Eksempel på kortform med kun små bokstaver"
recommended
examples={[
<>
<Fragment key="1">
<b>«aap»</b> blir utvidet til <b>«arbeidsavklaringspenger»</b>/<b>«Arbeidsavklaringspenger»</b>. <AutoCap />
</>,
<>
</Fragment>,
<Fragment key="2">
<b>«Aap»</b> blir utvidet til <b>«Arbeidsavklaringspenger»</b>. <AlwaysCap />
</>,
<>
</Fragment>,
<Fragment key="3">
<b>«AAP»</b> blir utvidet til <b>«ARBEIDSAVKLARINGSPENGER»</b>. <AlwaysAllCaps />
</>,
</Fragment>,
]}
>
Kortform <b>«aap»</b> med langform <b>«arbeidsavklaringspenger»</b>
Expand All @@ -66,15 +66,15 @@ export const AbbreviationsExplanation = () => {
title="Eksempel på kortform med spesialtegn"
recommended
examples={[
<>
<Fragment key="1">
<b>«@om»</b> blir utvidet til <b>«omsorgspenger»</b>/<b>«Omsorgspenger»</b>. <AutoCap />
</>,
<>
</Fragment>,
<Fragment key="2">
<b>«@Om»</b> blir utvidet til <b>«Omsorgspenger»</b>. <AlwaysCap />
</>,
<>
</Fragment>,
<Fragment key="3">
<b>«@OM»</b> blir utvidet til <b>«OMSORGSPENGER»</b>. <AlwaysAllCaps />
</>,
</Fragment>,
]}
>
Kortform <b>«@om»</b> med langform <b>«omsorgspenger»</b>
Expand All @@ -84,13 +84,13 @@ export const AbbreviationsExplanation = () => {
title="Eksempel på kortform med tall"
recommended
examples={[
<>
<Fragment key="1">
<b>«k9»</b> blir utvidet til <b>«kapittel 9 i folketrygdloven»</b>/<b>«Kapittel 9 i folketrygdloven»</b>.{' '}
<AutoCap />
</>,
<>
</Fragment>,
<Fragment key="2">
<b>«K9»</b> blir utvidet til <b>«Kapittel 9 i folketrygdloven»</b>. <AlwaysCap />
</>,
</Fragment>,
]}
>
Kortform <b>«k9»</b> med langform <b>«kapittel 9 i folketrygdloven»</b>
Expand All @@ -99,15 +99,15 @@ export const AbbreviationsExplanation = () => {
<AbbrevationExample
title="Eksempel på kortform med kun store bokstaver"
examples={[
<>
<b>«aap»</b> blir <Error />.
</>,
<>
<b>«Aap»</b> blir <Error />.
</>,
<>
<Fragment key="1">
<b>«aap»</b> blir <NotRecognised />.
</Fragment>,
<Fragment key="2">
<b>«Aap»</b> blir <NotRecognised />.
</Fragment>,
<Fragment key="3">
<b>«AAP»</b> blir utvidet til <b>«arbeidsavklaringspenger»</b>/<b>«Arbeidsavklaringspenger»</b>. <AutoCap />
</>,
</Fragment>,
]}
>
Kortform <b>«AAP»</b> med langform <b>«arbeidsavklaringspenger»</b>
Expand All @@ -116,15 +116,15 @@ export const AbbreviationsExplanation = () => {
<AbbrevationExample
title="Eksempel på kortform med både store og små bokstaver"
examples={[
<>
<b>«aap»</b> blir <Error />.
</>,
<>
<Fragment key="1">
<b>«aap»</b> blir <NotRecognised />.
</Fragment>,
<Fragment key="2">
<b>«Aap»</b> blir utvidet til <b>«arbeidsavklaringspenger»</b>/<b>«Arbeidsavklaringspenger»</b>. <AutoCap />
</>,
<>
<b>«AAP»</b> blir <Error />.
</>,
</Fragment>,
<Fragment key="3">
<b>«AAP»</b> blir <NotRecognised />.
</Fragment>,
]}
>
Kortform <b>«Aap»</b> med langform <b>«arbeidsavklaringspenger»</b>
Expand All @@ -133,15 +133,15 @@ export const AbbreviationsExplanation = () => {
<AbbrevationExample
title="Eksempel på kortform med kun én bokstav"
examples={[
<>
<Fragment key="1">
<b>«x»</b> blir utvidet til <b>«høyesterettsjustitiarius»</b>/<b>«Høyesterettsjustitiarius»</b>. <AutoCap />
</>,
<>
</Fragment>,
<Fragment key="2">
<b>«X»</b> blir utvidet til <b>«Høyesterettsjustitiarius»</b>. <AlwaysCap />
<Tag variant="neutral" size="xsmall">
Umulig å få bare store boktaver siden kortformen består av kun én bokstav.
</Tag>
</>,
</Fragment>,
]}
>
Kortform <b>«x»</b> med langform <b>«høyesterettsjustitiarius»</b>
Expand Down Expand Up @@ -170,7 +170,7 @@ const AlwaysAllCaps = () => (
</Tag>
);

const Error = () => (
const NotRecognised = () => (
<Tag variant="error" size="xsmall">
Ikke gjenkjent
</Tag>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/domain/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const isoTimeToPretty = (isoTime: ISOTime | null | undefined): prettyTime
return _isoTimeToPretty(isoTime);
};

// biome-ignore lint/style/noNonNullAssertion: Internal function.
const _isoTimeToPretty = (isoTime: ISOTime): prettyTime => isoTime.split('.')[0]!;

export const isoDateToPretty = (isoDate: ISODate | null | undefined): prettyDate | null => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class Environment implements EnvironmentVariables {
private getIsAnsattDomain(): boolean {
if (this.isProduction) {
return window.location.hostname.endsWith('.ansatt.nav.no');
} else if (this.isDevelopment) {
}
if (this.isDevelopment) {
return window.location.hostname.endsWith('.ansatt.dev.nav.no');
}

Expand Down
9 changes: 6 additions & 3 deletions frontend/src/functions/get-error-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const getErrorData = (error: FetchBaseQueryError | SerializedError | unde
if (typeof error.status === 'number') {
if (typeof error.data === 'string') {
return { title: error.data, status: error.status };
} else if (isApiError(error.data)) {
}
if (isApiError(error.data)) {
return error.data;
}
}
Expand All @@ -43,9 +44,11 @@ export const getErrorData = (error: FetchBaseQueryError | SerializedError | unde
const getCustomErrorMessage = (data?: unknown): string | undefined => {
if (typeof data === 'string') {
return data;
} else if (typeof data === 'number') {
}
if (typeof data === 'number') {
return data.toString();
} else if (typeof data === 'object') {
}
if (typeof data === 'object') {
return JSON.stringify(data);
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/hooks/use-kodeverk-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ export const useRegistreringshjemlerFromIds = (hjemmelIdList: string[]): string[
return hjemmelIdList.map((hjemmelId) => {
const hjemmel = data[hjemmelId];

return hjemmel === undefined ? hjemmelId : hjemmel.lovkilde.beskrivelse + ' ' + hjemmel.hjemmelnavn;
return hjemmel === undefined ? hjemmelId : `${hjemmel.lovkilde.beskrivelse} ${hjemmel.hjemmelnavn}`;
});
};
4 changes: 2 additions & 2 deletions frontend/src/hooks/use-smart-editor-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ export const useSmartEditorLanguage = () => {
);

// Try to use cache for single document first. This will probably not be in place in time, though.
if (document !== undefined && document.isSmartDokument) {
if (document?.isSmartDokument === true) {
return document.language;
}

// Fallback to going through all documents, which should already be in cache.
if (documents !== undefined) {
const doc = documents.find(({ id }) => documentId === id);

if (doc !== undefined && doc.isSmartDokument) {
if (doc?.isSmartDokument === true) {
return doc.language;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const LegacyRedigerbarMaltekst = ({
if (!isInitialized.current) {
insertRedigerbarMaltekst();
}
}, [editor, element, insertRedigerbarMaltekst]);
}, [element, insertRedigerbarMaltekst]);

if (isLoading) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const UpdateMaltekstseksjon = ({ next, replaceNodes }: Props) => {
const { data: oppgave } = useOppgave();
const [ignored, setIgnored] = useState(false);

// Reset ignored when text changes.
// biome-ignore lint/correctness/useExhaustiveDependencies: Reset ignored when text changes.
useEffect(() => setIgnored(false), [next?.maltekstseksjon?.id]);

const replaceMaltekstseksjonContent = useCallback(() => {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/plate/functions/lex-specialis/template-score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export const getTemplateScore = (
if (t === GLOBAL) {
if (s === undefined) {
return NEGATIVE_INFINITY;
} else if (s === section) {
}
if (s === section) {
return GLOBAL_SECTION_SCORE;
}
} else if (t === templateId) {
if (s === undefined) {
return NEGATIVE_INFINITY;
} else if (s === section) {
}
if (s === section) {
return TEMPLATE_SECTION_SCORE;
}
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/plate/functions/lex-specialis/ytelse-score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@ export const getYtelseScore = (ytelseId: string, hjemmelList: string[], ytelseHj
if (y === GLOBAL) {
if (h === undefined) {
return INCLUDE_THRESHOLD;
} else if (hjemmelList.includes(h)) {
}
if (hjemmelList.includes(h)) {
return GLOBAL_HJEMMEL_SCORE;
}
} else if (y === ytelseId) {
if (h === undefined) {
return ONLY_YTELSE_SCORE;
} else if (hjemmelList.includes(h)) {
}
if (hjemmelList.includes(h)) {
return YTELSE_AND_HJEMMEL_SCORE;
}
}
Expand Down
Loading

0 comments on commit 53d59f4

Please sign in to comment.