Skip to content

Commit 33a234e

Browse files
committed
sty: Address deno lint comments for validators/hed.ts
1 parent 55a00e3 commit 33a234e

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/validators/hed.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,25 @@ import { hedOldToNewLookup } from '../issues/list.ts'
33
import type { GenericSchema } from '../types/schema.ts'
44
import type { IssueFile } from '../types/issues.ts'
55
import type { BIDSContext, BIDSContextDataset } from '../schema/context.ts'
6-
import type { DatasetIssues } from '../issues/datasetIssues.ts'
7-
import type { ColumnsMap } from '../types/columns.ts'
86

9-
function sidecarHasHed(sidecarData: BIDSContext['sidecar']) {
7+
export interface HedIssue {
8+
code: number
9+
file: IssueFile
10+
evidence: string
11+
}
12+
13+
function sidecarHasHed(sidecarData: BIDSContext['sidecar']): boolean {
1014
if (!sidecarData) {
1115
return false
1216
}
1317
return Object.keys(sidecarData).some((x) => sidecarValueHasHed(sidecarData[x]))
1418
}
1519

16-
function sidecarValueHasHed(sidecarValue: unknown) {
17-
return (
18-
sidecarValue !== null &&
19-
typeof sidecarValue === 'object' &&
20-
'HED' in sidecarValue &&
21-
sidecarValue.HED !== undefined
22-
)
20+
function sidecarValueHasHed(sidecarValue: { HED?: string }): boolean {
21+
return typeof sidecarValue.HED !== 'undefined'
2322
}
2423

25-
async function setHedSchemas(dataset: BIDSContextDataset) {
24+
async function setHedSchemas(dataset: BIDSContextDataset): Promise<HedIssue[]> {
2625
if (dataset.hedSchemas !== undefined) {
2726
return [] as HedIssue[]
2827
}
@@ -46,14 +45,8 @@ async function setHedSchemas(dataset: BIDSContextDataset) {
4645
}
4746
}
4847

49-
export interface HedIssue {
50-
code: number
51-
file: IssueFile
52-
evidence: string
53-
}
54-
5548
export async function hedValidate(
56-
schema: GenericSchema,
49+
_schema: GenericSchema,
5750
context: BIDSContext,
5851
): Promise<void> {
5952
let file
@@ -89,16 +82,16 @@ export async function hedValidate(
8982
const location = hedIssue.file ? hedIssue.file.path : ''
9083
context.dataset.issues.add({
9184
code: hedOldToNewLookup[code],
92-
// @ts-expect-error
93-
subCode: hedIssue.hedIssue.hedCode, // Hidden property
85+
// @ts-expect-error Hidden property
86+
subCode: hedIssue.hedIssue.hedCode,
9487
location,
9588
issueMessage: hedIssue.evidence,
9689
})
9790
}
9891
})
9992
}
10093

101-
function buildHedTsvFile(context: BIDSContext) {
94+
function buildHedTsvFile(context: BIDSContext): hedValidator.bids.BidsTsvFile {
10295
const eventFile = new hedValidator.bids.BidsTsvFile(
10396
context.path,
10497
context.columns,
@@ -109,7 +102,7 @@ function buildHedTsvFile(context: BIDSContext) {
109102
return eventFile
110103
}
111104

112-
function buildHedSidecarFile(context: BIDSContext) {
105+
function buildHedSidecarFile(context: BIDSContext): hedValidator.bids.BidsSidecar {
113106
const sidecarFile = new hedValidator.bids.BidsSidecar(
114107
context.path,
115108
context.json,

0 commit comments

Comments
 (0)