Skip to content

Commit f76d2c3

Browse files
authored
Lint and rules (#205)
1 parent 0171a14 commit f76d2c3

File tree

59 files changed

+238
-142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+238
-142
lines changed

.eslintrc

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
{
2-
"extends": ["react-app", "prettier"],
3-
"plugins": ["import"],
2+
"extends": [
3+
"react-app",
4+
"eslint:recommended",
5+
"plugin:@typescript-eslint/recommended",
6+
"plugin:prettier/recommended"
7+
],
8+
"parser": "@typescript-eslint/parser",
9+
"plugins": ["@typescript-eslint", "import"],
410
"rules": {
11+
"@typescript-eslint/ban-ts-comment": "off",
12+
"@typescript-eslint/no-explicit-any": "off",
513
"import/no-restricted-paths": [
614
"error",
715
{

.prettierignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.md
22
build
33
package-lock.json
4+
.eslintrc

__mocks__/zustand.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { act } from '@testing-library/react';
33
import { vi } from 'vitest';
44
import * as zustand from 'zustand';
55

6-
const { create: actualCreate, createStore: actualCreateStore } = await vi.importActual<
7-
typeof zustand
8-
>('zustand');
6+
const { create: actualCreate, createStore: actualCreateStore } =
7+
await vi.importActual<typeof zustand>('zustand');
98

109
// a variable to hold reset functions for all stores declared in the app
1110
export const storeResetFns = new Set<() => void>();

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="no">
33
<head>
44
<meta charset="utf-8" />

mock/kandidat-api/mockKandidatIKandidatliste.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const mockKandidatIKandidatliste: KandidatIKandidatliste[] = [
1515
epost: mockKandidat.epostadresse,
1616
erSynlig: true,
1717
etternavn: mockKandidat.etternavn,
18-
fodselsdato: mockKandidat.fodselsdato!!,
18+
fodselsdato: mockKandidat.fodselsdato as string,
1919
fodselsnr: mockKandidat.fodselsnummer,
2020
fornavn: mockKandidat.fornavn,
2121
innsatsgruppe: 'Situasjonsbestemt innsats',

mock/stillingssok-proxy/mockEsStilling.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { EsRekrutteringsbistandstilling } from 'felles/domene/stilling/EsStilling';
2-
import { Kilde, Medium } from '../../src/felles/domene/stilling/Stilling';
2+
import {
3+
Administration,
4+
Kilde,
5+
Medium,
6+
Stillingsinfo,
7+
} from '../../src/felles/domene/stilling/Stilling';
38
import { mockRekrutteringsbistandstilling, mockStilling } from '../stilling-api/mockStilling';
49

510
export const mockEsRekrutteringsbistandstilling: EsRekrutteringsbistandstilling = {
@@ -41,12 +46,12 @@ export const mockEsRekrutteringsbistandstillingMin: EsRekrutteringsbistandstilli
4146
uuid: 'minIntern',
4247
styrkEllerTittel: 'Intern stilling MIN',
4348
administration: {
44-
...mockEsRekrutteringsbistandstilling.stilling.administration!,
49+
...(mockEsRekrutteringsbistandstilling.stilling.administration as Administration),
4550
navIdent: 'Z123456',
4651
},
4752
},
4853
stillingsinfo: {
49-
...mockEsRekrutteringsbistandstilling.stillingsinfo!,
54+
...(mockEsRekrutteringsbistandstilling.stillingsinfo as Stillingsinfo),
5055
eierNavident: 'Z123456',
5156
},
5257
};
@@ -93,12 +98,13 @@ export const mockEsRekrutteringsbistandstillingEksternMin: EsRekrutteringsbistan
9398
uuid: 'minEkstern',
9499
styrkEllerTittel: 'Ekstern stilling MIN',
95100
administration: {
96-
...mockEsRekrutteringsbistandstillingEkstern.stilling.administration!,
101+
...(mockEsRekrutteringsbistandstillingEkstern.stilling
102+
.administration as Administration),
97103
navIdent: 'Z123456',
98104
},
99105
},
100106
stillingsinfo: {
101-
...mockEsRekrutteringsbistandstillingEkstern.stillingsinfo!,
107+
...(mockEsRekrutteringsbistandstillingEkstern.stillingsinfo as Stillingsinfo),
102108
eierNavident: 'Z123456',
103109
},
104110
};

package-lock.json

+77
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"eslint-config-prettier": "^9.1.0",
7070
"eslint-config-react-app": "^7.0.1",
7171
"eslint-plugin-import": "^2.29.1",
72+
"eslint-plugin-prettier": "^5.1.3",
7273
"http-proxy-middleware": "^2.0.4",
7374
"husky": "^8.0.3",
7475
"jsdom": "^24.0.0",

src/api/foresporsel-om-deling-av-cv-api/test.ts

-23
This file was deleted.

src/api/sms-api/sms.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { z } from 'zod';
21
import { http, HttpResponse } from 'msw';
2+
import useSWR, { SWRResponse, useSWRConfig } from 'swr';
3+
import { z } from 'zod';
34
import { mockKandidatlisteMedStilling } from '../../../mock/kandidat-api/mockKandidatliste';
45
import { mockVeileder } from '../../../mock/mockVeileder';
56
import { fetchJson, postJson } from '../../kandidat/api/fetchUtils';
6-
import useSWR, { SWRResponse, useSWRConfig } from 'swr';
77

88
const varselStillingEndepunkt = (stillingId: string) => {
99
if (stillingId === undefined) throw new Error('stillingId === undefined');
@@ -159,7 +159,7 @@ export const smsApiMock = [
159159
}
160160
}),
161161

162-
http.post<{}, smserForKandidatRequest>(varselQueryEndepunkt, async ({ request }) => {
162+
http.post<object, smserForKandidatRequest>(varselQueryEndepunkt, async ({ request }) => {
163163
const { fnr } = await request.json();
164164
const sms = mockSms.filter((sms) => sms.mottakerFnr === fnr);
165165

@@ -174,7 +174,7 @@ export const smsApiMock = [
174174
const mockSms: Sms[] = [
175175
{
176176
id: '1',
177-
stillingId: mockKandidatlisteMedStilling.stillingId!,
177+
stillingId: mockKandidatlisteMedStilling.stillingId as string,
178178
mottakerFnr: '14114536327', //mockKandidatlisteMedStilling.kandidater[0].fodselsnr,
179179
avsenderNavident: mockVeileder.navIdent,
180180
opprettet: new Date().toISOString(),

src/api/stillings-api/hentFylker.ts

-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const hentFylkerSchema = z.array(fylkeSchema);
2020
export type HentFylkerDTO = z.infer<typeof hentFylkerSchema>;
2121
export type FylkeDTO = z.infer<typeof fylkeSchema>;
2222

23-
export interface HentFylkerProps {}
24-
2523
export const useHentFylker = () => {
2624
return useSWRImmutable(hentFylkerEndepunkt, getAPIwithSchema(hentFylkerSchema));
2725
};

src/api/stillings-api/hentLand.ts

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ const hentLandlisteSchema = z.array(landSchema);
2121
export type HentLandlisteDTO = z.infer<typeof hentLandlisteSchema>;
2222
export type LandDTO = z.infer<typeof landSchema>;
2323

24-
export interface HentFylkerProps {}
25-
2624
export const useHentLandliste = () => {
2725
const swrData = useSWRImmutable(hentLandlisteEndepunkt, getAPI);
2826

src/felles/amplitude.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const setNavKontorForAmplitude = (navKontor: string) => {
2020
}
2121
};
2222

23-
export const sendEvent = (område: string, hendelse: string, data?: Object) => {
23+
export const sendEvent = (område: string, hendelse: string, data?: object) => {
2424
if (import.meta.env.PROD) {
2525
client.logEvent(['#rekrutteringsbistand', område, hendelse].join('-'), data);
2626
}

src/felles/domene/elastic/ElasticSearch.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Sort =
4949

5050
export type AggregationsQuery = {
5151
[aggregering: string]: {
52-
global?: {};
52+
global?: object;
5353
terms?: {
5454
field: string;
5555
size?: number;
@@ -97,7 +97,7 @@ export type EsResponse<IndexedItem> = {
9797
max_score: number | null;
9898
hits: Array<Hit<IndexedItem>>;
9999
};
100-
suggest?: {};
100+
suggest?: object;
101101
aggregations?: AggregationsResponse;
102102
};
103103

src/felles/komponenter/banner/Banner.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import Grunnbanner from '../grunnbanner/Grunnbanner';
44
import css from './Banner.module.css';
55

66
type Props = {
7-
tittel: String;
7+
tittel: string;
88
ikon: ReactNode;
99
children?: ReactNode;
1010
};

src/forside/statistikk/Statistikk.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const Statistikk: FunctionComponent<Props> = ({ navKontor, navKontorNavn }) => {
1919
};
2020

2121
const antallMånederForHistorikk = 12;
22-
const tidsperioder = Array<Number>(antallMånederForHistorikk)
22+
const tidsperioder = Array<number>(antallMånederForHistorikk)
2323
.fill(0, 0, antallMånederForHistorikk)
2424
.map((_, i) => {
2525
const statistikkTidspunkt = new Date();

src/header/modiadekoratør/Modiadekoratør.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const Modiadekoratør: FunctionComponent<Props> = ({ navKontor, onNavKontorChang
4242
};
4343

4444
if (!loadjs.isDefined(appName)) {
45-
let url = hentHostname();
45+
const url = hentHostname();
4646

4747
loadAssets([
4848
`${url}/internarbeidsflatedecorator/v2.1/static/js/head.v2.min.js`,

src/header/nyheter/nyhetssaker.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Nyhet } from './Nyheter';
22

3-
const tilDato = (dag: number, måned: number, år: number, timer: number = 0, minutter: number = 0) =>
3+
const tilDato = (dag: number, måned: number, år: number, timer = 0, minutter = 0) =>
44
new Date(år, måned - 1, dag, timer, minutter);
55

66
const nyhetssaker: Nyhet[] = [
@@ -287,7 +287,7 @@ const nyhetssaker: Nyhet[] = [
287287
rel="noopener noreferrer"
288288
href="https://navno.sharepoint.com/sites/fag-og-ytelser-arbeid-markedsarbeid/SitePages/Del-stillinger-med-kandidater-i-Aktivitetsplanen.aspx"
289289
>
290-
Les om hvordan dudeler en stilling medkandidater
290+
Les om hvordan du deler en stilling med kandidater
291291
</a>
292292
.
293293
</p>

src/kandidat/api/fetchUtils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class SearchApiError {
1515
}
1616
}
1717

18-
export async function fetchJson(url: string, includeCredentials: boolean = false) {
18+
export async function fetchJson(url: string, includeCredentials = false) {
1919
try {
2020
let response;
2121
if (includeCredentials) {
@@ -90,7 +90,7 @@ export const postHeaders = () => ({
9090
export async function postJson(
9191
url: string,
9292
bodyString: string,
93-
parseAsJsonIgnoringContentType: boolean = false
93+
parseAsJsonIgnoringContentType = false
9494
) {
9595
try {
9696
const response = await fetch(url, {

0 commit comments

Comments
 (0)