Skip to content

Commit 4729339

Browse files
committed
switch to new prettier objectwrap collapse rule
1 parent 10cbb40 commit 4729339

File tree

26 files changed

+85
-240
lines changed

26 files changed

+85
-240
lines changed

.prettierrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
singleQuote: true
2+
objectWrap: collapse

eslint.config.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,25 +48,18 @@ export default tseslint.config(
4848
},
4949
{
5050
files: ['packages/**/src/**/*@(.mjs|.js|.ts|.cjs|.jsx|.tsx)'],
51-
rules: {
52-
'no-console': 'error',
53-
},
51+
rules: { 'no-console': 'error' },
5452
},
5553
{
5654
files: ['*.cjs'],
57-
languageOptions: {
58-
sourceType: 'script',
59-
globals: { ...globals.node },
60-
},
55+
languageOptions: { sourceType: 'script', globals: { ...globals.node } },
6156
},
6257
{
6358
files: [
6459
'packages/**/bin/**/*@(.mjs|.js|.ts|.cjs)',
6560
'scripts/**/*@(.mjs|.js|.ts|.cjs)',
6661
'packages/**/scripts/**/*@(.mjs|.js|.ts|.cjs)',
6762
],
68-
languageOptions: {
69-
globals: { ...globals.node },
70-
},
63+
languageOptions: { globals: { ...globals.node } },
7164
},
7265
) as Linter.Config[];

packages/convert-touchstone/src/convert-touchstone.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import * as sax from 'sax';
22
import type StaticDesign from '@lightmill/static-design';
33

4-
export type Experiment = {
5-
author: string;
6-
description: string;
7-
id: string;
8-
};
4+
export type Experiment = { author: string; description: string; id: string };
95
export type WithId = { id: string };
10-
export type Run<T extends MinimalTask> = {
11-
id: string;
12-
timeline: Array<T>;
13-
};
6+
export type Run<T extends MinimalTask> = { id: string; timeline: Array<T> };
147
export type Trial = (
158
| { practice: false; number: number; blockNumber: number }
169
| { practice: true }
@@ -213,10 +206,7 @@ export default function convertTouchstone(
213206
? {}
214207
: parseValues(trialNode.attributes.values, valueParsers);
215208
let trial: Trial = currentBlock.practice
216-
? {
217-
...currentBlock,
218-
...values,
219-
}
209+
? { ...currentBlock, ...values }
220210
: {
221211
...currentBlock,
222212
...values,
@@ -418,11 +408,7 @@ function createTaskGetter<FArgs extends MapperArgs, T extends MinimalTask>(
418408
}
419409
return value.map((task) => {
420410
if (typeof task === 'string') {
421-
return {
422-
...args[0],
423-
type: task,
424-
id: getId(task, undefined),
425-
};
411+
return { ...args[0], type: task, id: getId(task, undefined) };
426412
}
427413
let requestedId: string | undefined = undefined;
428414
if ('id' in task) {
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"extends": "../../tsconfig.json",
4-
"compilerOptions": {
5-
"rootDir": "src",
6-
"outDir": "dist"
7-
},
4+
"compilerOptions": { "rootDir": "src", "outDir": "dist" },
85
"include": ["./src/**/*.ts"]
96
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
33
"extends": "../../tsconfig.json",
4-
"compilerOptions": {
5-
"noEmit": true
6-
}
4+
"compilerOptions": { "noEmit": true }
75
}

packages/log-api/src/api.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ export const contract = c.router(
8383
path: '/experiments/:experimentName/logs',
8484
pathParams: z.object({ experimentName: z.string() }),
8585
query: z
86-
.object({
87-
type: z.union([z.string(), z.array(z.string())]).optional(),
88-
})
86+
.object({ type: z.union([z.string(), z.array(z.string())]).optional() })
8987
.strict(),
9088
headers: z.object({
9189
Accept: z.enum(['text/csv', 'application/json']).optional(),
@@ -97,9 +95,7 @@ export const contract = c.router(
9795
// In generate-openapi.ts, we will use a custom mapper to specify the response for
9896
// the CSV content type.
9997
// 200: c.otherResponse({ contentType: 'text/csv', body: z.string() }),
100-
200: schemas.okResponse.extend({
101-
logs: z.array(schemas.log),
102-
}),
98+
200: schemas.okResponse.extend({ logs: z.array(schemas.log) }),
10399
404: schemas.errorResponse,
104100
},
105101
strictStatusCodes: false,

packages/log-api/src/schemas.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ export const runStatus: z.ZodType<RunStatus> = z.enum([
4040
]);
4141

4242
export const run = z
43-
.object({
44-
experimentName: z.string(),
45-
runName: z.string(),
46-
})
43+
.object({ experimentName: z.string(), runName: z.string() })
4744
.strict();
4845
export type Run = z.output<typeof run>;
4946

packages/log-client/__mocks__/handlers.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,7 @@ export function getServerHandlers({
7676
if (run == null) {
7777
return HttpResponse.json({ message: 'Run not found' }, { status: 404 });
7878
}
79-
return HttpResponse.json({
80-
runStatus: 'running',
81-
logs: [],
82-
...run,
83-
});
79+
return HttpResponse.json({ runStatus: 'running', logs: [], ...run });
8480
}),
8581
patch('/experiments/:experimentName/runs/:runName', ({ params }) => {
8682
const run = getRun(params);

packages/log-client/__tests__/main.test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ import { paths } from '../generated/api.js';
88
type Method = 'get' | 'post' | 'delete' | 'patch';
99

1010
type ApiBody<M extends Method, P extends keyof paths> = paths[P] extends {
11-
[K in M]: {
12-
requestBody: { content: { 'application/json': infer B } };
13-
};
11+
[K in M]: { requestBody: { content: { 'application/json': infer B } } };
1412
}
1513
? B
1614
: paths[P] extends {
@@ -91,9 +89,7 @@ afterAll(() => {
9189

9290
describe('LogClient#startRun', () => {
9391
it('should send a start request', async () => {
94-
const logger = new LogClient({
95-
apiRoot: 'https://server.test/api',
96-
});
92+
const logger = new LogClient({ apiRoot: 'https://server.test/api' });
9793
await logger.startRun();
9894
await expect(waitForChangeRequests()).resolves.toEqual([
9995
{
@@ -268,9 +264,7 @@ describe('LogClient#resumeRun', () => {
268264
],
269265
},
270266
]);
271-
const logger = new LogClient({
272-
apiRoot: 'https://server.test/api',
273-
});
267+
const logger = new LogClient({ apiRoot: 'https://server.test/api' });
274268
await expect(
275269
logger.resumeRun({
276270
resumeAfterLast: ['test-type1', 'test-type2'],
@@ -699,9 +693,7 @@ describe('LogClient#cancelRun', () => {
699693

700694
describe('LogClient#logout', () => {
701695
it('should close the session', async () => {
702-
const logger = new LogClient({
703-
apiRoot: 'https://server.test/api',
704-
});
696+
const logger = new LogClient({ apiRoot: 'https://server.test/api' });
705697
await logger.startRun();
706698
clearRequests();
707699
await logger.logout();

packages/log-server/__tests__/app.test.ts

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,10 @@ describe('sessions', () => {
115115
it('should accept the creation of a host session if there is no host password set on the server', async ({
116116
expect,
117117
}) => {
118-
await api.put('/sessions/current').send({ role: 'host' }).expect(201, {
119-
role: 'host',
120-
runs: [],
121-
});
118+
await api
119+
.put('/sessions/current')
120+
.send({ role: 'host' })
121+
.expect(201, { role: 'host', runs: [] });
122122
});
123123

124124
it('should accept the creation of a host role if the provided password is correct', async ({
@@ -163,20 +163,19 @@ describe('sessions', () => {
163163

164164
it('should return the current session if it exists', async ({ expect }) => {
165165
await api.put('/sessions/current').send({ role: 'participant' });
166-
await api.get('/sessions/current').expect(200, {
167-
role: 'participant',
168-
runs: [],
169-
});
166+
await api
167+
.get('/sessions/current')
168+
.expect(200, { role: 'participant', runs: [] });
170169
});
171170
});
172171

173172
describe('delete /sessions/current', () => {
174173
it('should return an error if the session does not exists', async ({
175174
expect,
176175
}) => {
177-
await api.delete('/sessions/current').expect(404, {
178-
message: 'No session found',
179-
});
176+
await api
177+
.delete('/sessions/current')
178+
.expect(404, { message: 'No session found' });
180179
});
181180

182181
it('should delete the current session if it exists', async ({ expect }) => {
@@ -195,11 +194,7 @@ describe('runs', () => {
195194
vi.useFakeTimers({ toFake: ['Date'] });
196195
vi.setSystemTime(1234567890);
197196
store = MockStore();
198-
let app = LogServer({
199-
store,
200-
secret: 'secret',
201-
secureCookies: false,
202-
});
197+
let app = LogServer({ store, secret: 'secret', secureCookies: false });
203198
api = request.agent(app);
204199
await api.post('/sessions').send({ role: 'participant' });
205200
});
@@ -226,11 +221,14 @@ describe('runs', () => {
226221
it('should use the default experiment if the experiment is not named', async ({
227222
expect,
228223
}) => {
229-
await api.post('/runs').send({ runName: 'run' }).expect(201, {
230-
experimentName: 'addRun:experimentName',
231-
runName: 'addRun:runName',
232-
runStatus: 'idle',
233-
});
224+
await api
225+
.post('/runs')
226+
.send({ runName: 'run' })
227+
.expect(201, {
228+
experimentName: 'addRun:experimentName',
229+
runName: 'addRun:runName',
230+
runStatus: 'idle',
231+
});
234232
expect(store.addRun).toHaveBeenCalledWith({
235233
experimentName: 'default',
236234
runName: 'run',
@@ -262,16 +260,18 @@ describe('runs', () => {
262260
.post('/runs')
263261
.send({ experimentName: 'exp-id', runName: 'run-id' })
264262
.expect(201);
265-
await api.get('/sessions/current').expect(200, {
266-
role: 'participant',
267-
runs: [
268-
{
269-
runName: 'getRun:runName',
270-
experimentName: 'getRun:experimentName',
271-
runStatus: 'running',
272-
},
273-
],
274-
});
263+
await api
264+
.get('/sessions/current')
265+
.expect(200, {
266+
role: 'participant',
267+
runs: [
268+
{
269+
runName: 'getRun:runName',
270+
experimentName: 'getRun:experimentName',
271+
runStatus: 'running',
272+
},
273+
],
274+
});
275275
});
276276

277277
it('should refuse to create a run if participant already has one running', async ({
@@ -540,15 +540,11 @@ describe('runs', () => {
540540
await api
541541
.patch('/experiments/exp-id/runs/my-run')
542542
.send({ runStatus: 'completed' })
543-
.expect(405, {
544-
message: 'Cannot complete a canceled run',
545-
});
543+
.expect(405, { message: 'Cannot complete a canceled run' });
546544
await api
547545
.patch('/experiments/exp-id/runs/my-run')
548546
.send({ runStatus: 'canceled' })
549-
.expect(405, {
550-
message: 'Run is already canceled',
551-
});
547+
.expect(405, { message: 'Run is already canceled' });
552548
expect(store.setRunStatus).not.toHaveBeenCalled();
553549
expect(store.resumeRun).not.toHaveBeenCalled();
554550
});
@@ -696,11 +692,7 @@ describe('logs', () => {
696692
.post('/experiments/test-exp/runs/not-my-run/logs')
697693
.send({
698694
logs: [
699-
{
700-
type: 'test-log',
701-
values: { p1: 'v1', p2: 'v2' },
702-
number: 1,
703-
},
695+
{ type: 'test-log', values: { p1: 'v1', p2: 'v2' }, number: 1 },
704696
],
705697
})
706698
.expect(404);
@@ -717,11 +709,7 @@ describe('logs', () => {
717709
})
718710
.expect(201);
719711
expect(store.addLogs).toHaveBeenCalledWith(myRun.runId, [
720-
{
721-
type: 'test-log',
722-
values: { p1: 'v1', p2: 'v2' },
723-
number: 1,
724-
},
712+
{ type: 'test-log', values: { p1: 'v1', p2: 'v2' }, number: 1 },
725713
]);
726714
});
727715

0 commit comments

Comments
 (0)