Skip to content

Commit 8704e91

Browse files
committed
Fixed some issues that will be detected by the newer linter
1 parent 6c771a4 commit 8704e91

File tree

10 files changed

+49
-74
lines changed

10 files changed

+49
-74
lines changed

src/lib/common/errors.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ export async function responseError(response) {
1414
* Used for example to handle the displaying of the error alert when using the ConfirmActionButton.
1515
*/
1616
export class AlertError extends Error {
17-
/** @type {null | { loc: string[], msg: string } | string} */
18-
simpleValidationMessage;
19-
2017
/**
2118
* @param {any} reason
2219
* @param {number|null} statusCode
2320
*/
2421
constructor(reason, statusCode = null) {
2522
super();
2623
this.reason = reason;
24+
/** @type {null | { loc: string[], msg: string } | string} */
2725
this.simpleValidationMessage = getSimpleValidationMessage(reason, statusCode);
2826
}
2927

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
11
import Ajv from 'ajv';
22

33
export class SchemaValidator {
4-
#validator;
5-
#canValidate = false;
6-
74
/**
85
* @param {boolean} allErrors if true, check all rules collecting all errors. Default is to return after the first error.
96
*/
107
constructor(allErrors = false) {
118
this.ajv = new Ajv({ allErrors });
9+
this.canValidate = false;
1210
}
1311

12+
/**
13+
* @param {any} schema
14+
* @returns {boolean}
15+
*/
1416
loadSchema(schema) {
1517
try {
16-
this.#validator = this.ajv.compile(schema);
17-
return (this.#canValidate = true);
18+
this.validator = this.ajv.compile(schema);
19+
return (this.canValidate = true);
1820
} catch {
1921
console.error('SchemaValidator:loadSchema: error compiling schema');
2022
return false;
2123
}
2224
}
2325

26+
/**
27+
* @param {any} data
28+
* @returns {any}
29+
*/
2430
isValid(data) {
25-
if (!this.#canValidate) return null;
26-
return this.#validator(data);
31+
if (!this.validator) {
32+
return;
33+
}
34+
if (!this.canValidate) return null;
35+
return this.validator(data);
2736
}
2837

2938
/**
3039
* @returns {import('ajv').ErrorObject[] | null}
3140
*/
3241
getErrors() {
33-
if (!this.#canValidate) return null;
34-
return this.#validator.errors;
42+
if (!this.validator) {
43+
return null;
44+
}
45+
if (!this.canValidate) return null;
46+
return this.validator.errors || null;
3547
}
3648
}

src/lib/components/common/jschema/schema_management.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
export default class SchemaManager {
2-
keySeparator = '###';
3-
propertiesMap = new Map();
4-
hasUnsavedChanges = false;
5-
/** @type {(hasChanges: boolean) => void} */
6-
onPropertyChanges = () => {};
7-
/** @type {import('./jschema-types').JSONSchemaObjectProperty} */
8-
schema;
9-
102
/**
113
* @param {import('./jschema-types').JSONSchema|undefined} schema
124
* @param {object|undefined} schemaData
135
*/
146
constructor(schema, schemaData) {
157
this.schema = this.loadSchema(schema);
168
this.data = this.loadSchemaData(schemaData);
9+
this.keySeparator = '###';
10+
this.propertiesMap = new Map();
11+
this.hasUnsavedChanges = false;
12+
/** @type {(hasChanges: boolean) => void} */
13+
this.onPropertyChanges = () => {};
1714
}
1815

1916
/**
@@ -167,16 +164,6 @@ export default class SchemaManager {
167164
}
168165

169166
export class SchemaProperty {
170-
manager;
171-
/** @type {import('./jschema-types').JSONSchemaObjectProperty} */
172-
globalSchema;
173-
keySeparator = '###';
174-
nestedProperties = [];
175-
hasCustomKeyValues = false;
176-
/** @type {string[]|undefined} */
177-
requiredProperties = undefined;
178-
required = false;
179-
180167
/**
181168
* @param {import('./jschema-types').JSONSchemaProperty & { key: string }} propertySchema
182169
* @param {SchemaManager} manager
@@ -186,6 +173,12 @@ export class SchemaProperty {
186173
this.manager = manager;
187174
this.globalSchema = this.manager.schema;
188175
this.referenceSchema = propertySchema;
176+
this.keySeparator = '###';
177+
this.nestedProperties = [];
178+
this.hasCustomKeyValues = false;
179+
/** @type {string[]|undefined} */
180+
this.requiredProperties = undefined;
181+
this.required = false;
189182

190183
// Default properties
191184
this.type = propertySchema.type;

src/lib/components/jobs/JobInfoModal.svelte

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
import { page } from '$app/stores';
55
import Modal from '../common/Modal.svelte';
66
7-
/** @type {{id: number, name: string}[]} */
8-
export let datasets;
9-
/** @type {{id: number, name: string}[]} */
10-
export let workflows;
11-
127
/** @type {number|undefined} */
138
let workflowJobId = undefined;
149
/** @type {import('$lib/types').ApplyWorkflow|undefined} */
@@ -17,9 +12,6 @@
1712
let projectId = undefined;
1813
/** @type {string|undefined} */
1914
let projectName = undefined;
20-
let jobWorkflowName = undefined;
21-
let jobInputDatasetName = undefined;
22-
let jobOutputDatasetName = undefined;
2315
let jobStatus = undefined;
2416
2517
let errorAlert = undefined;
@@ -35,17 +27,6 @@
3527
workflowJobId = job.id;
3628
projectId = job.project_id;
3729
projectName = projectNameToDisplay;
38-
// Should update jobWorkflowName
39-
jobWorkflowName = workflows.find((workflow) => workflow.id === jobToDisplay.workflow_id)?.name;
40-
// Should update jobInputDatasetName
41-
jobInputDatasetName = datasets.find(
42-
(dataset) => dataset.id === jobToDisplay.input_dataset_id
43-
)?.name;
44-
// Should update jobOutputDatasetName
45-
jobOutputDatasetName = datasets.find(
46-
(dataset) => dataset.id === jobToDisplay.output_dataset_id
47-
)?.name;
48-
// Should update jobStatus
4930
jobStatus = job.status;
5031
5132
modal.show();

src/lib/components/jobs/JobsList.svelte

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,12 @@
3333
let inputDatasets = $page.data.inputDatasets || [];
3434
/** @type {{ id: number, name: string }[]} */
3535
let outputDatasets = $page.data.outputDatasets || [];
36-
/** @type {{ id: number, name: string }[]} */
37-
let datasets = inputDatasets.concat(outputDatasets);
3836
3937
/** @type {DataHandler} */
4038
let tableHandler = new DataHandler(jobs);
4139
tableHandler.sortDesc('id');
4240
43-
/** @type {import('svelte/types/runtime/store').Readable<import('$lib/types').ApplyWorkflow[]>} */
41+
/** @type {import('svelte/store').Readable<import('$lib/types').ApplyWorkflow[]>} */
4442
let rows = tableHandler.getRows();
4543
4644
// Filters
@@ -78,7 +76,6 @@
7876
/** @type {{id: number, name: string}[]} */
7977
(jobs.filter((j) => j.output_dataset_dump).map((j) => j.output_dataset_dump))
8078
);
81-
datasets = inputDatasets.concat(outputDatasets);
8279
tableHandler.setRows(jobs);
8380
}
8481
@@ -402,7 +399,7 @@
402399
</table>
403400
{/if}
404401

405-
<JobInfoModal {workflows} {datasets} bind:this={jobInfoModal} />
402+
<JobInfoModal bind:this={jobInfoModal} />
406403
<JobLogsModal bind:this={jobLogsModal} />
407404

408405
<style>

src/lib/stores/projectStores.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { writable } from 'svelte/store';
33
// The following store should be used to propagate selected project to display
44
// within a ProjectInfoModal. Every component that will update the project
55
// inside the store, will also update the to-be-displayed project in a modal.
6-
/** @type {import('svelte/types/runtime/store').Writable<import('$lib/types').Project|undefined>}} */
6+
/** @type {import('svelte/store').Writable<import('$lib/types').Project|undefined>}} */
77
export const projectInfoModal = writable(undefined);
88

99
// Context project store

src/lib/stores/taskStores.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { writable } from 'svelte/store';
22

3-
/** @type {import('svelte/types/runtime/store').Writable<import('$lib/types').Task|undefined>} */
3+
/** @type {import('svelte/store').Writable<import('$lib/types').Task|undefined>} */
44
export const taskStore = writable(undefined);
5-
/** @type {import('svelte/types/runtime/store').Writable<import('$lib/types').Task|undefined>} */
5+
/** @type {import('svelte/store').Writable<import('$lib/types').Task|undefined>} */
66
export const originalTaskStore = writable(undefined);
77
export const modalTaskCollectionId = writable(undefined);

src/routes/projects/[projectId]/datasets/[datasetId]/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165
<svelte:fragment slot="body">
166166
<ul class="list-group">
167167
{#if dataset.history && Object.keys(dataset.history).length > 0}
168-
{#each Object.entries(dataset.history) as [key, value]}
168+
{#each Object.entries(dataset.history) as [, value]}
169169
<li class="list-group-item text-bg-light">
170170
<span>
171171
Task "{value.workflowtask.task.name}", status "{value.status}"

src/routes/projects/[projectId]/workflows/[workflowId]/+page.svelte

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// List of available tasks to be inserted into workflow
2727
let availableTasks = [];
2828
29-
/** @type {import('svelte/types/runtime/store').Writable<import('$lib/types').WorkflowTask|undefined>} */
29+
/** @type {import('svelte/store').Writable<import('$lib/types').WorkflowTask|undefined>} */
3030
let workflowTaskContext = writable(undefined);
3131
let workflowTabContextId = 0;
3232
let workflowSuccessMessage = '';
@@ -636,19 +636,16 @@
636636
{#if workflow.task_list.length == 0}
637637
<p class="text-center mt-3">No workflow tasks yet, add one.</p>
638638
{:else}
639-
<ul class="list-group list-group-flush">
639+
<div class="list-group list-group-flush">
640640
{#each workflow.task_list as workflowTask}
641-
<li
641+
<button
642642
style="cursor: pointer"
643643
class="list-group-item list-group-item-action {$workflowTaskContext !==
644644
undefined && $workflowTaskContext.id == workflowTask.id
645645
? 'active'
646646
: ''}"
647647
data-fs-target={workflowTask.id}
648648
on:click|preventDefault={setActiveWorkflowTaskContext}
649-
on:keydown|preventDefault
650-
on:keyup|preventDefault
651-
on:keypress|preventDefault
652649
>
653650
{workflowTask.task.name} #{workflowTask.id}
654651
@@ -657,9 +654,9 @@
657654
<i class="bi bi-exclamation-triangle" />
658655
</span>
659656
{/if}
660-
</li>
657+
</button>
661658
{/each}
662-
</ul>
659+
</div>
663660
{/if}
664661
</div>
665662
</div>

src/routes/projects/[projectId]/workflows/experimental/[workflowId]/+page.svelte

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/** @type {import('$lib/components/common/StandardErrorAlert.svelte').default|undefined} */
3535
let workflowErrorAlert = undefined;
3636
37-
/** @type {import('svelte/types/runtime/store').Writable<import('$lib/types').WorkflowTask|undefined>} */
37+
/** @type {import('svelte/store').Writable<import('$lib/types').WorkflowTask|undefined>} */
3838
let workflowTaskContext = writable(undefined);
3939
let workflowTabContextId = 0;
4040
let workflowSuccessMessage = '';
@@ -729,19 +729,16 @@
729729
{#if workflow.task_list.length == 0}
730730
<p class="text-center mt-3">No workflow tasks yet, add one.</p>
731731
{:else}
732-
<ul class="list-group list-group-flush">
732+
<div class="list-group list-group-flush">
733733
{#each workflow.task_list as workflowTask}
734-
<li
734+
<button
735735
style="cursor: pointer"
736736
class="list-group-item list-group-item-action {$workflowTaskContext !==
737737
undefined && $workflowTaskContext.id == workflowTask.id
738738
? 'active'
739739
: ''}"
740740
data-fs-target={workflowTask.id}
741741
on:click|preventDefault={setActiveWorkflowTaskContext}
742-
on:keydown|preventDefault
743-
on:keyup|preventDefault
744-
on:keypress|preventDefault
745742
>
746743
{workflowTask.task.name}
747744

@@ -753,9 +750,9 @@
753750
<i class="bi bi-exclamation-triangle" />
754751
</span>
755752
{/if}
756-
</li>
753+
</button>
757754
{/each}
758-
</ul>
755+
</div>
759756
{/if}
760757
</div>
761758
</div>

0 commit comments

Comments
 (0)