@alis-build/design-system 0.18.0 → 0.19.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 CHANGED
@@ -17,9 +17,12 @@ product screens in any framework: Svelte, Vue, or plain HTML.
17
17
  | `tokens.json` | The source of every value: each colour tagged palette, product or narrative, each product role with a value per theme. References such as `{cyan-600}` are left in; read `tokens.css` or `themes.json` rather than resolving them. For code written before themes, each product role also keeps a `value` (its light one), and each shadow its light literal as `value` beside `values` per theme. |
18
18
  | `marks.json` | The capability marks (`alis_*`): construction, stroke grade by size, geometry, in canonical order. |
19
19
  | `assets/Brand/` | The Alis mark, product lockups, app icon and favicon. |
20
+ | `stylelint.mjs` | The style check that restates `rules/styling.md`, as a stylelint config your own extends. |
21
+ | `classes.json` | Every class and custom property `alisx.css` defines in this version. |
22
+ | `check.mjs` | `alisx-check`: runs the two checks below in your build. |
20
23
 
21
24
  ```bash
22
- pnpm add @alis-build/design-system
25
+ pnpm add -E @alis-build/design-system
23
26
  ```
24
27
 
25
28
  ```js
@@ -32,6 +35,89 @@ import tokens from '@alis-build/design-system/tokens.json' with { type: 'json' }
32
35
  `"system"` to follow the operating system, on `<html>` or on any element
33
36
  ([rules/themes.md](rules/themes.md)). Choosing the theme is your app's job.
34
37
 
38
+ ## Keep an app in line
39
+
40
+ Three things, set up once, so the next change stays consistent whoever makes it.
41
+
42
+ **1. Point your agents at the rules.** In your app's `CLAUDE.md` or `AGENTS.md`:
43
+
44
+ ```md
45
+ The UI is built from @alis-build/design-system. Before changing a screen, read
46
+ node_modules/@alis-build/design-system/rules/README.md and follow its "Where to
47
+ start". The rules there are the version this app has installed.
48
+ ```
49
+
50
+ Never copy the rules into your repo: a copy stops moving with the version.
51
+
52
+ **2. Check your styles.** Add `stylelint` (16 or later) as a dev dependency,
53
+ with `postcss-html` if you have `<style>` blocks in Svelte or Vue files and
54
+ `postcss-scss` if any of them is `lang="scss"` (without it those blocks are
55
+ skipped, silently). Then in `stylelint.config.js`:
56
+
57
+ ```js
58
+ export default {
59
+ extends: ['@alis-build/design-system/stylelint'],
60
+ overrides: [{ files: ['**/*.svelte', '**/*.vue'], customSyntax: 'postcss-html' }],
61
+ }
62
+ ```
63
+
64
+ - **A rule you set under the same name replaces the system's**: stylelint never
65
+ merges two lists. To add to one, carry the system's part along. The config
66
+ exports its parts (`refusedValues`, `allowedValues`, `refusedProperties`,
67
+ `refusedSelectors`) and two builders:
68
+
69
+ ```js
70
+ import { refuse, refusedValues } from '@alis-build/design-system/stylelint'
71
+ export default {
72
+ extends: ['@alis-build/design-system/stylelint'],
73
+ rules: {
74
+ 'declaration-property-value-disallowed-list': refuse([
75
+ ...refusedValues,
76
+ { properties: 'cursor', values: ['wait'], message: 'A busy control shows its own spinner.' },
77
+ ]),
78
+ },
79
+ }
80
+ ```
81
+
82
+ - **When nothing in `rules/styling.md` fits, the system has a gap.** Say so on
83
+ the line above, and name it when you hand the work back. A disable with no
84
+ reason is itself reported.
85
+
86
+ ```css
87
+ /* stylelint-disable-next-line declaration-no-important -- GAP: a hidden element stays hidden */
88
+ [hidden] { display: none !important; }
89
+ ```
90
+
91
+ - It reads what is written in CSS. A value held in a Sass variable or a mixin,
92
+ or a literal behind a custom property of your own (`--pad: 13px`), is not seen.
93
+
94
+ **3. Run both checks in your build.**
95
+
96
+ ```json
97
+ "scripts": {
98
+ "lint:names": "alisx-check names src",
99
+ "lint:styles": "alisx-check styles \"src/**/*.{css,svelte,vue}\"",
100
+ "lint:styles:record": "alisx-check styles \"src/**/*.{css,svelte,vue}\" --update"
101
+ }
102
+ ```
103
+
104
+ - `alisx-check names` fails on a system class (`app-*`, `text-*`) or a custom
105
+ property this version doesn't have: a misspelling, or a name a release
106
+ removed. Pass `--prefix app-` if your app has `text-*` utilities of its own,
107
+ and `--allow '--brand-*'` for a property that arrives from outside your source.
108
+ - `alisx-check styles` is a gate: any violation fails. An app with a backlog
109
+ records it once (`lint:styles:record`) and commits
110
+ `alisx-style-baseline.json`; from then on it is a ratchet, failing only when a
111
+ file gains violations of a rule. The baseline holds the package version it was
112
+ recorded against: after an upgrade the check says so, because the rules may
113
+ have changed. Re-record only after an intentional change, never to clear a
114
+ failure, and say in the commit why the number moved.
115
+ - Both stop with exit code 2, never pass, when they could not run as set up: a
116
+ rule stylelint rejected, a file that didn't parse, no files matched.
117
+
118
+ Pin an exact version (`pnpm add -E`, `npm install -E`), so the rules, the
119
+ classes and the checks move together.
120
+
35
121
  The package root has no JavaScript entry: import the files above by path.
36
122
  Pin an exact version from a CDN with
37
123
  `https://cdn.jsdelivr.net/npm/@alis-build/design-system@<version>/alisx.css`.
package/check.mjs ADDED
@@ -0,0 +1,228 @@
1
+ #!/usr/bin/env node
2
+ // alisx-check: the two checks an app built on @alis-build/design-system runs in
3
+ // its build. Neither needs a framework; both read your source as text.
4
+ //
5
+ // alisx-check names <path…> [--prefix app-] [--allow '--brand-*']
6
+ // Fails on a system class or a custom property this version of the package
7
+ // doesn't have: a misspelling, or a name a release removed. Without it a
8
+ // wrong name renders unstyled and nothing says so.
9
+ // --prefix the class prefixes that belong to the system (default: app-
10
+ // and text-; an app with its own text-* utilities passes app-)
11
+ // --allow a custom property that arrives from outside your source
12
+ // It reads a class where one is written (a selector, a class attribute, a
13
+ // class directive, classList), not a name held in a script string.
14
+ //
15
+ // alisx-check styles <glob…> [--baseline <file>] [--update]
16
+ // Runs your stylelint config (which extends ./stylelint, the check that
17
+ // restates rules/styling.md). With no baseline it is a gate: any violation
18
+ // fails. With one it is a ratchet: it fails only when a file gains
19
+ // violations of a rule, so a backlog doesn't block new work. --update
20
+ // records the baseline (default alisx-style-baseline.json, where you run
21
+ // it); do that only after an intentional change, never to clear a failure.
22
+ import { existsSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
23
+ import { spawnSync } from 'node:child_process'
24
+ import { tmpdir } from 'node:os'
25
+ import { dirname, extname, join, relative, resolve, sep } from 'node:path'
26
+ import { fileURLToPath } from 'node:url'
27
+
28
+ const here = dirname(fileURLToPath(import.meta.url))
29
+ const { version } = JSON.parse(readFileSync(join(here, 'package.json'), 'utf8'))
30
+ const usage = 'usage: alisx-check names <path…> [--prefix app-] [--allow <property>]\n alisx-check styles <glob…> [--baseline <file>] [--update]'
31
+ const [command, ...argv] = process.argv.slice(2)
32
+
33
+ const paths = []
34
+ const options = { prefix: [], allow: [], baseline: 'alisx-style-baseline.json', update: false }
35
+ for (let i = 0; i < argv.length; i++) {
36
+ const arg = argv[i]
37
+ if (arg === '--update') options.update = true
38
+ else if (arg === '--baseline' || arg === '--prefix' || arg === '--allow') {
39
+ const value = argv[++i]
40
+ // --allow takes a property, which itself starts with two dashes.
41
+ if (!value || (arg !== '--allow' && value.startsWith('--'))) stop(`${arg} needs a value.\n${usage}`)
42
+ if (arg === '--baseline') options.baseline = value
43
+ else options[arg.slice(2)].push(value)
44
+ } else if (arg.startsWith('--')) stop(`Unknown option ${arg}.\n${usage}`)
45
+ else paths.push(arg)
46
+ }
47
+
48
+ if (command === 'names' && paths.length) names()
49
+ else if (command === 'styles' && paths.length) styles()
50
+ else stop(usage)
51
+
52
+ function names() {
53
+ const inventory = JSON.parse(readFileSync(join(here, 'classes.json'), 'utf8'))
54
+ const classes = new Set(inventory.classes)
55
+ const properties = new Set(inventory.properties)
56
+ const prefixes = (options.prefix.length ? options.prefix : ['app-', 'text-']).map(escape).join('|')
57
+ const allowed = options.allow.map((glob) => new RegExp(`^${glob.split('*').map(escape).join('.*')}$`))
58
+
59
+ const sources = ['.svelte', '.vue', '.html', '.jsx', '.tsx', '.js', '.ts', '.mjs', '.css', '.scss', '.less']
60
+ const missing = paths.filter((path) => !existsSync(path))
61
+ if (missing.length) stop(`alisx-check names: no such path: ${missing.join(', ')}`)
62
+ const files = paths.flatMap((path) => walk(resolve(path))).filter((file) => sources.includes(extname(file)))
63
+ if (!files.length) stop(`alisx-check names: no source files under ${paths.join(', ')}.`)
64
+ const texts = new Map(files.map((file) => [file, readFileSync(file, 'utf8')]))
65
+
66
+ // A property your own source declares is yours, wherever it is used.
67
+ // Declared: `--x: …` in a rule or an object, style:--x on an element,
68
+ // setProperty('--x', …) in script.
69
+ const declared = [/(?:^|[\s{;"'`])(--[\w-]+)["'`]?\s*:/g, /\bstyle:(--[\w-]+)/g, /setProperty\(\s*["'`](--[\w-]+)/g]
70
+ for (const text of texts.values())
71
+ for (const pattern of declared) for (const [, name] of text.matchAll(pattern)) properties.add(name)
72
+
73
+ // A class is read where a class is written: a selector, a class attribute, a
74
+ // class directive, classList. Anywhere else the same letters are not a class.
75
+ const token = new RegExp(`(?<![\\w-])((?:${prefixes})[\\w-]*[A-Za-z0-9])(?![\\w-]|\\{|\\$)`, 'g')
76
+ const selector = new RegExp(`(?<![\\w/-])\\.((?:${prefixes})[\\w-]*[A-Za-z0-9])`, 'g')
77
+ const written = [
78
+ /\bclass(?:Name)?\s*=\s*(?:"([^"]*)"|'([^']*)'|\{([^}]*)\})/g,
79
+ /\bclass:([\w-]+)/g,
80
+ /\bclassList\.\w+\(([^)]*)\)/g,
81
+ ]
82
+
83
+ const problems = []
84
+ let uses = 0
85
+ for (const [file, text] of texts) {
86
+ const line = (index) => text.slice(0, index).split('\n').length
87
+ const seen = (name, index, known, kind) => {
88
+ uses++
89
+ if (!known.has(name)) problems.push(`${relative(process.cwd(), file)}:${line(index)} ${kind} ${name}`)
90
+ }
91
+ for (const match of text.matchAll(selector)) seen(match[1], match.index, classes, 'class')
92
+ for (const pattern of written)
93
+ for (const match of text.matchAll(pattern))
94
+ for (const found of (match[1] ?? match[2] ?? match[3] ?? '').matchAll(token)) seen(found[1], match.index, classes, 'class')
95
+ for (const match of text.matchAll(/var\(\s*(--[\w-]+)/g))
96
+ if (!allowed.some((pattern) => pattern.test(match[1]))) seen(match[1], match.index, properties, 'property')
97
+ }
98
+
99
+ if (!problems.length) {
100
+ console.log(`alisx-check names: ok. ${uses} uses in ${files.length} files, all in @alis-build/design-system@${version}.`)
101
+ return
102
+ }
103
+ console.error(`\nalisx-check names: not in @alis-build/design-system@${version}, and not declared in your source.\n`)
104
+ for (const problem of [...new Set(problems)]) console.error(` ${problem}`)
105
+ console.error('\nA misspelling, or a name this version removed: components/ and tokens.css in the package have the names.\n')
106
+ process.exit(1)
107
+ }
108
+
109
+ function styles() {
110
+ const bin = findUp(join('node_modules', '.bin', 'stylelint'))
111
+ if (!bin) stop('alisx-check styles: stylelint is not installed in this app. Add stylelint 16 or later as a dev dependency.')
112
+
113
+ // The report goes to a file: stylelint's own stream for it changed between
114
+ // versions, and it also echoes the report, so the pipe must not cap it.
115
+ const report = join(mkdtempSync(join(tmpdir(), 'alisx-check-')), 'report.json')
116
+ const run = spawnSync(bin, ['--formatter', 'json', '--output-file', report, ...paths], { encoding: 'utf8', maxBuffer: Infinity })
117
+ let results
118
+ try {
119
+ results = JSON.parse(readFileSync(report, 'utf8'))
120
+ } catch {
121
+ // No report: stylelint itself failed (no files matched, a config that won't load).
122
+ }
123
+ rmSync(dirname(report), { recursive: true, force: true })
124
+ if (!results) stop(`alisx-check styles: stylelint did not run.\n\n${(run.stderr || run.stdout || String(run.error)).trim()}`)
125
+
126
+ // A rule that didn't run, or a file that didn't parse, reports nothing: that
127
+ // would read as an improvement. Stop instead.
128
+ const broken = []
129
+ for (const result of results) {
130
+ for (const each of result.invalidOptionWarnings ?? []) broken.push(each.text)
131
+ for (const each of result.parseErrors ?? []) broken.push(`${result.source}: ${each.text}`)
132
+ for (const each of result.warnings) if (each.rule === 'CssSyntaxError') broken.push(`${result.source}:${each.line}: ${each.text}`)
133
+ }
134
+ if (broken.length)
135
+ stop(
136
+ `alisx-check styles: the check could not run as configured, so nothing was compared.\n\n ${[...new Set(broken)].join('\n ')}\n\nA file with a <style> block needs its syntax in your stylelint config (postcss-html; postcss-scss for lang="scss").`,
137
+ )
138
+
139
+ // Keyed by the file's path from the baseline's own directory, so the same
140
+ // baseline reads the same wherever the command is run from.
141
+ const root = dirname(resolve(options.baseline))
142
+ const key = (source) => relative(root, source).split(sep).join('/')
143
+ const now = {}
144
+ const linted = new Set()
145
+ for (const result of results) {
146
+ const path = key(result.source)
147
+ linted.add(path)
148
+ for (const { rule } of result.warnings) {
149
+ now[path] ??= {}
150
+ now[path][rule] = (now[path][rule] ?? 0) + 1
151
+ }
152
+ }
153
+ const total = (files) => Object.values(files).reduce((sum, rules) => sum + Object.values(rules).reduce((a, b) => a + b, 0), 0)
154
+
155
+ let baseline = null
156
+ if (existsSync(options.baseline)) {
157
+ try {
158
+ baseline = JSON.parse(readFileSync(options.baseline, 'utf8'))
159
+ if (!baseline.files) throw new Error('it has no "files"')
160
+ } catch (error) {
161
+ stop(`alisx-check styles: ${options.baseline} can't be read (${error.message}). Restore it from version control, or re-record it with --update and say why in the commit.`)
162
+ }
163
+ }
164
+ // A file the baseline names that this run didn't lint keeps its entry while
165
+ // it exists: a run over part of the app says nothing about the rest.
166
+ const unseen = Object.fromEntries(Object.entries(baseline?.files ?? {}).filter(([path]) => !linted.has(path) && existsSync(join(root, path))))
167
+
168
+ if (options.update) {
169
+ const files = Object.fromEntries(Object.entries({ ...unseen, ...now }).sort(([a], [b]) => a.localeCompare(b)))
170
+ writeFileSync(options.baseline, `${JSON.stringify({ version, files }, null, 2)}\n`)
171
+ console.log(`alisx-check styles: recorded ${total(files)} violations across ${Object.keys(files).length} files in ${options.baseline}, against @alis-build/design-system@${version}.`)
172
+ return
173
+ }
174
+
175
+ const was = baseline?.files ?? {}
176
+ const worse = []
177
+ for (const [path, rules] of Object.entries(now))
178
+ for (const [rule, count] of Object.entries(rules)) if (count > (was[path]?.[rule] ?? 0)) worse.push({ path, rule, from: was[path]?.[rule] ?? 0, to: count })
179
+ let saved = 0
180
+ for (const [path, rules] of Object.entries(was))
181
+ if (!(path in unseen)) for (const [rule, count] of Object.entries(rules)) saved += Math.max(0, count - (now[path]?.[rule] ?? 0))
182
+
183
+ if (baseline && baseline.version !== version)
184
+ console.log(
185
+ `alisx-check styles: the baseline was recorded against @alis-build/design-system@${baseline.version}; ${version} is installed, and its rules may differ. If a change below comes from the rules and not from your code, re-record with --update and say so in the commit.`,
186
+ )
187
+ if (saved) console.log(`alisx-check styles: ${saved} fewer violations than the baseline. Run with --update to lock that in.`)
188
+ if (!worse.length) {
189
+ console.log(`alisx-check styles: ok. ${total(now) ? `${total(now)} known violations, none new` : 'No violations'}.`)
190
+ return
191
+ }
192
+
193
+ console.error(`\nalisx-check styles: ${baseline ? 'more violations than the baseline' : 'violations'}.\n`)
194
+ for (const { path, rule, from, to } of worse) {
195
+ console.error(` ${path} ${rule} ${from} → ${to}`)
196
+ const warnings = results.find((result) => key(result.source) === path).warnings.filter((warning) => warning.rule === rule)
197
+ for (const warning of warnings.slice(0, 20)) console.error(` ${warning.line}:${warning.column} ${warning.text.replace(` (${rule})`, '')}`)
198
+ if (warnings.length > 20) console.error(` … and ${warnings.length - 20} more`)
199
+ }
200
+ console.error(
201
+ '\nEvery rule is a row of rules/styling.md in @alis-build/design-system. If nothing there fits, the\nsystem has a gap: say so on the line above, and name it when you hand the work back.\n\n /* stylelint-disable-next-line <rule> -- GAP: what this needs */\n',
202
+ )
203
+ process.exit(1)
204
+ }
205
+
206
+ function walk(path) {
207
+ if (!statSync(path).isDirectory()) return [path]
208
+ return readdirSync(path, { withFileTypes: true })
209
+ .filter((entry) => !entry.name.startsWith('.') && entry.name !== 'node_modules' && entry.name !== 'dist')
210
+ .flatMap((entry) => walk(join(path, entry.name)))
211
+ }
212
+
213
+ function findUp(target) {
214
+ for (let dir = process.cwd(); ; dir = dirname(dir)) {
215
+ if (existsSync(join(dir, target))) return join(dir, target)
216
+ if (dir === dirname(dir)) return null
217
+ }
218
+ }
219
+
220
+ function escape(text) {
221
+ return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
222
+ }
223
+
224
+ // A setup problem, as opposed to a finding: exit 2.
225
+ function stop(message) {
226
+ console.error(message)
227
+ process.exit(2)
228
+ }
package/classes.json ADDED
@@ -0,0 +1,553 @@
1
+ {
2
+ "classes": [
3
+ "app-account",
4
+ "app-account__avatar",
5
+ "app-account__text",
6
+ "app-ai-ground",
7
+ "app-ai-text",
8
+ "app-alert",
9
+ "app-alert--error",
10
+ "app-alert--stacked",
11
+ "app-alert--success",
12
+ "app-alert--warning",
13
+ "app-alert__actions",
14
+ "app-alert__body",
15
+ "app-alert__title",
16
+ "app-ask",
17
+ "app-ask__actions",
18
+ "app-ask__body",
19
+ "app-ask__grants",
20
+ "app-ask__head",
21
+ "app-ask__key",
22
+ "app-ask__line",
23
+ "app-ask__note",
24
+ "app-ask__option",
25
+ "app-ask__option-text",
26
+ "app-ask__options",
27
+ "app-ask__page",
28
+ "app-ask__title",
29
+ "app-attachment",
30
+ "app-attachment--image",
31
+ "app-attachment--message",
32
+ "app-attachment__bar",
33
+ "app-attachment__external",
34
+ "app-attachment__glyph",
35
+ "app-attachment__text",
36
+ "app-brand",
37
+ "app-brand__wordmark",
38
+ "app-btn",
39
+ "app-btn--error",
40
+ "app-btn--filled",
41
+ "app-btn--outlined",
42
+ "app-btn--quiet",
43
+ "app-btn--small",
44
+ "app-btn-row",
45
+ "app-btn-row--end",
46
+ "app-btn__spinner",
47
+ "app-card",
48
+ "app-card--instrument",
49
+ "app-card--statement",
50
+ "app-card__inset",
51
+ "app-card__title",
52
+ "app-chip",
53
+ "app-chip--cat1",
54
+ "app-chip--cat2",
55
+ "app-chip--cat3",
56
+ "app-chip--cat4",
57
+ "app-chip--cat5",
58
+ "app-chip--cat6",
59
+ "app-chip--error",
60
+ "app-chip--icon",
61
+ "app-chip--info",
62
+ "app-chip--opaque",
63
+ "app-chip--outlined",
64
+ "app-chip--small",
65
+ "app-chip--success",
66
+ "app-chip--warning",
67
+ "app-chip-group",
68
+ "app-chip__close",
69
+ "app-compact-only",
70
+ "app-composer",
71
+ "app-composer__box",
72
+ "app-composer__drop",
73
+ "app-composer__editor",
74
+ "app-composer__go",
75
+ "app-composer__go--plain",
76
+ "app-composer__input",
77
+ "app-composer__interim",
78
+ "app-composer__light",
79
+ "app-composer__line",
80
+ "app-composer__line-action",
81
+ "app-composer__meter",
82
+ "app-composer__rec",
83
+ "app-composer__row",
84
+ "app-composer__spacer",
85
+ "app-composer__status",
86
+ "app-composer__timer",
87
+ "app-composer__tray",
88
+ "app-count",
89
+ "app-dialog",
90
+ "app-dialog__body",
91
+ "app-dialog__title",
92
+ "app-empty",
93
+ "app-empty-field",
94
+ "app-empty-line",
95
+ "app-empty__headline",
96
+ "app-empty__line",
97
+ "app-field",
98
+ "app-field__box",
99
+ "app-field__box--select",
100
+ "app-field__input",
101
+ "app-field__label",
102
+ "app-field__row",
103
+ "app-field__select",
104
+ "app-field__support",
105
+ "app-field__values",
106
+ "app-fieldset",
107
+ "app-fieldset__legend",
108
+ "app-fieldset__support",
109
+ "app-file-pane",
110
+ "app-file-pane__bar",
111
+ "app-file-pane__body",
112
+ "app-file-pane__body--image",
113
+ "app-file-pane__body--paper",
114
+ "app-file-pane__body--prose",
115
+ "app-file-pane__body--source",
116
+ "app-file-pane__body--table",
117
+ "app-file-pane__expand",
118
+ "app-file-pane__frame",
119
+ "app-file-pane__line",
120
+ "app-file-pane__name",
121
+ "app-file-pane__source",
122
+ "app-file-pane__state",
123
+ "app-file-pane__tools",
124
+ "app-file-pane__word",
125
+ "app-filterrow",
126
+ "app-filterrow__controls",
127
+ "app-filterrow__search",
128
+ "app-filterrow__summary",
129
+ "app-form",
130
+ "app-icon",
131
+ "app-icon--24",
132
+ "app-icon--filled",
133
+ "app-icon--mark",
134
+ "app-icon-btn",
135
+ "app-icon-btn--small",
136
+ "app-key",
137
+ "app-keys",
138
+ "app-keys--single",
139
+ "app-keys__said",
140
+ "app-keys__then",
141
+ "app-lattice",
142
+ "app-lattice__eyebrow",
143
+ "app-list",
144
+ "app-loader",
145
+ "app-loader--line",
146
+ "app-machine",
147
+ "app-menu",
148
+ "app-menu--suggest",
149
+ "app-menu__avatar",
150
+ "app-menu__divider",
151
+ "app-menu__empty",
152
+ "app-menu__heading",
153
+ "app-menu__hint",
154
+ "app-menu__item",
155
+ "app-menu__item--danger",
156
+ "app-menu__support",
157
+ "app-menu__text",
158
+ "app-nav-heading",
159
+ "app-progress",
160
+ "app-progress__fill",
161
+ "app-progress__head",
162
+ "app-progress__track",
163
+ "app-progress__value",
164
+ "app-qa",
165
+ "app-qa__a",
166
+ "app-qa__pair",
167
+ "app-qa__q",
168
+ "app-row",
169
+ "app-row--agent-chat",
170
+ "app-row--divided",
171
+ "app-row--nav",
172
+ "app-row__hit",
173
+ "app-row__icon",
174
+ "app-row__meta",
175
+ "app-row__text",
176
+ "app-row__trailing",
177
+ "app-scrim",
178
+ "app-scrim--inline",
179
+ "app-search",
180
+ "app-search__clear",
181
+ "app-search__input",
182
+ "app-seg",
183
+ "app-seg__item",
184
+ "app-shell",
185
+ "app-shell--detail",
186
+ "app-shell--file",
187
+ "app-shell--file-expanded",
188
+ "app-shell--nav-open",
189
+ "app-shell__content",
190
+ "app-shell__detail",
191
+ "app-shell__main",
192
+ "app-shell__nav",
193
+ "app-shell__nav-close",
194
+ "app-shell__nav-foot",
195
+ "app-shortcuts",
196
+ "app-shortcuts__foot",
197
+ "app-shortcuts__group",
198
+ "app-shortcuts__heading",
199
+ "app-shortcuts__note",
200
+ "app-shortcuts__row",
201
+ "app-skel",
202
+ "app-skel__bar",
203
+ "app-skel__bar--block",
204
+ "app-skel__bar--short",
205
+ "app-skel__bar--title",
206
+ "app-skel__dot",
207
+ "app-skel__lines",
208
+ "app-skel__row",
209
+ "app-skel__row--plain",
210
+ "app-snackbar",
211
+ "app-snackbar--inline",
212
+ "app-snackbar__text",
213
+ "app-state",
214
+ "app-statement-over-gradient",
215
+ "app-step",
216
+ "app-steps",
217
+ "app-switch",
218
+ "app-switch-row",
219
+ "app-switch-row__text",
220
+ "app-tab",
221
+ "app-table",
222
+ "app-table--sticky",
223
+ "app-table-wrap",
224
+ "app-table__primary",
225
+ "app-tabs",
226
+ "app-target",
227
+ "app-target--none",
228
+ "app-thread",
229
+ "app-thread__event",
230
+ "app-thread__status",
231
+ "app-thread__typing",
232
+ "app-tile",
233
+ "app-tile-group",
234
+ "app-tile__check",
235
+ "app-titlebar",
236
+ "app-titlebar--detail",
237
+ "app-titlebar__actions",
238
+ "app-titlebar__label",
239
+ "app-titlebar__lead",
240
+ "app-titlebar__leading",
241
+ "app-titlebar__name",
242
+ "app-titlebar__row",
243
+ "app-titlebar__title",
244
+ "app-token",
245
+ "app-tooltip",
246
+ "app-turn",
247
+ "app-turn--alis",
248
+ "app-turn--them",
249
+ "app-turn--you",
250
+ "app-turn__about",
251
+ "app-turn__avatar",
252
+ "app-turn__avatar--alis",
253
+ "app-turn__bubble",
254
+ "app-turn__bubble--voice",
255
+ "app-turn__caret",
256
+ "app-turn__files",
257
+ "app-turn__foot",
258
+ "app-turn__head",
259
+ "app-turn__image",
260
+ "app-turn__line",
261
+ "app-turn__line-action",
262
+ "app-turn__mark",
263
+ "app-turn__output",
264
+ "app-turn__record",
265
+ "app-turn__request",
266
+ "app-turn__row",
267
+ "app-turn__status",
268
+ "app-turn__step",
269
+ "app-turn__steps",
270
+ "app-turn__tools",
271
+ "app-turn__who",
272
+ "app-turn__worked",
273
+ "app-voice",
274
+ "app-voice-note",
275
+ "app-voice-note__more",
276
+ "app-voice-note__player",
277
+ "app-voice-note__time",
278
+ "app-voice-note__transcript",
279
+ "app-voice-note__wave",
280
+ "app-voice__body",
281
+ "app-voice__caption",
282
+ "app-voice__controls",
283
+ "app-voice__end",
284
+ "app-voice__orb",
285
+ "app-voice__round",
286
+ "app-voice__said",
287
+ "app-voice__title",
288
+ "app-voice__top",
289
+ "app-wide-only",
290
+ "ax-field",
291
+ "ax-field__glow",
292
+ "ax-field__grid",
293
+ "ax-field__noise",
294
+ "drop-target",
295
+ "is-active",
296
+ "is-alis",
297
+ "is-current",
298
+ "is-disabled",
299
+ "is-done",
300
+ "is-dragged",
301
+ "is-error",
302
+ "is-failed",
303
+ "is-gone",
304
+ "is-interactive",
305
+ "is-latest",
306
+ "is-loading",
307
+ "is-locked",
308
+ "is-muted",
309
+ "is-numeric",
310
+ "is-open",
311
+ "is-played",
312
+ "is-selected",
313
+ "mono",
314
+ "mono-sm",
315
+ "mono-xs",
316
+ "narrative-body",
317
+ "narrative-deck",
318
+ "narrative-eyebrow",
319
+ "narrative-h1",
320
+ "narrative-h2",
321
+ "narrative-h3",
322
+ "narrative-lede",
323
+ "prose",
324
+ "prose-compact",
325
+ "text-body",
326
+ "text-emphasis",
327
+ "text-eyebrow",
328
+ "text-label",
329
+ "text-meta",
330
+ "text-metric-value",
331
+ "text-mono",
332
+ "text-object-title",
333
+ "text-on-surface",
334
+ "text-on-surface-variant",
335
+ "text-page-title",
336
+ "text-section-title",
337
+ "text-selected",
338
+ "text-supporting",
339
+ "text-welcome-title"
340
+ ],
341
+ "properties": [
342
+ "--ai-alis",
343
+ "--ai-alis-container",
344
+ "--ai-ground-end",
345
+ "--ai-ground-start",
346
+ "--ai-tail",
347
+ "--ai-you",
348
+ "--ai-you-container",
349
+ "--alis-red",
350
+ "--amber-100",
351
+ "--amber-700",
352
+ "--background",
353
+ "--band-bottom",
354
+ "--band-fg",
355
+ "--band-line",
356
+ "--band-surface",
357
+ "--band-top",
358
+ "--bench-grid-line",
359
+ "--blink",
360
+ "--blue-600",
361
+ "--breakpoint-compact",
362
+ "--breakpoint-expanded",
363
+ "--breakpoint-large",
364
+ "--breakpoint-medium",
365
+ "--card-padding-wide",
366
+ "--cat",
367
+ "--cat1",
368
+ "--cat1-container",
369
+ "--cat2",
370
+ "--cat2-container",
371
+ "--cat3",
372
+ "--cat3-container",
373
+ "--cat4",
374
+ "--cat4-container",
375
+ "--cat5",
376
+ "--cat5-container",
377
+ "--cat6",
378
+ "--cat6-container",
379
+ "--chart-neutral",
380
+ "--chat-row",
381
+ "--container",
382
+ "--control-height",
383
+ "--cyan-200",
384
+ "--cyan-600",
385
+ "--cyan-700",
386
+ "--detail-width",
387
+ "--dur-arrive",
388
+ "--dur-effects",
389
+ "--dur-panel",
390
+ "--dur-spatial",
391
+ "--dur-tint",
392
+ "--dur-ui",
393
+ "--ease-arrive",
394
+ "--ease-standard",
395
+ "--elevation-1",
396
+ "--elevation-2",
397
+ "--elevation-3",
398
+ "--error",
399
+ "--field-glow",
400
+ "--field-glow-1",
401
+ "--field-glow-2",
402
+ "--field-grid",
403
+ "--field-grid-line",
404
+ "--field-grid-size",
405
+ "--field-mask",
406
+ "--field-noise",
407
+ "--font-mono",
408
+ "--font-sans",
409
+ "--green-700",
410
+ "--grey-200",
411
+ "--grey-250",
412
+ "--grey-300",
413
+ "--grey-400",
414
+ "--grey-600",
415
+ "--highlight",
416
+ "--info",
417
+ "--inverse-surface",
418
+ "--machine-surface",
419
+ "--measure-prose",
420
+ "--mist-100",
421
+ "--motion-effects",
422
+ "--motion-spatial",
423
+ "--narrative-canvas",
424
+ "--narrative-ink-body",
425
+ "--narrative-line",
426
+ "--narrative-line-inverse",
427
+ "--narrative-line-strong",
428
+ "--narrative-link",
429
+ "--narrative-surface-sunken",
430
+ "--narrative-tone-forge",
431
+ "--nav-width",
432
+ "--noise-opacity",
433
+ "--on-band-build",
434
+ "--on-band-forge",
435
+ "--on-band-ideate",
436
+ "--on-band-spec",
437
+ "--on-cat",
438
+ "--on-cat1-container",
439
+ "--on-cat2-container",
440
+ "--on-cat3-container",
441
+ "--on-cat4-container",
442
+ "--on-cat5-container",
443
+ "--on-cat6-container",
444
+ "--on-error",
445
+ "--on-highlight",
446
+ "--on-inverse-surface",
447
+ "--on-machine-surface",
448
+ "--on-primary",
449
+ "--on-secondary-container",
450
+ "--on-surface",
451
+ "--on-surface-variant",
452
+ "--outline",
453
+ "--outline-variant",
454
+ "--paper",
455
+ "--paper-0",
456
+ "--paper-100",
457
+ "--paper-150",
458
+ "--paper-25",
459
+ "--paper-50",
460
+ "--paper-75",
461
+ "--petrol-500",
462
+ "--petrol-700",
463
+ "--petrol-800",
464
+ "--petrol-850",
465
+ "--petrol-900",
466
+ "--petrol-950",
467
+ "--primary",
468
+ "--prose-body-line",
469
+ "--prose-body-size",
470
+ "--prose-code-size",
471
+ "--prose-gap",
472
+ "--prose-h1-above",
473
+ "--prose-h1-below",
474
+ "--prose-h1-line",
475
+ "--prose-h1-size",
476
+ "--prose-h1-tracking",
477
+ "--prose-h1-weight",
478
+ "--prose-h2-above",
479
+ "--prose-h2-line",
480
+ "--prose-h2-size",
481
+ "--prose-h2-weight",
482
+ "--prose-h3-above",
483
+ "--prose-item-gap",
484
+ "--prose-minor-ink",
485
+ "--radius-0",
486
+ "--radius-lg",
487
+ "--radius-md",
488
+ "--radius-pill",
489
+ "--radius-sm",
490
+ "--radius-xl",
491
+ "--radius-xs",
492
+ "--rc-noise",
493
+ "--red-700",
494
+ "--scrim",
495
+ "--secondary-container",
496
+ "--selection-chrome",
497
+ "--shadow-ambient",
498
+ "--shadow-key",
499
+ "--shiki-background",
500
+ "--shiki-foreground",
501
+ "--shiki-token-comment",
502
+ "--shiki-token-constant",
503
+ "--shiki-token-function",
504
+ "--shiki-token-keyword",
505
+ "--shiki-token-link",
506
+ "--shiki-token-parameter",
507
+ "--shiki-token-punctuation",
508
+ "--shiki-token-string",
509
+ "--shiki-token-string-expression",
510
+ "--shimmer",
511
+ "--signal",
512
+ "--slate-500",
513
+ "--space-12",
514
+ "--space-16",
515
+ "--space-24",
516
+ "--space-32",
517
+ "--space-4",
518
+ "--space-48",
519
+ "--space-8",
520
+ "--stagger",
521
+ "--state-dragged",
522
+ "--state-focus",
523
+ "--state-hover",
524
+ "--state-pressed",
525
+ "--state-statement",
526
+ "--success",
527
+ "--surface",
528
+ "--surface-container-high",
529
+ "--surface-container-highest",
530
+ "--surface-container-low",
531
+ "--surface-variant",
532
+ "--syntax-comment",
533
+ "--syntax-function",
534
+ "--syntax-keyword",
535
+ "--syntax-number",
536
+ "--syntax-plain",
537
+ "--syntax-string",
538
+ "--teal-200",
539
+ "--teal-600",
540
+ "--term-bg",
541
+ "--term-fg",
542
+ "--term-ok",
543
+ "--term-prompt",
544
+ "--term-reply",
545
+ "--titlebar-height-phone",
546
+ "--touch-target",
547
+ "--touch-target-coarse",
548
+ "--violet-200",
549
+ "--violet-600",
550
+ "--violet-700",
551
+ "--warning"
552
+ ]
553
+ }
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@alis-build/design-system",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "description": "The AlisX design system for coding agents: tokens, product CSS, component markup, capability marks and rules.",
5
5
  "keywords": ["alisx", "design-system", "design-tokens", "css"],
6
6
  "homepage": "https://alisx.com",
7
7
  "license": "Apache-2.0",
8
8
  "style": "alisx.css",
9
9
  "sideEffects": ["*.css"],
10
+ "bin": {
11
+ "alisx-check": "./check.mjs"
12
+ },
10
13
  "exports": {
11
14
  "./alisx.css": "./alisx.css",
12
15
  "./tokens.css": "./tokens.css",
@@ -14,6 +17,8 @@
14
17
  "./tokens.json": "./tokens.json",
15
18
  "./themes.json": "./themes.json",
16
19
  "./marks.json": "./marks.json",
20
+ "./classes.json": "./classes.json",
21
+ "./stylelint": "./stylelint.mjs",
17
22
  "./rules/*": "./rules/*",
18
23
  "./components/*": "./components/*",
19
24
  "./assets/*": "./assets/*",
@@ -26,11 +31,22 @@
26
31
  "tokens.json",
27
32
  "themes.json",
28
33
  "marks.json",
34
+ "classes.json",
35
+ "stylelint.mjs",
36
+ "check.mjs",
29
37
  "rules",
30
38
  "components",
31
39
  "assets",
32
40
  "NOTICE"
33
41
  ],
42
+ "peerDependencies": {
43
+ "stylelint": ">=16.0.0"
44
+ },
45
+ "peerDependenciesMeta": {
46
+ "stylelint": {
47
+ "optional": true
48
+ }
49
+ },
34
50
  "publishConfig": {
35
51
  "access": "public"
36
52
  }
package/rules/styling.md CHANGED
@@ -76,12 +76,26 @@ global class or invent a role: the system changes once, by decision.
76
76
 
77
77
  ## Enforce it
78
78
 
79
- Lint for what can be linted: hex literals, off-scale spacing and radius, shadows,
80
- local font declarations and forced-priority overrides in component code. Run it
81
- as a ratchet, failing when a file gains violations, so an existing backlog
82
- doesn't block new work. Re-record the baseline only after an intentional change,
83
- never to clear a failure, and say in the commit why the number moved.
84
-
85
- Check by hand what a linter can't see: a static `style=""` attribute in a
86
- template, and a case transform in code (`toUpperCase()` on displayed text),
87
- which shouts exactly as `text-transform` would.
79
+ The package ships what can be linted, so every app checks the same things
80
+ (setup: the package README).
81
+
82
+ - **`stylelint.mjs`** restates this page as a stylelint config an app extends:
83
+ a literal colour, a role at an alpha outside a drawing or the scrim, spacing,
84
+ radius and shadow written without their tokens, local type, a forced
85
+ priority, and a selector on a system class. It reads the token and class
86
+ names from the package, so a new token needs no edit to the check. In a
87
+ Svelte or Vue file it reads the `<style>` block and a static `style=""`.
88
+ - **A gap is said where it is**: `/* stylelint-disable-next-line <rule> -- GAP:
89
+ what this needs */`. A disable with no reason is reported.
90
+ - **`alisx-check styles`** runs it as a gate. An app with a backlog records a
91
+ baseline and it becomes a ratchet, failing when a file gains violations of a
92
+ rule, so the backlog doesn't block new work. Re-record the baseline only
93
+ after an intentional change, never to clear a failure, and say in the commit
94
+ why the number moved.
95
+ - **`alisx-check names`** fails on a system class or a custom property the
96
+ installed version doesn't have (`classes.json`): a misspelt class renders
97
+ unstyled and says nothing.
98
+
99
+ Check by hand what a linter can't see: a computed style binding, a value behind
100
+ a variable of your own, and a case transform in code (`toUpperCase()` on
101
+ displayed text), which shouts exactly as `text-transform` would.
package/stylelint.mjs ADDED
@@ -0,0 +1,150 @@
1
+ // The style check for an app built on @alis-build/design-system.
2
+ //
3
+ // Every rule restates a row of rules/styling.md: appearance comes from the
4
+ // system, a site supplies layout, motion and drawing. Nothing here is a new
5
+ // opinion. The names it accepts (tokens, classes) are read from classes.json,
6
+ // so a token added to the system is accepted without an edit here.
7
+ //
8
+ // Use it from your stylelint config (stylelint 16 or later):
9
+ //
10
+ // export default {
11
+ // extends: ['@alis-build/design-system/stylelint'],
12
+ // overrides: [{ files: ['**/*.svelte', '**/*.vue'], customSyntax: 'postcss-html' }],
13
+ // }
14
+ //
15
+ // A rule you set under the same name REPLACES the system's: stylelint never
16
+ // merges two lists. To add to one, carry the system's part along (the named
17
+ // exports below) and build the rule with refuse() or allow().
18
+ //
19
+ // When nothing in styling.md fits, the system has a gap. Say so where it is:
20
+ //
21
+ // /* stylelint-disable-next-line <rule> -- GAP: what this needs */
22
+ //
23
+ // A disable with no reason after `--` is itself reported.
24
+ import { readFileSync } from 'node:fs'
25
+
26
+ export const guide = 'rules/styling.md in @alis-build/design-system'
27
+
28
+ const inventory = JSON.parse(readFileSync(new URL('./classes.json', import.meta.url), 'utf8'))
29
+ const escaped = (names) => names.map((name) => name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')
30
+ const tokens = (prefix) =>
31
+ inventory.properties
32
+ .filter((name) => name.startsWith(prefix))
33
+ .map((name) => name.slice(2))
34
+ .sort((a, b) => a.localeCompare(b, undefined, { numeric: true }))
35
+ const spaces = tokens('--space-')
36
+ const radii = tokens('--radius-')
37
+ const elevations = tokens('--elevation-')
38
+ // Every class the system defines, except its state classes (is-selected …),
39
+ // which an app also sets on its own elements.
40
+ const systemClasses = inventory.classes.filter((name) => !name.startsWith('is-'))
41
+
42
+ // A colour written out: #006383, rgb(0 99 131), color(srgb 0 .4 .5). A hash
43
+ // inside url() is a reference, not a colour.
44
+ const literalColour =
45
+ /(?<!url\([^)]*)#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})(?![\w-])|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch)\(\s*[-+.\d]|\bcolor\(\s*(?!from\b)[\w-]+\s+[-+.\d]/i
46
+ // A role at an alpha or a blend: color-mix(…), rgb(var(--x) / 50%),
47
+ // oklch(from var(--x) …). The scrim at an alpha is the one styling.md allows.
48
+ const blendedColour =
49
+ /^(?!.*var\(--scrim\)).*(?:\bcolor-mix\(|\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch|color)\(\s*(?:from\b|var\())/is
50
+ // A length written as a number (12px, -8px, 0.75rem), or a spacing token the
51
+ // system doesn't have. A token's own name (var(--space-12)) is not a length.
52
+ const literalLength = /(?<!--[\w-]*)(?<![\w.])\d*\.?\d+(?:px|r?em|ch|ex|pt|pc|cm|mm|in|vw|vh|vmin|vmax|[sld]v[wh])\b/i
53
+ const unknownSpace = new RegExp(`var\\(\\s*--space-(?!(?:${escaped(spaces.map((name) => name.slice('space-'.length)))})\\s*[,)])`)
54
+
55
+ // The parts, exported so an app can add to a rule without losing the system's.
56
+ // A key is a property name or a "/regex/" string, as stylelint reads them.
57
+
58
+ /** Values no declaration may carry. */
59
+ export const refusedValues = [
60
+ {
61
+ // A mask reads alpha only, and a filter's shadow is the same in both themes.
62
+ properties: '/^(?!(?:-webkit-)?(?:mask|filter|backdrop-filter))/',
63
+ values: [literalColour],
64
+ message: `A literal colour is the same in both themes: name a role (${guide}).`,
65
+ },
66
+ {
67
+ // "A role at an alpha is allowed for an area or a band in a drawing, and
68
+ // for the scrim behind text on an image. Nowhere else."
69
+ properties: '/^(?!(?:fill|stroke|stop-color)$)/',
70
+ values: [blendedColour],
71
+ message: `A role at an alpha or a blend belongs to a drawing (fill, stroke) or the scrim. Elsewhere, name the nearest role (${guide}).`,
72
+ },
73
+ {
74
+ properties: '/^(?:(?:margin|padding|scroll-margin|scroll-padding)(?:-|$)|(?:grid-)?(?:row-|column-)?gap$)/',
75
+ values: [literalLength, unknownSpace],
76
+ message: (property) => `Spacing comes from the scale: write ${property} with ${spaces.map((name) => `var(--${name})`).join(', ')}, or 0 (${guide}).`,
77
+ },
78
+ ]
79
+
80
+ /** Properties whose every value must be one of these. */
81
+ export const allowedValues = [
82
+ {
83
+ properties: '/radius$/',
84
+ values: [new RegExp(`^(?:(?:var\\(--(?:${escaped(radii)})\\)|0|50%|inherit)(?:\\s*\\/\\s*|\\s+|$))+$`)],
85
+ message: `A radius is ${radii.map((name) => `var(--${name})`).join(', ')}, 0, or 50% for a circle (${guide}).`,
86
+ },
87
+ {
88
+ properties: '/^(?:-webkit-|-moz-)?box-shadow$/',
89
+ values: ['none', 'inherit', new RegExp(`^var\\(--(?:${escaped(elevations)})\\)$`)],
90
+ message: `A shadow is ${elevations.map((name) => `var(--${name})`).join(', ')}, or none (${guide}).`,
91
+ },
92
+ ]
93
+
94
+ /** Type belongs to a text-* class. Refused in a rule; an @font-face is not one. */
95
+ export const refusedProperties = {
96
+ properties: ['font', 'font-family', 'font-size', 'font-weight', 'font-variation-settings', 'line-height', 'letter-spacing', 'text-transform', 'text-shadow'],
97
+ message: (selector, property) => `${property} is appearance: a text-* class carries type (${guide}).`,
98
+ }
99
+
100
+ /** A site never restyles a system class. Exact names, so .app-bar-search of your own is yours. */
101
+ export const refusedSelectors = {
102
+ selectors: [new RegExp(`\\.(?:${escaped(systemClasses)})(?![\\w-])`)],
103
+ message: `A site never restyles a system component, a type class or prose (${guide}).`,
104
+ }
105
+
106
+ const applies = (key, property) => {
107
+ const pattern = /^\/.*\/$/.test(key) ? new RegExp(key.slice(1, -1)) : null
108
+ // stylelint 16 matches a key against the property without its vendor prefix.
109
+ return [property, property.replace(/^-(?:webkit|moz|ms|o)-/, '')].some((name) => (pattern ? pattern.test(name) : key === name))
110
+ }
111
+ const matches = (pattern, value) => (typeof pattern === 'string' ? pattern === value : pattern.test(value))
112
+ const said = (entry, property, value) => (typeof entry.message === 'function' ? entry.message(property, value) : entry.message)
113
+ const listed = (entries) => {
114
+ const list = {}
115
+ for (const entry of entries) (list[entry.properties] ??= []).push(...entry.values)
116
+ return list
117
+ }
118
+
119
+ /** declaration-property-value-disallowed-list from entries, each with its own message. */
120
+ export function refuse(entries) {
121
+ const message = (property, value) => {
122
+ const entry = entries.find((each) => applies(each.properties, property) && each.values.some((pattern) => matches(pattern, value)))
123
+ return entry ? said(entry, property, value) : `${property}: ${value} is not from the system (${guide}).`
124
+ }
125
+ return [listed(entries), { message }]
126
+ }
127
+
128
+ /** declaration-property-value-allowed-list from entries, each with its own message. */
129
+ export function allow(entries) {
130
+ const message = (property, value) => {
131
+ const entry = entries.find((each) => applies(each.properties, property))
132
+ return entry ? said(entry, property, value) : `${property}: ${value} is not from the system (${guide}).`
133
+ }
134
+ return [listed(entries), { message }]
135
+ }
136
+
137
+ export default {
138
+ // An exemption says why: `-- GAP: …` after the rule name.
139
+ reportDescriptionlessDisables: true,
140
+ rules: {
141
+ // A named colour is a hex by another name. Hex is refused with the other
142
+ // literal colours below, so a mask may use either.
143
+ 'color-named': ['never', { ignoreProperties: ['/mask/', '/filter/'], message: `A named colour is the same in both themes: name a role (${guide}).` }],
144
+ 'declaration-property-value-disallowed-list': refuse(refusedValues),
145
+ 'declaration-property-value-allowed-list': allow(allowedValues),
146
+ 'rule-selector-property-disallowed-list': [{ '/.*/': refusedProperties.properties }, { message: refusedProperties.message }],
147
+ 'declaration-no-important': [true, { message: `!important fights the system: settle it once, in the theme, or not at all (${guide}).` }],
148
+ 'selector-disallowed-list': [refusedSelectors.selectors, { message: refusedSelectors.message }],
149
+ },
150
+ }