diff --git a/internal/check-selection-kinds.mjs b/internal/check-selection-kinds.mjs index ee4ef0079..7dff731d2 100644 --- a/internal/check-selection-kinds.mjs +++ b/internal/check-selection-kinds.mjs @@ -131,8 +131,17 @@ for (const fn of ['onLegendExport', 'makeSelectionPacket', 'makeSelectionPoster' 'onLegendExport no longer splits the kind — a packet: emit would fall through as an unknown kind and print nothing') for (const kind of emitted) { const [base] = kind.split(':') - ok(base === 'poster' || base === 'packet', - `the legend emits '${kind}', whose base '${base}' is neither poster nor packet — the plugin's handler has no branch for it`) + if (base === 'poster' || base === 'packet') continue + // ★ AN OPT-IN ITEM IS ONLY THIS PLUGIN'S PROBLEM IF THIS PLUGIN OPTS IN. The card deck ('cards') sits + // behind v-if="exportCards", a prop that defaults to false: countries-map passes it and handles it, + // and a legend here that never shows the item cannot emit it. So an item guarded by a prop is + // required to have a handler branch only when upg-100-list.vue passes that prop. + const line = LEGEND.split('\n').find((l) => l.includes(`emitExport('${kind}')`)) || '' + const guard = (line.match(/v-if="(\w+)"/) || [])[1] + const kebab = guard && guard.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase()) + const optedIn = !!guard && new RegExp(`[\\s:](?:${kebab}|${guard})\\b`).test(VUE) + ok(guard && !optedIn, + `the legend emits '${kind}', whose base '${base}' is neither poster nor packet — ${optedIn ? `upg-100-list passes ${guard}, but ` : ''}the plugin's handler has no branch for it`) } // The variant must actually travel to the renderer. Asserting the split alone would pass while // the parsed value was dropped on the floor.