Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | 62x 68x 62x 68x 66x 76x 134x 134x 2x 44x 37x 64x 20x 152x 22x 22x 22x 28x 28x 28x 3x 22x 22x 25x 25x 28x 23x 22x 22x 22x 22x 22x 22x 136x 48x 3x 3x 134x 134x 22x 45x 21x 21x 1x 22x 20x 1x 22x 22x 22x 20x 20x 4x 22x 16x 1x 22x 22x 22x 15x 15x 22x 15x 112x 112x 24x 24x 3x 112x 112x 21x 21x 2x 112x 19x 22x 22x 176x 64x 22x 176x 152x 22x | import type { LintIssue, LintResult } from '@/layers/interfaces'
// Mirrors api/internal/handlers/lanes.go LintLaneConfig exactly (ADR-0012):
// same rule semantics, same message strings, same warning emission order.
// The lint is wired to the pipeline `config` field, so `parsed` is the full
// pipeline config object ({ vikunja?: { lanes?: ... } }).
const LANE_KEYS = new Set([
'start',
'open_questions',
'blocked',
'in_progress',
'pr_open',
'needs_rework',
'done',
'pr_rejected',
'failed',
])
const OPTIONAL_LANE_KEYS = [
'open_questions',
'blocked',
'in_progress',
'pr_open',
'needs_rework',
'done',
'pr_rejected',
'failed',
] as const
function isPlainObject(value: unknown): value is Record<string, unknown> {
return typeof value === 'object' && value !== null && !Array.isArray(value)
}I
// Mirrors parseLaneID: the value must be a positive integer. YAML numbers
// arrive as JS numbers; string literals like "1" are rejected, as are
// fractions and non-positive values.
function positiveInteger(raw: unknown): number | null {
if (typeof raw !== 'number' || !Number.isInteger(raw) || raw <= 0) return null
return raw
}
function error(field: string, message: string): LintIssue {
return { field, message }
}
function warning(field: string, message: string): LintIssue {
return { field, message }
}
eIxport function laneLint(parsed: unknown, _raw: string): LintResult {
const errors: LintIssue[] = []
const warnings: LintIssue[] = []
if (!isPlainObject(parsed)) {
return { errors: [error('config', 'config must be a JSON object')], warnings }
}
I const vikunja = parsed['vikunja']
const lanes = isPlainObject(vikunja) ? vikunja['lanes'] : undefined
if (lanes === undefined) return { errors, warnings }
if (!isPlainObject(lanes)) {
I return {
errors: [error('vikunja.lanes', 'vikunja.lanes: must be a JSON object')],
warnings,
}
}
const configured = new Set<string>()
let startPresent = false
const seenStart = new Set<number>()
const owner = new Map<number, string>()
for (const [key, raw] of Object.entries(lanes)) {
if (!LANE_KEYS.has(key)) {
errors.push(error('vikunja.lanes', `vikunja.lanes: unknown lane key "${key}"`))
continue
}
configured.add(key)
I if (key === 'start') {
startPresent = true
if (!Array.isArray(raw)) {
errors.push(error('vikunja.lanes.start', 'vikunja.lanes.start: must be an array of positive integers'))
I continue
}
if (raw.length === 0) {
errors.push(error('vikunja.lanes.start', 'vikunja.lanes.start: must contain at least one bucket id'))
continue
}
I for (const el of raw) {
const id = positiveInteger(el)
if (id === null) {
errors.push(error('vikunja.lanes.start', 'vikunja.lanes.start: must be a positive integer'))
I continue
}
if (seenStart.has(id)) {
errors.push(error('vikunja.lanes.start', `vikunja.lanes.start: duplicate bucket id ${id}`))
continue
}
I seenStart.add(id)
const prev = owner.get(id)
Iif (prev !== undefined) {
errors.push(error('vikunja.lanes', `vikunja.lanes: duplicate bucket id ${id} across lanes (${prev}, start)`))
continue
}
owner.set(id, 'start')
}
I } else {
const id = positiveInteger(raw)
if (id === null) {
errors.push(error(`vikunja.lanes.${key}`, `vikunja.lanes.${key}: must be a positive integer`))
continue
I }
const prev = owner.get(id)
if (prev !== undefined) {
errors.push(error('vikunja.lanes', `vikunja.lanes: duplicate bucket id ${id} across lanes (${prev}, ${key})`))
continue
}
owner.set(id, key)
I }
}
if (!startPresent) {
errors.push(error('vikunja.lanes.start', 'vikunja.lanes.start: is required'))
}
for (const key of OPTIONAL_LANE_KEYS) {
if (!configured.has(key)) {
warnings.push(warning(`vikunja.lanes.${key}`, `vikunja.lanes.${key}: not configured`))
}
}
return { errors, warnings }
}
|