@miragon/slidev-validator 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/package.json +7 -6
- package/src/rules/index.mjs +2 -0
- package/src/rules/source/window-tabs.mjs +76 -0
package/README.md
CHANGED
|
@@ -141,6 +141,7 @@ config, so a report — and a CI log — is self-describing.
|
|
|
141
141
|
| `brand-palette` | source | required | error |
|
|
142
142
|
| `brand-logo-asset` | source | required | error |
|
|
143
143
|
| `brand-token-defined` | source | required | error |
|
|
144
|
+
| `window-tabs` | source | required | error |
|
|
144
145
|
| `element-overflow` | rendered | recommended | error |
|
|
145
146
|
| `heading-black` | rendered | required | error |
|
|
146
147
|
| `card-white` | rendered | required | error |
|
|
@@ -166,6 +167,11 @@ token, usually as something plausible-looking. A computed name
|
|
|
166
167
|
(`var(--miragon-gradient-${accent})`) cannot be resolved statically and is skipped
|
|
167
168
|
rather than guessed at.
|
|
168
169
|
|
|
170
|
+
`window-tabs` names every slide still written for the toolkit 1.x `code` layout
|
|
171
|
+
(`layout: code`, `files:`, `icons:`, `tabIcon:`, a slide-wide `lang:`) and every
|
|
172
|
+
malformed `tabs:` entry. Vue drops an unknown prop silently, so without it such a slide
|
|
173
|
+
would render with numbered, uncaptioned tabs and stay green.
|
|
174
|
+
|
|
169
175
|
`content-heading` has a per-slide opt-out (`allowMultilineHeading: true` in the
|
|
170
176
|
slide frontmatter). `overlay-safe-area` reads the toolkit-owned safe-area model and
|
|
171
177
|
cannot be switched off by a deck; its only escape hatch is a per-slide
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miragon/slidev-validator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Miragon Slidev deck validator: a configurable design-system linter (stable rule IDs, off/warn/error severities, extends/overrides/exceptions) shipped as a versioned CLI so central guardrail improvements reach decks over npm instead of a frozen copy.",
|
|
6
6
|
"keywords": [
|
|
@@ -33,15 +33,16 @@
|
|
|
33
33
|
"node": ">=20"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"markdown-it": "15.0.
|
|
37
|
-
"playwright-chromium": "1.63.0"
|
|
36
|
+
"markdown-it": "15.0.3"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@slidev/parser": "53.
|
|
39
|
+
"@slidev/parser": "53.1.0",
|
|
40
|
+
"playwright-chromium": "1.65.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@miragon/slidev-toolkit": ">=1.15.0 <
|
|
44
|
-
"@slidev/parser": "^53.0.0"
|
|
43
|
+
"@miragon/slidev-toolkit": ">=1.15.0 <3",
|
|
44
|
+
"@slidev/parser": "^53.0.0",
|
|
45
|
+
"playwright-chromium": "^1.65.0"
|
|
45
46
|
},
|
|
46
47
|
"files": [
|
|
47
48
|
"bin",
|
package/src/rules/index.mjs
CHANGED
|
@@ -22,6 +22,7 @@ import { excalidrawBuiltTransparent } from './source/excalidraw-built-transparen
|
|
|
22
22
|
import { brandPalette } from './source/brand-palette.mjs'
|
|
23
23
|
import { brandLogoAsset } from './source/brand-logo-asset.mjs'
|
|
24
24
|
import { brandTokenDefined } from './source/brand-token-defined.mjs'
|
|
25
|
+
import { windowTabs } from './source/window-tabs.mjs'
|
|
25
26
|
|
|
26
27
|
import { elementOverflow } from './rendered/element-overflow.mjs'
|
|
27
28
|
import { headingBlack } from './rendered/heading-black.mjs'
|
|
@@ -44,6 +45,7 @@ export const allRules = [
|
|
|
44
45
|
brandPalette,
|
|
45
46
|
brandLogoAsset,
|
|
46
47
|
brandTokenDefined,
|
|
48
|
+
windowTabs,
|
|
47
49
|
elementOverflow,
|
|
48
50
|
headingBlack,
|
|
49
51
|
cardWhite,
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import { parseSync } from '@slidev/parser'
|
|
3
|
+
import { toRel } from '../../helpers.mjs'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The `window` layout (toolkit 2.0, formerly `code`) takes every per-tab setting
|
|
7
|
+
* from one `tabs:` list. A key the layout no longer reads is dropped silently by
|
|
8
|
+
* Vue, so a slide written for the old `code` layout would render with numbered,
|
|
9
|
+
* uncaptioned tabs and stay green. This rule names each leftover instead.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const TAB_KEYS = new Set(['label', 'icon', 'caption', 'lang'])
|
|
13
|
+
|
|
14
|
+
const REMOVED_KEYS = {
|
|
15
|
+
files: 'use `tabs: [{ label }]`',
|
|
16
|
+
icons: 'set `icon` on the matching `tabs` entry',
|
|
17
|
+
tabIcon: 'set `icon` on each `tabs` entry',
|
|
18
|
+
lang: 'set `lang` on the matching `tabs` entry',
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function scanTab(tab, index) {
|
|
22
|
+
const where = `tabs[${index}]`
|
|
23
|
+
if (tab === null || typeof tab !== 'object' || Array.isArray(tab)) {
|
|
24
|
+
return [`${where} must be an object with a \`label\`, e.g. \`- label: Main.kt\``]
|
|
25
|
+
}
|
|
26
|
+
const reasons = []
|
|
27
|
+
if (typeof tab.label !== 'string' || !tab.label.trim()) reasons.push(`${where} needs a \`label\``)
|
|
28
|
+
for (const key of Object.keys(tab)) {
|
|
29
|
+
if (!TAB_KEYS.has(key)) reasons.push(`${where} has unknown key \`${key}\`; allowed are label, icon, caption, lang`)
|
|
30
|
+
}
|
|
31
|
+
if (tab.icon !== undefined && tab.icon !== false && typeof tab.icon !== 'string') {
|
|
32
|
+
reasons.push(`${where}.icon must be a Lucide class or false`)
|
|
33
|
+
}
|
|
34
|
+
for (const key of ['caption', 'lang']) {
|
|
35
|
+
if (tab[key] !== undefined && typeof tab[key] !== 'string') reasons.push(`${where}.${key} must be a string`)
|
|
36
|
+
}
|
|
37
|
+
return reasons
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Pure per-slide check (fixture-testable). Returns reasons; [] = ok. */
|
|
41
|
+
export function scanWindowSlide(frontmatter = {}) {
|
|
42
|
+
const reasons = []
|
|
43
|
+
if (frontmatter.layout === 'code') {
|
|
44
|
+
reasons.push('the `code` layout was renamed to `window` in @miragon/slidev-toolkit 2.0; set `layout: window` (see MIGRATION.md)')
|
|
45
|
+
} else if (frontmatter.layout !== 'window') {
|
|
46
|
+
return reasons
|
|
47
|
+
}
|
|
48
|
+
for (const [key, hint] of Object.entries(REMOVED_KEYS)) {
|
|
49
|
+
if (key in frontmatter) reasons.push(`\`${key}:\` was removed from the window layout in toolkit 2.0; ${hint}`)
|
|
50
|
+
}
|
|
51
|
+
if (frontmatter.tabs === undefined) return reasons
|
|
52
|
+
if (!Array.isArray(frontmatter.tabs)) return [...reasons, '`tabs:` must be a list with one entry per tab']
|
|
53
|
+
return [...reasons, ...frontmatter.tabs.flatMap(scanTab)]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const windowTabs = {
|
|
57
|
+
id: 'window-tabs',
|
|
58
|
+
type: 'source',
|
|
59
|
+
title: 'window slides configure their tabs in `tabs:`',
|
|
60
|
+
message: 'A window slide takes label, icon, caption and lang per tab from `tabs:`; the old code-layout keys are gone',
|
|
61
|
+
meta: { category: 'required', default: 'error' },
|
|
62
|
+
check({ sourceFiles = [] } = {}) {
|
|
63
|
+
const offenders = []
|
|
64
|
+
for (const file of sourceFiles) {
|
|
65
|
+
const rel = toRel(file)
|
|
66
|
+
const parsed = parseSync(readFileSync(file, 'utf8'), file)
|
|
67
|
+
for (const slide of parsed.slides) {
|
|
68
|
+
if (slide.frontmatter?.src) continue
|
|
69
|
+
for (const reason of scanWindowSlide(slide.frontmatter)) {
|
|
70
|
+
offenders.push({ file: rel, line: (slide.start ?? 0) + 1, message: reason })
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return offenders
|
|
75
|
+
},
|
|
76
|
+
}
|