Skip to content

Commit 2e28d01

Browse files
committed
Fiks noen eslint errors
1 parent b5136e5 commit 2e28d01

File tree

7 files changed

+41
-31
lines changed

7 files changed

+41
-31
lines changed

eslint.config.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@ export default tseslint.config(
77
prettier,
88
...tseslint.configs.recommendedTypeChecked,
99
{
10-
ignores: ['**/dist/**/*',],
10+
ignores: ['**/dist/**/*'],
1111
languageOptions: {
1212
parserOptions: {
1313
project: ['./tsconfig.json', './packages/*/tsconfig.json'],
1414
tsconfigRootDir: import.meta.dirname,
1515
},
1616
},
17+
rules: {
18+
'@typescript-eslint/no-floating-promises': 'warn',
19+
'@typescript-eslint/no-misused-promises': [
20+
'error',
21+
{
22+
checksVoidReturn: false,
23+
},
24+
],
25+
},
26+
},
27+
{
28+
files: ['**/*.js', 'vitest.workspace.ts'],
29+
extends: [tseslint.configs.disableTypeChecked],
1730
},
1831
{
19-
files: ['**/*.js','vitest.workspace.ts'],
20-
extends: [tseslint.configs.disableTypeChecked]
21-
}
32+
ignores: ['**/postcss.config.cjs'],
33+
},
2234
);

packages/dev-server/CustomServer.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import { Serve, Server } from 'bun';
32
import {
43
Route,
@@ -248,9 +247,9 @@ export class CustomServer {
248247
};
249248
}
250249

251-
const hasParam = <T extends Record<string, any>>(
250+
const hasParam = <T extends Record<string, string>>(
252251
key: string,
253252
params: T,
254-
): params is T & { [K in typeof key]: any } => {
253+
): params is T & { [K in typeof key]: string } => {
255254
return key in params && params[key] !== '';
256255
};

packages/dev-server/index.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable @typescript-eslint/no-explicit-any */
21
import { CustomServer } from './CustomServer';
32
import { BadRequestResponse } from './responses/BadRequestResponse';
43
import { InternalServerErrorResponse } from './responses/InternalServerErrorResponse';
@@ -8,6 +7,10 @@ import { NotFoundResponse } from './responses/NotFoundResponse';
87
import { BunServerWebsocket } from './types';
98

109
type Metadata = { ident: string };
10+
type Veileder = {
11+
enheter: { enhetId: string }[];
12+
};
13+
type Event = { eventType: 'NY_AKTIV_ENHET' | 'NY_AKTIV_BRUKER'; verdi: string };
1114

1215
const serve = () => {
1316
type Context = {
@@ -52,7 +55,7 @@ const serve = () => {
5255
return new BadRequestResponse('Missing enhetId');
5356
}
5457

55-
const response = mockMe.enheter.find(
58+
const response = (mockMe as Veileder).enheter.find(
5659
(enhet) => enhet.enhetId === request.params.enhetId,
5760
);
5861

@@ -68,11 +71,9 @@ const serve = () => {
6871
return new BadRequestResponse('No body provided');
6972
}
7073

71-
const {
72-
eventType,
73-
verdi,
74-
}: { eventType: 'NY_AKTIV_ENHET' | 'NY_AKTIV_BRUKER'; verdi: string } =
75-
await Bun.readableStreamToJSON(request.body);
74+
const { eventType, verdi } = (await Bun.readableStreamToJSON(
75+
request.body,
76+
)) as Event;
7677

7778
if (eventType === 'NY_AKTIV_BRUKER') {
7879
context.aktivBruker = verdi;
@@ -94,9 +95,9 @@ const serve = () => {
9495
return new BadRequestResponse('No body provided');
9596
}
9697

97-
const { code }: { code: string } = await Bun.readableStreamToJSON(
98-
request.body,
99-
);
98+
const { code } = (await Bun.readableStreamToJSON(request.body)) as {
99+
code: string;
100+
};
100101

101102
const fnr = codeToFnr[code];
102103

@@ -112,9 +113,9 @@ const serve = () => {
112113
return new BadRequestResponse('No body provided');
113114
}
114115

115-
const { fnr }: { fnr: string } = await Bun.readableStreamToJSON(
116-
request.body,
117-
);
116+
const { fnr } = (await Bun.readableStreamToJSON(request.body)) as {
117+
fnr: string;
118+
};
118119

119120
const code = crypto.randomUUID();
120121

packages/dev-server/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export interface WebSocketRoute<T = any> extends BaseRoute {
3737
};
3838
}
3939

40-
export type Params = Record<string, any>;
40+
export type Params = Record<string, string>;
4141
export type BunServerMetadata = BaseRoute & {
4242
metadata?: Record<string, any> | undefined;
4343
};

packages/internarbeidsflate-decorator-v3/src/__mocks__/mock-handlers.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export const mockMe: Veileder = {
1717
],
1818
};
1919

20-
const getUrl = (path: string) =>
21-
`${urlPrefix}/modiacontextholder/api${path}`;
20+
const getUrl = (path: string) => `${urlPrefix}/modiacontextholder/api${path}`;
2221

2322
const getErrorResponse = (status = 500) => {
2423
return new HttpResponse(null, { status });
@@ -40,12 +39,11 @@ let context: Context = { aktivEnhet: '0118', aktivBruker: '10108000398' };
4039

4140
export const updateMockContext = (newContext: Partial<Context>) => {
4241
context = {
43-
...context,
44-
...newContext,
45-
}
42+
...context,
43+
...newContext,
44+
};
4645
};
4746

48-
4947
export const getHandlers = (
5048
ws: WS,
5149
errorConfig: FailureConfig,

packages/internarbeidsflate-decorator-v3/src/store/EnhetValueManager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export class EnhetValueManager extends ContextValueManager {
4040

4141
const enheter = veileder.enheter;
4242
if (!enheter?.length) {
43-
this.#resetFnrAndEnhetDueToNoLegalEnhet();
43+
await this.#resetFnrAndEnhetDueToNoLegalEnhet();
4444
return;
4545
}
4646

@@ -160,7 +160,7 @@ export class EnhetValueManager extends ContextValueManager {
160160
};
161161

162162
readonly changeEnhetExternallyToLocalValue = async () => {
163-
this.contextHolderApi.changeEnhet(this.state.enhet.value);
163+
await this.contextHolderApi.changeEnhet(this.state.enhet.value);
164164
this.clearWSRequestedValue('enhet');
165165
this.closeModal('enhet');
166166
};

packages/internarbeidsflate-decorator-v3/src/wrapper/Wrapper.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const Wrapper: React.FC = () => {
2929
{
3030
onOpen: () => setWsConntected(true),
3131
onClose: () => setWsConntected(false),
32-
onMessage: (event) => {
32+
onMessage: (event: MessageEvent<string>) => {
3333
setWsMessages((messages) => {
3434
return [...messages, event.data];
3535
});
@@ -46,7 +46,7 @@ const Wrapper: React.FC = () => {
4646
await api.changeEnhet(wsEnhet);
4747
};
4848

49-
const sendNewFnr = async () => {
49+
const sendNewFnr = () => {
5050
await api.changeFnr(wsFnr);
5151
};
5252

0 commit comments

Comments
 (0)