@estiva-app/ui 0.43.0 → 0.44.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/dist/eslint/index.js +21 -0
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-handmade-empty-state.d.ts +7 -0
- package/dist/eslint/no-handmade-empty-state.d.ts.map +1 -1
- package/dist/gates/app-checks.d.ts.map +1 -1
- package/dist/gates/{chunk-SYVKGOWM.js → chunk-P5W6O5TF.js} +114 -63
- package/dist/gates/chunk-P5W6O5TF.js.map +7 -0
- package/dist/gates/cli.js +1 -1
- package/dist/gates/gate-config.d.ts.map +1 -1
- package/dist/gates/index.js +13 -3
- package/dist/gates/index.js.map +2 -2
- package/dist/gates/token-joined.d.ts +28 -0
- package/dist/gates/token-joined.d.ts.map +1 -0
- package/dist/gates/token-lint.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +1 -1
- package/src/EmptyState.mdx +1 -1
- package/src/eslint/no-handmade-empty-state.test.ts +23 -1
- package/src/eslint/no-handmade-empty-state.ts +37 -1
- package/src/gates/app-checks.ts +7 -0
- package/src/gates/gate-config.ts +2 -0
- package/src/gates/gates.test.ts +26 -0
- package/src/gates/token-joined.ts +94 -0
- package/src/gates/token-lint.ts +68 -66
- package/dist/gates/chunk-SYVKGOWM.js.map +0 -7
package/dist/gates/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/gates/gate-config.ts", "../../src/gates/app-checks.ts"],
|
|
4
|
-
"sourcesContent": ["/// <reference types=\"node\" />\n/**\n * Where the UI Guardrails' rules apply, written once (docs/GATES.md \u00A723).\n *\n * Until UIG-10 every repo wrote this itself: `eslint.gates.js` (the rules and\n * where they apply) and `eslint.gates.config.js` (the gate: those rules alone)\n * in Peek, in Ship, and here pointed inward. The rules were always the\n * package's; these two files were copies. Now they are two functions.\n *\n * Where: every `.ts` and `.tsx` under `src`, stories included (a story is what\n * people read and copy), tests not (a test mounts markup to test it) \u2014\n * Katerina's rulings of 13 September; `.ts` since UIG-8. This package's own\n * inward set reads `.tsx` only, as it always has.\n *\n * A place that keeps something says why, on the line above:\n * `// @estiva-escape: <reason>`, or `{/* @estiva-escape: <reason> *\\/}` as a\n * JSX child. Never `eslint-disable`: the count refuses it.\n */\nimport type { ESLint, Linter } from 'eslint'\nimport betterTailwindcss from 'eslint-plugin-better-tailwindcss'\nimport { parser as typescriptParser } from 'typescript-eslint'\nimport estiva from '../eslint/index'\nimport { KNOWN_PLUGINS, TOKEN_LINT_IGNORES } from './token-lint'\nimport { tokenStylePlugin } from './token-style'\n\nexport interface GateConfigOptions {\n /** `app` (the default) runs `configs.recommended`; `package` runs this package's inward set. */\n audience?: 'app' | 'package'\n /**\n * Plugins whose `eslint-disable` directives appear in the source, registered\n * here with every rule off. ESLint refuses a directive for a rule it does not\n * know, so without them the gate would fail on another lint's comments.\n * The token lint's names and TypeScript's are registered already (UIG-37).\n */\n quiet?: Record<string, ESLint.Plugin>\n /** Folders the gate never reads, beside build output. */\n ignores?: string[]\n}\n\n/**\n * The rules and where they apply \u2014 one config object, to add beside\n * everything else an app's `eslint.config.js` runs, so an editor shows a\n * refusal where the element is typed.\n */\nexport function gateLint({ audience = 'app' }: Pick<GateConfigOptions, 'audience'> = {}): Linter.Config {\n return {\n ...(audience === 'package' ? estiva.configs.package : estiva.configs.recommended),\n // An app's every script type: a raw <button> in a .jsx, or a key listener in a .mts,\n // passed while only .ts and .tsx were read (the re-review after the audit before UIG-26).\n files: audience === 'package' ? ['src/**/*.tsx'] : ['src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'],\n ignores: ['**/*.test.*'],\n languageOptions: {\n parser: typescriptParser,\n parserOptions: { ecmaFeatures: { jsx: true } },\n },\n }\n}\n\n/**\n * The gate: the rules on their own \u2014 `npm run lint:rules`, CI's job `gate`, and\n * the config the editor hook lints a proposed write with. It fails on a gate\n * rule and on nothing else, so a backlog in the full lint never blocks it.\n */\nexport function gateConfig({ audience = 'app', quiet = {}, ignores = [] }: GateConfigOptions = {}): Linter.Config[] {\n return [\n { ignores: [...TOKEN_LINT_IGNORES, ...ignores] },\n {\n plugins: {\n ...KNOWN_PLUGINS,\n ...quiet,\n 'better-tailwindcss': betterTailwindcss,\n 'token-values': betterTailwindcss,\n 'token-spacing': betterTailwindcss,\n 'token-style': tokenStylePlugin,\n },\n // Every other config's directives are unused here, because their rules are\n // off here. Reporting them would be this config complaining about the\n // others' business.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n },\n gateLint({ audience }),\n ]\n}\n", "/// <reference types=\"node\" />\n/**\n * The gate checks every app runs, written once (docs/GATES.md \u00A723).\n *\n * Until UIG-10 Peek and Ship each wrote them into their own\n * `scripts/gates-checks.mjs`. 65 different checks for finished tickets, counted\n * on 17 September: 28 were identical in both, 21 were the same check written two\n * ways, 2 read each app's real page, and 14 read code only one app has. This is\n * the first three groups as one list. The fourth stays in the app's own checks\n * file, beside this list.\n *\n * Where Peek and Ship wrote one check two ways, the check here runs both, so it\n * passes wherever either did: the raw-link probe with both of their texts, the\n * token probes against each token config the app has.\n *\n * `scripts/gates-compare.mjs` holds this list to Peek's and Ship's: every check\n * of theirs must be here, or be about code only that app has, or the comparison\n * fails and names it.\n *\n * A check for a ticket not built yet is a first guess at the evidence, taken\n * from the ticket's own text; the ticket that builds it changes it here.\n */\nimport type { CheckResult, GateCheck, GateHelpers, GateTicket } from './status'\n\nexport interface AppCheckOptions {\n /** Where the app is inside the repository: `.` unless it sits in a folder of its own. */\n app?: string\n /** A real page of the app, relative to the app, full of elements that are not controls. */\n page: string\n /** The ticket the gate chain is listed under, and whether this repo owns it: UIG-3 in Peek, UIG-4 in Ship. */\n chain?: { ref: string; owner: boolean }\n /** The token lint configs the app has, relative to the app. */\n tokenConfigs?: string[]\n /** The part a hand-made column header should name (UIG-22): `Panel` since 0.37.0, `ContainerHeader` before. */\n headers?: string[]\n}\n\nexport const APP_TICKET_TITLES: Record<string, string> = {\n 'UIG-2': 'The tracking rails \u2014 GATES.md, the status script, the guide committed',\n 'UIG-3': 'Tracer bullet \u2014 one rule, end to end, blocking in Peek',\n 'UIG-4': 'The same chain, blocking in Ship',\n 'UIG-6': 'Branch protection \u2014 the backstop, all three repos',\n 'UIG-7': 'Lint rule \u2014 every remaining raw element',\n 'UIG-8': 'Lint rule \u2014 forbid the reach',\n 'UIG-9': 'Lint rule \u2014 the className allow-list',\n 'UIG-10': 'create-app \u2014 a command that makes a new Estiva app that runs',\n 'UIG-13': \"The registry widens to Peek's 115 and Ship's 74, with classification\",\n 'UIG-19': 'Lock the contract in CI',\n 'UIG-20': 'The Claude skill, reading the registry',\n 'UIG-21': 'CLAUDE.md becomes an index, not a lecture',\n 'UIG-22': 'Fingerprint \u2014 a hand-made header row',\n 'UIG-23': 'Fingerprint \u2014 a hand-made empty state',\n 'UIG-24': 'Fingerprint \u2014 a browser tooltip where ours belongs',\n 'UIG-25': 'Fingerprint \u2014 a component copied out by hand',\n 'UIG-27': 'The components the apps had to build themselves \u2014 Link, ProgressBar, EmptyState padding',\n 'UIG-28': 'Close the two holes in the token contract \u2014 arbitrary values, and inline style',\n 'UIG-30': 'RichText \u2014 one component that draws a message\\'s text, for both apps',\n 'UIG-32': 'Peek and Ship take their gate pieces from the package',\n 'UIG-37': 'The gates refuse a TypeScript eslint-disable comment \u2014 know the rule names, rules off',\n}\n\n/** Run several checks as one: the first that does not pass is the answer. */\nfunction all(h: GateHelpers, steps: (() => CheckResult | Promise<CheckResult>)[], label: string): () => Promise<CheckResult> {\n return async () => {\n for (const step of steps) {\n const r = await step()\n if (r.result !== 'pass') return r\n }\n return h.PASS(label)\n }\n}\n\nexport function appChecks(h: GateHelpers, { app = '.', page, chain = { ref: 'UIG-3', owner: false }, tokenConfigs = ['eslint.tokens.config.js', 'eslint.config.js'], headers = ['Panel'] }: AppCheckOptions): GateTicket[] {\n const WEB = app === '.' ? '' : `${app.replace(/\\/$/, '')}/`\n const cwd = app === '.' ? undefined : app\n const PROBE = 'src/components/__gates_probe__.tsx'\n const GATES = 'eslint.gates.config.js'\n const at = (rel: string) => `${WEB}${rel}`\n const probe = (code: string, expect: 'error' | 'warning' | 'none', mentions?: string, file = PROBE, config = GATES) => () =>\n h.lint({ ...(cwd ? { cwd } : {}), config, file, code, expect, mentions })\n const component = (body: string) => `export function Probe() {\\n return ${body}\\n}\\n`\n const installed = at('node_modules/@estiva-app/ui/dist/index.d.ts')\n const realPage = (): Promise<CheckResult> => h.lint({ ...(cwd ? { cwd } : {}), config: GATES, file: page, code: h.read(at(page)), expect: 'none' })\n const button = component('<button type=\"button\">x</button>')\n /** A line TypeScript's own lint writes; ESLint refuses it where TypeScript's plugin is unknown (UIG-37). */\n const typescriptDirective = '// eslint-disable-next-line @typescript-eslint/no-explicit-any\\nexport const probe: any = 1\\n'\n const ticket = (ref: string, checks: GateCheck[], owner = false): GateTicket => ({ ref, title: APP_TICKET_TITLES[ref], owner, checks })\n\n const tokenProbe = (code: string, expect: 'error' | 'warning' | 'none', mentions?: string, file = PROBE) =>\n all(h, tokenConfigs.map((config) => probe(code, expect, mentions, file, config)), `${tokenConfigs.join(' and ')}: as expected`)\n\n return [\n ticket('UIG-2', [\n { what: 'npm run gates:status is wired', run: () => h.script('package.json', 'gates:status') },\n ]),\n ticket(chain.ref, [\n { what: 'the gate lint config loads', run: () => h.loads(at(GATES)) },\n { what: `${at('package.json')} has lint:rules`, run: () => h.script(at('package.json'), 'lint:rules') },\n { what: 'CI runs lint:rules', run: () => h.ci('lint:rules') },\n { what: 'the committed hook runs the gate lint', run: () => h.hook('.claude/settings.json', 'gates') },\n { what: '.gates-count.json is committed and parses', run: () => h.json(h.exists('.gates-count.json') ? '.gates-count.json' : at('.gates-count.json')) },\n { what: 'a raw <button> is an error naming Button', run: probe(button, 'error', 'Button') },\n { what: 'the same in a story', run: probe(button, 'error', 'Button', 'src/stories/__gates_probe__.stories.tsx') },\n { what: 'a test file is not checked, while source is', run: async () => {\n const source = await probe(button, 'error', 'Button')()\n if (source.result !== 'pass') return h.FAIL(`source is not checked yet, so this proves nothing: ${source.detail}`)\n return probe(button, 'none', undefined, 'src/components/__gates_probe__.test.tsx')()\n } },\n { what: 'the debt list exists', run: () => h.file('docs/GATES-DEBT.md') },\n ], chain.owner),\n ticket('UIG-6', [\n { what: 'GitHub requires the check gate to merge into main', run: () => h.protectedBranch(/^gate$/) },\n { what: \"CI's job gate runs lint:rules\", run: () => h.ciJob('gate', 'lint:rules') },\n ]),\n ticket('UIG-7', [\n { what: 'a raw <input> is an error naming TextInput', run: probe(component('<input />'), 'error', 'TextInput') },\n { what: 'a clickable <div> is an error naming Button (R5)', run: probe(component('<div onClick={() => history.back()}>Back</div>'), 'error', '`Button`') },\n { what: 'a raw <a> is an error naming Link', run: all(h, [probe(component('<a href=\"/topics\">Topics</a>'), 'error', 'Link'), probe(component('<a href=\"/issues\">Issues</a>'), 'error', 'Link')], 'a raw <a> is an error naming Link') },\n { what: 'a raw <form> is an error naming Form, and a file input one naming FilePicker', run: async () => {\n const form = await probe(component('<form />'), 'error', '`Form`')()\n if (form.result !== 'pass') return form\n return probe(component('<input type=\"file\" />'), 'error', 'FilePicker')()\n } },\n { what: '<textarea>, <select>, <dialog> and <label> name Textarea, Select, DialogShell and Field', run: async () => {\n for (const [element, part] of [['textarea', 'Textarea'], ['select', 'Select'], ['dialog', 'DialogShell'], ['label', 'Field']]) {\n const one = await probe(component(`<${element} />`), 'error', `\\`${part}\\``)()\n if (one.result !== 'pass') return one\n }\n return h.PASS('all four are errors, each naming its part')\n } },\n { what: 'an element the package has no part for is an error that says to ask for one', run: probe(component('<iframe title=\"Map\" />'), 'error', 'ask Katerina') },\n { what: 'an escaped element is not an error, while the same element is', run: async () => {\n const raw = await probe(component('<form />'), 'error')()\n if (raw.result !== 'pass') return h.FAIL(`a raw <form> is not caught yet, so this proves nothing: ${raw.detail}`)\n return probe('export function Probe() {\\n return (\\n // @estiva-escape(no-raw-element): a probe that keeps its element on purpose\\n <form />\\n )\\n}\\n', 'none')()\n } },\n { what: 'a real page, full of elements that are not controls, gets no error', run: realPage },\n ]),\n ticket('UIG-8', [\n { what: 'a Base UI import is an error naming the part built on it', run: probe(\"import { Popover } from '@base-ui/react/popover'\\nexport const Probe = Popover\\n\", 'error', '`Popover`') },\n { what: 'createPortal is an error naming the floating parts', run: probe(\"import { createPortal } from 'react-dom'\\nexport const Probe = (to: HTMLElement) => createPortal(<span />, to)\\n\", 'error', '`DialogShell`') },\n { what: 'a key listener on the whole page is an error, in a .ts file too', run: probe(\"export function listen() {\\n window.addEventListener('keydown', () => {})\\n}\\n\", 'error', '`DialogShell`', 'src/lib/__gates_probe__.ts') },\n { what: 'arrow keys by hand are an error; Enter in a field is not', run: async () => {\n const arrows = await probe(\"export const onKeyDown = (e: KeyboardEvent) => e.key === 'ArrowDown'\\n\", 'error', '`Menu`', 'src/lib/__gates_probe__.ts')()\n if (arrows.result !== 'pass') return arrows\n return probe(\"export const onKeyDown = (e: KeyboardEvent) => e.key === 'Enter'\\n\", 'none', undefined, 'src/lib/__gates_probe__.ts')()\n } },\n { what: 'a hand-written role=\"option\" is an error naming Select', run: probe(component('<div role=\"option\" />'), 'error', '`Select`') },\n { what: 'tabIndex={0} on a div is an error; tabIndex={-1} is not', run: async () => {\n const zero = await probe(component('<div tabIndex={0} />'), 'error', '`Button`')()\n if (zero.result !== 'pass') return h.FAIL(`tabIndex={0} is not caught yet, so this proves nothing: ${zero.detail}`)\n return probe(component('<div tabIndex={-1} />'), 'none')()\n } },\n { what: 'overflow-y-auto is an error naming ScrollArea', run: probe(component('<div className=\"h-64 overflow-y-auto\" />'), 'error', '`ScrollArea`') },\n { what: 'an escaped listener is not an error, while the same listener is', run: async () => {\n const raw = await probe(\"export function listen() {\\n document.addEventListener('mousedown', () => {})\\n}\\n\", 'error', undefined, 'src/lib/__gates_probe__.ts')()\n if (raw.result !== 'pass') return h.FAIL(`a page listener is not caught yet, so this proves nothing: ${raw.detail}`)\n return probe(\"export function listen() {\\n // @estiva-escape(no-rebuilt-behaviour): a probe that keeps its listener on purpose\\n document.addEventListener('mousedown', () => {})\\n}\\n\", 'none', undefined, 'src/lib/__gates_probe__.ts')()\n } },\n { what: 'a real page gets no error', run: realPage },\n ]),\n ticket('UIG-9', [\n { what: 'a border passed into Button is an error naming Button', run: probe(`import { Button } from '@estiva-app/ui'\\n${component('<Button className=\"border\">x</Button>')}`, 'error', 'on `Button` changes how it looks') },\n { what: 'placement passed into Button is not', run: probe(`import { Button } from '@estiva-app/ui'\\n${component('<Button className=\"mt-2 w-full flex-1 relative\">x</Button>')}`, 'none') },\n { what: 'an escaped look is not an error, while the same look is', run: async () => {\n const raw = await probe(`import { Link } from '@estiva-app/ui'\\n${component('<Link href=\"/x\" className=\"after:absolute after:inset-0\">x</Link>')}`, 'error', '`Link`')()\n if (raw.result !== 'pass') return h.FAIL(`a restyled part is not caught yet, so this proves nothing: ${raw.detail}`)\n return probe(`import { Link } from '@estiva-app/ui'\\nexport function Probe() {\\n return (\\n // @estiva-escape(no-restyled-part): a probe that keeps its row link on purpose\\n <Link href=\"/x\" className=\"after:absolute after:inset-0\">x</Link>\\n )\\n}\\n`, 'none')()\n } },\n { what: 'a real page gets no error', run: realPage },\n ]),\n // UIG-10, reopened 18 September: a tab holds one relay client, the way Peek and Ship hold\n // theirs and a made app is written to. Measured on both mains that day: one each, and no\n // socket opened any other way. A second holder, or a socket of the app's own, is a second\n // connection the relay signs in and budgets separately.\n ticket('UIG-10', [\n { what: 'the app holds one relay client, at module level, and opens no socket of its own', run: () => {\n const sources = h.listFiles(at('src'), (n) => /\\.tsx?$/.test(n) && !/\\.(test|stories)\\.tsx?$/.test(n))\n const own = sources.filter((f) => /\\bcreateLiveClient\\(|\\bcreateLiveRelay\\(|\\bnew WebSocket\\(/.test(h.read(f)))\n if (own.length) return h.FAIL(`opens a socket of its own (${own.join(', ')}): hold one client from createLiveClientHolder()`)\n const holders = sources.filter((f) => /^\\s*(?:export\\s+)?const\\s+\\w+\\s*=\\s*createLiveClientHolder\\(\\)/m.test(h.read(f)))\n if (holders.length !== 1) return h.FAIL(holders.length ? `${holders.length} client holders (${holders.join(', ')}): a tab holds one` : 'no module-level createLiveClientHolder(): the app has no relay client')\n return h.PASS(`one client for the tab, held in ${holders[0]}`)\n } },\n ]),\n // Built by UIG-13, 18 September. An app's catalogue is built fresh from its code\n // and never committed: the package is public and the apps are private (Katerina).\n ticket('UIG-13', [\n { what: \"npm run ui:find is the package's search, over the package and this app\", run: () => h.contains(at('package.json'), /\"ui:find\":\\s*\"estiva-ui find\\b/, \"ui:find runs the package's estiva-ui find\") },\n { what: \"npm run registry:check is the package's check\", run: () => h.contains(at('package.json'), /\"registry:check\":\\s*\"estiva-ui check\\b/, 'registry:check runs estiva-ui check') },\n { what: \"CI's job gate refuses a part with no description\", run: () => h.ciJob('gate', 'registry:check') },\n // In the .gitignore of the app's own folder, where `estiva-ui build` would write it.\n { what: 'the catalogue is never committed: git ignores registry.json', run: () => h.contains(at('.gitignore'), /^\\/?registry\\.json\\r?$/m, `${at('.gitignore')} ignores registry.json`) },\n { what: 'every part is described and sorted, and every file is accounted for', run: () => h.catalogue(at('.')) },\n ]),\n ticket('UIG-19', [\n // The contract runs inside `estiva-ui check`, which the gate job already runs\n // (UIG-13), so an app changes no script: it takes the package that has it.\n { what: 'the installed package checks the usage-page contract and the story links', run: () => h.contains(at('node_modules/@estiva-app/ui/dist/registry/cli.js'), 'the usage-page contract', \"the installed estiva-ui check runs the contract\") },\n { what: \"CI's job gate runs it\", run: () => h.ciJob('gate', 'registry:check') },\n { what: 'the app keeps no copy of it in its own gates-checks.mjs', run: () => h.exists(at('scripts/gates-checks.mjs')) ? h.lacks(at('scripts/gates-checks.mjs'), '\"When not\"', 'the app checks no page sections itself') : h.PASS('the app has no gates-checks.mjs') },\n ]),\n // The Claude skill (UIG-20): its text is the installed package's, read in by a\n // loader `estiva-ui skill` writes; the app commits the loader and the settings.\n ticket('UIG-20', [\n { what: \"the skill's loader reads the installed package's text\", run: () => h.contains('.claude/skills/estiva-ui/SKILL.md', `!\\`cat \"\\${CLAUDE_PROJECT_DIR}/${at('node_modules/@estiva-app/ui/skill/estiva-ui.md')}\"\\``, 'the loader reads the package\u2019s skill') },\n { what: 'the search runs without a prompt', run: () => h.contains('.claude/settings.json', 'Bash(npm run ui:find *)', '.claude/settings.json allows npm run ui:find') },\n { what: 'ui:find searches every app beside this one: it names none', run: () => h.lacks(at('package.json'), /\"ui:find\":[^\\n]*--also/, 'ui:find names no neighbour, so it finds them all') },\n ...(WEB ? [{ what: 'ui:find runs from the top folder too', run: () => h.contains('package.json', /\"ui:find\":/, 'the top folder has ui:find') }] : []),\n { what: \"CI's job gate refuses a loader that differs\", run: () => (h.exists(at('node_modules/@estiva-app/ui/dist/registry/cli.js')) && /claude skill:/.test(h.read(at('node_modules/@estiva-app/ui/dist/registry/cli.js'))) ? h.ciJob('gate', 'registry:check') : h.FAIL('the installed package does not check the loader: take a version that does')) },\n ]),\n // What loads into every Claude session (UIG-21): CLAUDE.md is an index, the\n // rest loads where it applies, and a rule a check can hold is a check.\n ticket('UIG-21', [\n { what: 'CLAUDE.md with its imports is under 200 lines, and every rule file is scoped', run: () => h.instructions(200) },\n { what: \"CI's job gate runs the token lint\", run: () => {\n const tokens = h.ciJob('gate', 'lint:tokens')\n return tokens.result === 'pass' ? tokens : h.ciJob('gate', 'lint')\n } },\n { what: \"a plain tailwind-merge is an error naming the package's cn()\", run: tokenProbe(\"import { twMerge } from 'tailwind-merge'\\nexport const merged = twMerge('p-2', 'p-3')\\n\", 'error', 'cn()', 'src/lib/__gates_probe__.ts') },\n ]),\n ticket('UIG-22', [\n // The Folders pane's own row, at the commit before peek 3dc663b.\n { what: `a hand-made column header is an error naming ${headers.join(' or ')}`, run: all(h, headers.map((name) => probe(component('<div className=\"flex h-full flex-col\"><div className=\"flex items-center gap-2 px-3 py-2\"><span>Folders</span></div><div /></div>'), 'error', name)), `a hand-made column header is an error naming ${headers.join(' or ')}`) },\n // 26 September: the package's header on its own is a panel made by hand, whose box forgot to scroll.\n { what: \"the package's ContainerHeader on its own is an error naming Panel\", run: probe(`import { ContainerHeader } from '@estiva-app/ui'\\n${component('<div className=\"flex flex-col\"><ContainerHeader title=\"Details\" /><div className=\"px-4\">x</div></div>')}`, 'error', '`Panel`') },\n { what: 'a group heading inside a list is left alone', run: probe(component('<section className=\"flex flex-col gap-px\"><h3 className=\"flex h-8 items-center gap-2 px-3\"><span>Todo</span></h3><div /></section>'), 'none') },\n ]),\n ticket('UIG-23', [\n { what: 'a hand-made empty line is an error naming EmptyState', run: probe(\"export function Probe({ items }: { items: string[] }) {\\n return <div>{items.length === 0 ? <p className=\\\"text-text-secondary\\\">Nothing here</p> : items.map((i) => <span key={i}>{i}</span>)}</div>\\n}\\n\", 'error', 'EmptyState') },\n ]),\n ticket('UIG-24', [\n { what: 'a title= is an error naming WithTooltip', run: probe(`import { Button } from '@estiva-app/ui'\\n${component('<Button title=\"Delete\">x</Button>')}`, 'error', 'WithTooltip') },\n ]),\n ticket('UIG-25', [\n { what: \"SectionLabel's class list, typed by hand, is a warning\", run: probe(component('<span className=\"text-h5 leading-3 signal:font-mono signal:text-small signal:uppercase signal:tracking-widest text-text-secondary\">Label</span>'), 'warning', 'SectionLabel') },\n ]),\n ticket('UIG-27', [\n { what: 'the installed package has Link', run: () => h.contains(installed, /\\bLink\\b/, 'the installed @estiva-app/ui exports Link') },\n { what: 'the installed package has ProgressBar', run: () => h.contains(installed, /\\bProgressBar\\b/, 'the installed @estiva-app/ui exports ProgressBar') },\n ]),\n ticket('UIG-28', [\n { what: 'text-[14px] is an error', run: tokenProbe(component('<div className=\"text-[14px]\">x</div>'), 'error') },\n { what: 'a colour in an inline style is an error', run: tokenProbe(component(\"<div style={{ backgroundColor: '#ff0000' }}>x</div>\"), 'error') },\n { what: 'h-[240px] is a warning', run: tokenProbe(component('<div className=\"h-[240px]\">x</div>'), 'warning') },\n { what: 'h-[240px] is not an error', run: tokenProbe(component('<div className=\"h-[240px]\">x</div>'), 'none') },\n { what: 'a hand-written line height behind an arbitrary variant is an error', run: tokenProbe(component('<div className=\"[&_p]:leading-[1.4]\">x</div>'), 'error') },\n { what: 'a raw colour in a class is an error (the pattern that matched nothing, R1)', run: tokenProbe(component('<div className=\"bg-[#5c69dc]\">x</div>'), 'error', 'raw colour') },\n { what: 'a width and height from a prop pass', run: tokenProbe(\"export function Probe({ size }: { size: number }) {\\n return <div style={{ width: size, height: size }}>x</div>\\n}\\n\", 'none') },\n { what: 'a test file is not checked for hand-written values, while source is', run: all(h, tokenConfigs.map((config) => async () => {\n const code = component(\"<div className=\\\"text-[14px]\\\" style={{ color: 'red' }}>x</div>\")\n const source = await probe(code, 'error', undefined, PROBE, config)()\n if (source.result !== 'pass') return h.FAIL(`source is not checked yet, so this proves nothing: ${source.detail}`)\n return probe(code, 'none', undefined, 'src/components/__gates_probe__.test.tsx', config)()\n }), 'a test file is not checked for hand-written values, while source is') },\n ]),\n // Built 28 September: both apps drew the protocol's text tree by hand, and drifted apart.\n // A file that reads the protocol and draws a quote or a numbered list itself is a third copy.\n ticket('UIG-30', [\n { what: 'the installed package has RichText', run: () => h.contains(installed, /\\bRichText\\b/, 'the installed @estiva-app/ui exports RichText') },\n { what: \"no file draws the protocol's text tree by hand\", run: () => {\n const sources = h.listFiles(at('src'), (n) => /\\.tsx$/.test(n) && !/\\.(test|stories)\\.tsx$/.test(n))\n const own = sources.filter((f) => { const text = h.read(f); return /from ['\"]@estiva-app\\/protocol['\"]/.test(text) && /<(?:blockquote|ol)\\b/.test(text) })\n return own.length ? h.FAIL(`draws the text tree itself (${own.join(', ')}): pass the tree to RichText`) : h.PASS('formatted text is drawn by RichText only')\n } },\n ]),\n // UIG-33, Katerina's picks of 28 September: a row that is one link is `Link` with `cover`, and a\n // chip that is a link is `Chip` with `href`. Before, both apps stretched a link over its row by\n // hand (`after:absolute`) and rounded a Link round a chip, each under an escape.\n ticket('UIG-33', [\n { what: 'the installed package has Link cover and Chip href', run: all(h, [\n () => h.contains(at('node_modules/@estiva-app/ui/dist/Link.d.ts'), /\\bcover\\?: boolean/, 'the installed Link takes cover'),\n () => h.contains(at('node_modules/@estiva-app/ui/dist/Chip.d.ts'), /\\bhref\\?: string/, 'the installed Chip takes href'),\n ], 'the installed Link takes cover and Chip takes href') },\n { what: 'no link is stretched over its row by hand', run: () => {\n const sources = h.listFiles(at('src'), (n) => /\\.tsx$/.test(n) && !/\\.(test|stories)\\.tsx$/.test(n))\n const own = sources.filter((f) => /<(?:Link|a)\\b[^>]*\\bafter:(?:absolute|inset-0)\\b/.test(h.read(f)))\n return own.length ? h.FAIL(`stretches a link by hand (${own.join(', ')}): give the Link cover`) : h.PASS('every whole-row link is Link with cover')\n } },\n ]),\n // Katerina's ruling of 17 September (docs/GATES.md \u00A723): one copy, in the package. An app made\n // by create-estiva-app passes this from its first commit; Peek and Ship do once UIG-32 lands.\n ticket('UIG-32', [\n { what: 'the gate pieces come from the package, and no repo keeps a copy', run: all(h, [\n () => h.contains(at('eslint.gates.config.js'), /from '@estiva-app\\/ui\\/gates'/, 'the gate config imports @estiva-app/ui/gates'),\n () => h.hook('.claude/settings.json', '@estiva-app/ui/dist/gates/cli.js'),\n // `estiva-gates status` where npm can find the command; by path where it cannot,\n // because the install is in the app's folder and the script is in the repo's top one (Ship).\n () => h.contains('package.json', /\"gates:status\":\\s*\"[^\"]*(?:estiva-gates|@estiva-app\\/ui\\/dist\\/gates\\/cli\\.js)[^\"]*status/, \"gates:status runs the package's engine\"),\n () => (h.exists('scripts/gates-status.mjs') ? h.FAIL('scripts/gates-status.mjs is a copy of the status engine: run estiva-gates status instead') : h.PASS('no copy of the status engine')),\n ], 'the gate config, the hook and gates:status are the package\\'s; no copy of the engine') },\n ]),\n ticket('UIG-37', [\n { what: 'a TypeScript eslint-disable comment breaks neither the gate nor the token lint', run: all(h, [\n probe(typescriptDirective, 'none'),\n tokenProbe(typescriptDirective, 'none'),\n ], `${[GATES, ...tokenConfigs].join(', ')}: a TypeScript directive is no error`) },\n { what: 'a token lint on its own is the package\\'s tokenConfig, not built by hand', run: () =>\n (h.exists(at('eslint.tokens.config.js'))\n ? h.contains(at('eslint.tokens.config.js'), /\\btokenConfig\\(/, 'eslint.tokens.config.js runs tokenConfig from @estiva-app/ui/gates')\n : h.PASS('no token lint on its own')) },\n ]),\n ]\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,uBAAuB;AAC9B,SAAS,UAAU,wBAAwB;AAC3C,OAAO,YAAY;AAuBZ,SAAS,SAAS,EAAE,WAAW,MAAM,IAAyC,CAAC,GAAkB;AACtG,SAAO;AAAA,IACL,GAAI,aAAa,YAAY,OAAO,QAAQ,UAAU,OAAO,QAAQ;AAAA;AAAA;AAAA,IAGrE,OAAO,aAAa,YAAY,CAAC,cAAc,IAAI,CAAC,0CAA0C;AAAA,IAC9F,SAAS,CAAC,aAAa;AAAA,IACvB,iBAAiB;AAAA,MACf,QAAQ;AAAA,MACR,eAAe,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE;AAAA,IAC/C;AAAA,EACF;AACF;AAOO,SAAS,WAAW,EAAE,WAAW,OAAO,QAAQ,CAAC,GAAG,UAAU,CAAC,EAAE,IAAuB,CAAC,GAAoB;AAClH,SAAO;AAAA,IACL,EAAE,SAAS,CAAC,GAAG,oBAAoB,GAAG,OAAO,EAAE;AAAA,IAC/C;AAAA,MACE,SAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG;AAAA,QACH,sBAAsB;AAAA,QACtB,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,QACjB,eAAe;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA,MAIA,eAAe,EAAE,+BAA+B,MAAM;AAAA,IACxD;AAAA,IACA,SAAS,EAAE,SAAS,CAAC;AAAA,EACvB;AACF;;;AC7CO,IAAM,oBAA4C;AAAA,EACvD,SA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O,0BAA0B,IAAI,EAAE,KAAK,0FAA0F,IAAI,EAAE,KAAK,8BAA8B;AAAA,MAC1L,GAAG,qFAAsF,EAAE;AAAA,IAC7F,CAAC;AAAA,IACD,OAAO,UAAU;AAAA,MACf,EAAE,MAAM,kFAAkF,KAAK,IAAI,GAAG;AAAA,QACpG,MAAM,qBAAqB,MAAM;AAAA,QACjC,WAAW,qBAAqB,MAAM;AAAA,MACxC,GAAG,GAAG,CAAC,OAAO,GAAG,YAAY,EAAE,KAAK,IAAI,CAAC,sCAAsC,EAAE;AAAA,MACjF,EAAE,MAAM,2EAA4E,KAAK,MACtF,EAAE,OAAO,GAAG,yBAAyB,CAAC,IACnC,EAAE,SAAS,GAAG,yBAAyB,GAAG,mBAAmB,oEAAoE,IACjI,EAAE,KAAK,0BAA0B,EAAG;AAAA,IAC5C,CAAC;AAAA,EACH;AACF;",
|
|
4
|
+
"sourcesContent": ["/// <reference types=\"node\" />\n/**\n * Where the UI Guardrails' rules apply, written once (docs/GATES.md \u00A723).\n *\n * Until UIG-10 every repo wrote this itself: `eslint.gates.js` (the rules and\n * where they apply) and `eslint.gates.config.js` (the gate: those rules alone)\n * in Peek, in Ship, and here pointed inward. The rules were always the\n * package's; these two files were copies. Now they are two functions.\n *\n * Where: every `.ts` and `.tsx` under `src`, stories included (a story is what\n * people read and copy), tests not (a test mounts markup to test it) \u2014\n * Katerina's rulings of 13 September; `.ts` since UIG-8. This package's own\n * inward set reads `.tsx` only, as it always has.\n *\n * A place that keeps something says why, on the line above:\n * `// @estiva-escape: <reason>`, or `{/* @estiva-escape: <reason> *\\/}` as a\n * JSX child. Never `eslint-disable`: the count refuses it.\n */\nimport type { ESLint, Linter } from 'eslint'\nimport betterTailwindcss from 'eslint-plugin-better-tailwindcss'\nimport { parser as typescriptParser } from 'typescript-eslint'\nimport estiva from '../eslint/index'\nimport { KNOWN_PLUGINS, TOKEN_LINT_IGNORES } from './token-lint'\nimport { tokenJoinedPlugin } from './token-joined'\nimport { tokenStylePlugin } from './token-style'\n\nexport interface GateConfigOptions {\n /** `app` (the default) runs `configs.recommended`; `package` runs this package's inward set. */\n audience?: 'app' | 'package'\n /**\n * Plugins whose `eslint-disable` directives appear in the source, registered\n * here with every rule off. ESLint refuses a directive for a rule it does not\n * know, so without them the gate would fail on another lint's comments.\n * The token lint's names and TypeScript's are registered already (UIG-37).\n */\n quiet?: Record<string, ESLint.Plugin>\n /** Folders the gate never reads, beside build output. */\n ignores?: string[]\n}\n\n/**\n * The rules and where they apply \u2014 one config object, to add beside\n * everything else an app's `eslint.config.js` runs, so an editor shows a\n * refusal where the element is typed.\n */\nexport function gateLint({ audience = 'app' }: Pick<GateConfigOptions, 'audience'> = {}): Linter.Config {\n return {\n ...(audience === 'package' ? estiva.configs.package : estiva.configs.recommended),\n // An app's every script type: a raw <button> in a .jsx, or a key listener in a .mts,\n // passed while only .ts and .tsx were read (the re-review after the audit before UIG-26).\n files: audience === 'package' ? ['src/**/*.tsx'] : ['src/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}'],\n ignores: ['**/*.test.*'],\n languageOptions: {\n parser: typescriptParser,\n parserOptions: { ecmaFeatures: { jsx: true } },\n },\n }\n}\n\n/**\n * The gate: the rules on their own \u2014 `npm run lint:rules`, CI's job `gate`, and\n * the config the editor hook lints a proposed write with. It fails on a gate\n * rule and on nothing else, so a backlog in the full lint never blocks it.\n */\nexport function gateConfig({ audience = 'app', quiet = {}, ignores = [] }: GateConfigOptions = {}): Linter.Config[] {\n return [\n { ignores: [...TOKEN_LINT_IGNORES, ...ignores] },\n {\n plugins: {\n ...KNOWN_PLUGINS,\n ...quiet,\n 'better-tailwindcss': betterTailwindcss,\n 'token-values': betterTailwindcss,\n 'token-spacing': betterTailwindcss,\n 'token-style': tokenStylePlugin,\n 'token-joined': tokenJoinedPlugin,\n },\n // Every other config's directives are unused here, because their rules are\n // off here. Reporting them would be this config complaining about the\n // others' business.\n linterOptions: { reportUnusedDisableDirectives: 'off' },\n },\n gateLint({ audience }),\n ]\n}\n", "/// <reference types=\"node\" />\n/**\n * The gate checks every app runs, written once (docs/GATES.md \u00A723).\n *\n * Until UIG-10 Peek and Ship each wrote them into their own\n * `scripts/gates-checks.mjs`. 65 different checks for finished tickets, counted\n * on 17 September: 28 were identical in both, 21 were the same check written two\n * ways, 2 read each app's real page, and 14 read code only one app has. This is\n * the first three groups as one list. The fourth stays in the app's own checks\n * file, beside this list.\n *\n * Where Peek and Ship wrote one check two ways, the check here runs both, so it\n * passes wherever either did: the raw-link probe with both of their texts, the\n * token probes against each token config the app has.\n *\n * `scripts/gates-compare.mjs` holds this list to Peek's and Ship's: every check\n * of theirs must be here, or be about code only that app has, or the comparison\n * fails and names it.\n *\n * A check for a ticket not built yet is a first guess at the evidence, taken\n * from the ticket's own text; the ticket that builds it changes it here.\n */\nimport type { CheckResult, GateCheck, GateHelpers, GateTicket } from './status'\n\nexport interface AppCheckOptions {\n /** Where the app is inside the repository: `.` unless it sits in a folder of its own. */\n app?: string\n /** A real page of the app, relative to the app, full of elements that are not controls. */\n page: string\n /** The ticket the gate chain is listed under, and whether this repo owns it: UIG-3 in Peek, UIG-4 in Ship. */\n chain?: { ref: string; owner: boolean }\n /** The token lint configs the app has, relative to the app. */\n tokenConfigs?: string[]\n /** The part a hand-made column header should name (UIG-22): `Panel` since 0.37.0, `ContainerHeader` before. */\n headers?: string[]\n}\n\nexport const APP_TICKET_TITLES: Record<string, string> = {\n 'UIG-2': 'The tracking rails \u2014 GATES.md, the status script, the guide committed',\n 'UIG-3': 'Tracer bullet \u2014 one rule, end to end, blocking in Peek',\n 'UIG-4': 'The same chain, blocking in Ship',\n 'UIG-6': 'Branch protection \u2014 the backstop, all three repos',\n 'UIG-7': 'Lint rule \u2014 every remaining raw element',\n 'UIG-8': 'Lint rule \u2014 forbid the reach',\n 'UIG-9': 'Lint rule \u2014 the className allow-list',\n 'UIG-10': 'create-app \u2014 a command that makes a new Estiva app that runs',\n 'UIG-13': \"The registry widens to Peek's 115 and Ship's 74, with classification\",\n 'UIG-19': 'Lock the contract in CI',\n 'UIG-20': 'The Claude skill, reading the registry',\n 'UIG-21': 'CLAUDE.md becomes an index, not a lecture',\n 'UIG-22': 'Fingerprint \u2014 a hand-made header row',\n 'UIG-23': 'Fingerprint \u2014 a hand-made empty state',\n 'UIG-24': 'Fingerprint \u2014 a browser tooltip where ours belongs',\n 'UIG-25': 'Fingerprint \u2014 a component copied out by hand',\n 'UIG-27': 'The components the apps had to build themselves \u2014 Link, ProgressBar, EmptyState padding',\n 'UIG-28': 'Close the two holes in the token contract \u2014 arbitrary values, and inline style',\n 'UIG-30': 'RichText \u2014 one component that draws a message\\'s text, for both apps',\n 'UIG-32': 'Peek and Ship take their gate pieces from the package',\n 'UIG-37': 'The gates refuse a TypeScript eslint-disable comment \u2014 know the rule names, rules off',\n 'UIG-42': \"What the gate can't see yet \u2014 a box around a part, a screen drawn by hand, two blind spots in the token check\",\n}\n\n/** Run several checks as one: the first that does not pass is the answer. */\nfunction all(h: GateHelpers, steps: (() => CheckResult | Promise<CheckResult>)[], label: string): () => Promise<CheckResult> {\n return async () => {\n for (const step of steps) {\n const r = await step()\n if (r.result !== 'pass') return r\n }\n return h.PASS(label)\n }\n}\n\nexport function appChecks(h: GateHelpers, { app = '.', page, chain = { ref: 'UIG-3', owner: false }, tokenConfigs = ['eslint.tokens.config.js', 'eslint.config.js'], headers = ['Panel'] }: AppCheckOptions): GateTicket[] {\n const WEB = app === '.' ? '' : `${app.replace(/\\/$/, '')}/`\n const cwd = app === '.' ? undefined : app\n const PROBE = 'src/components/__gates_probe__.tsx'\n const GATES = 'eslint.gates.config.js'\n const at = (rel: string) => `${WEB}${rel}`\n const probe = (code: string, expect: 'error' | 'warning' | 'none', mentions?: string, file = PROBE, config = GATES) => () =>\n h.lint({ ...(cwd ? { cwd } : {}), config, file, code, expect, mentions })\n const component = (body: string) => `export function Probe() {\\n return ${body}\\n}\\n`\n const installed = at('node_modules/@estiva-app/ui/dist/index.d.ts')\n const realPage = (): Promise<CheckResult> => h.lint({ ...(cwd ? { cwd } : {}), config: GATES, file: page, code: h.read(at(page)), expect: 'none' })\n const button = component('<button type=\"button\">x</button>')\n /** A line TypeScript's own lint writes; ESLint refuses it where TypeScript's plugin is unknown (UIG-37). */\n const typescriptDirective = '// eslint-disable-next-line @typescript-eslint/no-explicit-any\\nexport const probe: any = 1\\n'\n const ticket = (ref: string, checks: GateCheck[], owner = false): GateTicket => ({ ref, title: APP_TICKET_TITLES[ref], owner, checks })\n\n const tokenProbe = (code: string, expect: 'error' | 'warning' | 'none', mentions?: string, file = PROBE) =>\n all(h, tokenConfigs.map((config) => probe(code, expect, mentions, file, config)), `${tokenConfigs.join(' and ')}: as expected`)\n\n return [\n ticket('UIG-2', [\n { what: 'npm run gates:status is wired', run: () => h.script('package.json', 'gates:status') },\n ]),\n ticket(chain.ref, [\n { what: 'the gate lint config loads', run: () => h.loads(at(GATES)) },\n { what: `${at('package.json')} has lint:rules`, run: () => h.script(at('package.json'), 'lint:rules') },\n { what: 'CI runs lint:rules', run: () => h.ci('lint:rules') },\n { what: 'the committed hook runs the gate lint', run: () => h.hook('.claude/settings.json', 'gates') },\n { what: '.gates-count.json is committed and parses', run: () => h.json(h.exists('.gates-count.json') ? '.gates-count.json' : at('.gates-count.json')) },\n { what: 'a raw <button> is an error naming Button', run: probe(button, 'error', 'Button') },\n { what: 'the same in a story', run: probe(button, 'error', 'Button', 'src/stories/__gates_probe__.stories.tsx') },\n { what: 'a test file is not checked, while source is', run: async () => {\n const source = await probe(button, 'error', 'Button')()\n if (source.result !== 'pass') return h.FAIL(`source is not checked yet, so this proves nothing: ${source.detail}`)\n return probe(button, 'none', undefined, 'src/components/__gates_probe__.test.tsx')()\n } },\n { what: 'the debt list exists', run: () => h.file('docs/GATES-DEBT.md') },\n ], chain.owner),\n ticket('UIG-6', [\n { what: 'GitHub requires the check gate to merge into main', run: () => h.protectedBranch(/^gate$/) },\n { what: \"CI's job gate runs lint:rules\", run: () => h.ciJob('gate', 'lint:rules') },\n ]),\n ticket('UIG-7', [\n { what: 'a raw <input> is an error naming TextInput', run: probe(component('<input />'), 'error', 'TextInput') },\n { what: 'a clickable <div> is an error naming Button (R5)', run: probe(component('<div onClick={() => history.back()}>Back</div>'), 'error', '`Button`') },\n { what: 'a raw <a> is an error naming Link', run: all(h, [probe(component('<a href=\"/topics\">Topics</a>'), 'error', 'Link'), probe(component('<a href=\"/issues\">Issues</a>'), 'error', 'Link')], 'a raw <a> is an error naming Link') },\n { what: 'a raw <form> is an error naming Form, and a file input one naming FilePicker', run: async () => {\n const form = await probe(component('<form />'), 'error', '`Form`')()\n if (form.result !== 'pass') return form\n return probe(component('<input type=\"file\" />'), 'error', 'FilePicker')()\n } },\n { what: '<textarea>, <select>, <dialog> and <label> name Textarea, Select, DialogShell and Field', run: async () => {\n for (const [element, part] of [['textarea', 'Textarea'], ['select', 'Select'], ['dialog', 'DialogShell'], ['label', 'Field']]) {\n const one = await probe(component(`<${element} />`), 'error', `\\`${part}\\``)()\n if (one.result !== 'pass') return one\n }\n return h.PASS('all four are errors, each naming its part')\n } },\n { what: 'an element the package has no part for is an error that says to ask for one', run: probe(component('<iframe title=\"Map\" />'), 'error', 'ask Katerina') },\n { what: 'an escaped element is not an error, while the same element is', run: async () => {\n const raw = await probe(component('<form />'), 'error')()\n if (raw.result !== 'pass') return h.FAIL(`a raw <form> is not caught yet, so this proves nothing: ${raw.detail}`)\n return probe('export function Probe() {\\n return (\\n // @estiva-escape(no-raw-element): a probe that keeps its element on purpose\\n <form />\\n )\\n}\\n', 'none')()\n } },\n { what: 'a real page, full of elements that are not controls, gets no error', run: realPage },\n ]),\n ticket('UIG-8', [\n { what: 'a Base UI import is an error naming the part built on it', run: probe(\"import { Popover } from '@base-ui/react/popover'\\nexport const Probe = Popover\\n\", 'error', '`Popover`') },\n { what: 'createPortal is an error naming the floating parts', run: probe(\"import { createPortal } from 'react-dom'\\nexport const Probe = (to: HTMLElement) => createPortal(<span />, to)\\n\", 'error', '`DialogShell`') },\n { what: 'a key listener on the whole page is an error, in a .ts file too', run: probe(\"export function listen() {\\n window.addEventListener('keydown', () => {})\\n}\\n\", 'error', '`DialogShell`', 'src/lib/__gates_probe__.ts') },\n { what: 'arrow keys by hand are an error; Enter in a field is not', run: async () => {\n const arrows = await probe(\"export const onKeyDown = (e: KeyboardEvent) => e.key === 'ArrowDown'\\n\", 'error', '`Menu`', 'src/lib/__gates_probe__.ts')()\n if (arrows.result !== 'pass') return arrows\n return probe(\"export const onKeyDown = (e: KeyboardEvent) => e.key === 'Enter'\\n\", 'none', undefined, 'src/lib/__gates_probe__.ts')()\n } },\n { what: 'a hand-written role=\"option\" is an error naming Select', run: probe(component('<div role=\"option\" />'), 'error', '`Select`') },\n { what: 'tabIndex={0} on a div is an error; tabIndex={-1} is not', run: async () => {\n const zero = await probe(component('<div tabIndex={0} />'), 'error', '`Button`')()\n if (zero.result !== 'pass') return h.FAIL(`tabIndex={0} is not caught yet, so this proves nothing: ${zero.detail}`)\n return probe(component('<div tabIndex={-1} />'), 'none')()\n } },\n { what: 'overflow-y-auto is an error naming ScrollArea', run: probe(component('<div className=\"h-64 overflow-y-auto\" />'), 'error', '`ScrollArea`') },\n { what: 'an escaped listener is not an error, while the same listener is', run: async () => {\n const raw = await probe(\"export function listen() {\\n document.addEventListener('mousedown', () => {})\\n}\\n\", 'error', undefined, 'src/lib/__gates_probe__.ts')()\n if (raw.result !== 'pass') return h.FAIL(`a page listener is not caught yet, so this proves nothing: ${raw.detail}`)\n return probe(\"export function listen() {\\n // @estiva-escape(no-rebuilt-behaviour): a probe that keeps its listener on purpose\\n document.addEventListener('mousedown', () => {})\\n}\\n\", 'none', undefined, 'src/lib/__gates_probe__.ts')()\n } },\n { what: 'a real page gets no error', run: realPage },\n ]),\n ticket('UIG-9', [\n { what: 'a border passed into Button is an error naming Button', run: probe(`import { Button } from '@estiva-app/ui'\\n${component('<Button className=\"border\">x</Button>')}`, 'error', 'on `Button` changes how it looks') },\n { what: 'placement passed into Button is not', run: probe(`import { Button } from '@estiva-app/ui'\\n${component('<Button className=\"mt-2 w-full flex-1 relative\">x</Button>')}`, 'none') },\n { what: 'an escaped look is not an error, while the same look is', run: async () => {\n const raw = await probe(`import { Link } from '@estiva-app/ui'\\n${component('<Link href=\"/x\" className=\"after:absolute after:inset-0\">x</Link>')}`, 'error', '`Link`')()\n if (raw.result !== 'pass') return h.FAIL(`a restyled part is not caught yet, so this proves nothing: ${raw.detail}`)\n return probe(`import { Link } from '@estiva-app/ui'\\nexport function Probe() {\\n return (\\n // @estiva-escape(no-restyled-part): a probe that keeps its row link on purpose\\n <Link href=\"/x\" className=\"after:absolute after:inset-0\">x</Link>\\n )\\n}\\n`, 'none')()\n } },\n { what: 'a real page gets no error', run: realPage },\n ]),\n // UIG-10, reopened 18 September: a tab holds one relay client, the way Peek and Ship hold\n // theirs and a made app is written to. Measured on both mains that day: one each, and no\n // socket opened any other way. A second holder, or a socket of the app's own, is a second\n // connection the relay signs in and budgets separately.\n ticket('UIG-10', [\n { what: 'the app holds one relay client, at module level, and opens no socket of its own', run: () => {\n const sources = h.listFiles(at('src'), (n) => /\\.tsx?$/.test(n) && !/\\.(test|stories)\\.tsx?$/.test(n))\n const own = sources.filter((f) => /\\bcreateLiveClient\\(|\\bcreateLiveRelay\\(|\\bnew WebSocket\\(/.test(h.read(f)))\n if (own.length) return h.FAIL(`opens a socket of its own (${own.join(', ')}): hold one client from createLiveClientHolder()`)\n const holders = sources.filter((f) => /^\\s*(?:export\\s+)?const\\s+\\w+\\s*=\\s*createLiveClientHolder\\(\\)/m.test(h.read(f)))\n if (holders.length !== 1) return h.FAIL(holders.length ? `${holders.length} client holders (${holders.join(', ')}): a tab holds one` : 'no module-level createLiveClientHolder(): the app has no relay client')\n return h.PASS(`one client for the tab, held in ${holders[0]}`)\n } },\n ]),\n // Built by UIG-13, 18 September. An app's catalogue is built fresh from its code\n // and never committed: the package is public and the apps are private (Katerina).\n ticket('UIG-13', [\n { what: \"npm run ui:find is the package's search, over the package and this app\", run: () => h.contains(at('package.json'), /\"ui:find\":\\s*\"estiva-ui find\\b/, \"ui:find runs the package's estiva-ui find\") },\n { what: \"npm run registry:check is the package's check\", run: () => h.contains(at('package.json'), /\"registry:check\":\\s*\"estiva-ui check\\b/, 'registry:check runs estiva-ui check') },\n { what: \"CI's job gate refuses a part with no description\", run: () => h.ciJob('gate', 'registry:check') },\n // In the .gitignore of the app's own folder, where `estiva-ui build` would write it.\n { what: 'the catalogue is never committed: git ignores registry.json', run: () => h.contains(at('.gitignore'), /^\\/?registry\\.json\\r?$/m, `${at('.gitignore')} ignores registry.json`) },\n { what: 'every part is described and sorted, and every file is accounted for', run: () => h.catalogue(at('.')) },\n ]),\n ticket('UIG-19', [\n // The contract runs inside `estiva-ui check`, which the gate job already runs\n // (UIG-13), so an app changes no script: it takes the package that has it.\n { what: 'the installed package checks the usage-page contract and the story links', run: () => h.contains(at('node_modules/@estiva-app/ui/dist/registry/cli.js'), 'the usage-page contract', \"the installed estiva-ui check runs the contract\") },\n { what: \"CI's job gate runs it\", run: () => h.ciJob('gate', 'registry:check') },\n { what: 'the app keeps no copy of it in its own gates-checks.mjs', run: () => h.exists(at('scripts/gates-checks.mjs')) ? h.lacks(at('scripts/gates-checks.mjs'), '\"When not\"', 'the app checks no page sections itself') : h.PASS('the app has no gates-checks.mjs') },\n ]),\n // The Claude skill (UIG-20): its text is the installed package's, read in by a\n // loader `estiva-ui skill` writes; the app commits the loader and the settings.\n ticket('UIG-20', [\n { what: \"the skill's loader reads the installed package's text\", run: () => h.contains('.claude/skills/estiva-ui/SKILL.md', `!\\`cat \"\\${CLAUDE_PROJECT_DIR}/${at('node_modules/@estiva-app/ui/skill/estiva-ui.md')}\"\\``, 'the loader reads the package\u2019s skill') },\n { what: 'the search runs without a prompt', run: () => h.contains('.claude/settings.json', 'Bash(npm run ui:find *)', '.claude/settings.json allows npm run ui:find') },\n { what: 'ui:find searches every app beside this one: it names none', run: () => h.lacks(at('package.json'), /\"ui:find\":[^\\n]*--also/, 'ui:find names no neighbour, so it finds them all') },\n ...(WEB ? [{ what: 'ui:find runs from the top folder too', run: () => h.contains('package.json', /\"ui:find\":/, 'the top folder has ui:find') }] : []),\n { what: \"CI's job gate refuses a loader that differs\", run: () => (h.exists(at('node_modules/@estiva-app/ui/dist/registry/cli.js')) && /claude skill:/.test(h.read(at('node_modules/@estiva-app/ui/dist/registry/cli.js'))) ? h.ciJob('gate', 'registry:check') : h.FAIL('the installed package does not check the loader: take a version that does')) },\n ]),\n // What loads into every Claude session (UIG-21): CLAUDE.md is an index, the\n // rest loads where it applies, and a rule a check can hold is a check.\n ticket('UIG-21', [\n { what: 'CLAUDE.md with its imports is under 200 lines, and every rule file is scoped', run: () => h.instructions(200) },\n { what: \"CI's job gate runs the token lint\", run: () => {\n const tokens = h.ciJob('gate', 'lint:tokens')\n return tokens.result === 'pass' ? tokens : h.ciJob('gate', 'lint')\n } },\n { what: \"a plain tailwind-merge is an error naming the package's cn()\", run: tokenProbe(\"import { twMerge } from 'tailwind-merge'\\nexport const merged = twMerge('p-2', 'p-3')\\n\", 'error', 'cn()', 'src/lib/__gates_probe__.ts') },\n ]),\n ticket('UIG-22', [\n // The Folders pane's own row, at the commit before peek 3dc663b.\n { what: `a hand-made column header is an error naming ${headers.join(' or ')}`, run: all(h, headers.map((name) => probe(component('<div className=\"flex h-full flex-col\"><div className=\"flex items-center gap-2 px-3 py-2\"><span>Folders</span></div><div /></div>'), 'error', name)), `a hand-made column header is an error naming ${headers.join(' or ')}`) },\n // 26 September: the package's header on its own is a panel made by hand, whose box forgot to scroll.\n { what: \"the package's ContainerHeader on its own is an error naming Panel\", run: probe(`import { ContainerHeader } from '@estiva-app/ui'\\n${component('<div className=\"flex flex-col\"><ContainerHeader title=\"Details\" /><div className=\"px-4\">x</div></div>')}`, 'error', '`Panel`') },\n { what: 'a group heading inside a list is left alone', run: probe(component('<section className=\"flex flex-col gap-px\"><h3 className=\"flex h-8 items-center gap-2 px-3\"><span>Todo</span></h3><div /></section>'), 'none') },\n ]),\n ticket('UIG-23', [\n { what: 'a hand-made empty line is an error naming EmptyState', run: probe(\"export function Probe({ items }: { items: string[] }) {\\n return <div>{items.length === 0 ? <p className=\\\"text-text-secondary\\\">Nothing here</p> : items.map((i) => <span key={i}>{i}</span>)}</div>\\n}\\n\", 'error', 'EmptyState') },\n ]),\n ticket('UIG-24', [\n { what: 'a title= is an error naming WithTooltip', run: probe(`import { Button } from '@estiva-app/ui'\\n${component('<Button title=\"Delete\">x</Button>')}`, 'error', 'WithTooltip') },\n ]),\n ticket('UIG-25', [\n { what: \"SectionLabel's class list, typed by hand, is a warning\", run: probe(component('<span className=\"text-h5 leading-3 signal:font-mono signal:text-small signal:uppercase signal:tracking-widest text-text-secondary\">Label</span>'), 'warning', 'SectionLabel') },\n ]),\n ticket('UIG-27', [\n { what: 'the installed package has Link', run: () => h.contains(installed, /\\bLink\\b/, 'the installed @estiva-app/ui exports Link') },\n { what: 'the installed package has ProgressBar', run: () => h.contains(installed, /\\bProgressBar\\b/, 'the installed @estiva-app/ui exports ProgressBar') },\n ]),\n ticket('UIG-28', [\n { what: 'text-[14px] is an error', run: tokenProbe(component('<div className=\"text-[14px]\">x</div>'), 'error') },\n { what: 'a colour in an inline style is an error', run: tokenProbe(component(\"<div style={{ backgroundColor: '#ff0000' }}>x</div>\"), 'error') },\n { what: 'h-[240px] is a warning', run: tokenProbe(component('<div className=\"h-[240px]\">x</div>'), 'warning') },\n { what: 'h-[240px] is not an error', run: tokenProbe(component('<div className=\"h-[240px]\">x</div>'), 'none') },\n { what: 'a hand-written line height behind an arbitrary variant is an error', run: tokenProbe(component('<div className=\"[&_p]:leading-[1.4]\">x</div>'), 'error') },\n { what: 'a raw colour in a class is an error (the pattern that matched nothing, R1)', run: tokenProbe(component('<div className=\"bg-[#5c69dc]\">x</div>'), 'error', 'raw colour') },\n { what: 'a width and height from a prop pass', run: tokenProbe(\"export function Probe({ size }: { size: number }) {\\n return <div style={{ width: size, height: size }}>x</div>\\n}\\n\", 'none') },\n { what: 'a test file is not checked for hand-written values, while source is', run: all(h, tokenConfigs.map((config) => async () => {\n const code = component(\"<div className=\\\"text-[14px]\\\" style={{ color: 'red' }}>x</div>\")\n const source = await probe(code, 'error', undefined, PROBE, config)()\n if (source.result !== 'pass') return h.FAIL(`source is not checked yet, so this proves nothing: ${source.detail}`)\n return probe(code, 'none', undefined, 'src/components/__gates_probe__.test.tsx', config)()\n }), 'a test file is not checked for hand-written values, while source is') },\n ]),\n // Built 28 September: the token check's two blind spots, and a box that places a page EmptyState.\n ticket('UIG-42', [\n { what: 'a class behind an arbitrary variant is an error', run: tokenProbe(component('<div className=\"group-hover/row:bg-gray-100\">x</div>'), 'error') },\n { what: 'a class list joined by hand is read', run: tokenProbe(component(\"<div className={['text-sm', 'p-2'].join(' ')}>x</div>\"), 'error') },\n { what: 'a box that centres a page EmptyState is an error naming it', run: probe(`import { EmptyState } from '@estiva-app/ui'\\n${component('<div className=\"flex items-center justify-center\"><EmptyState message=\"Nothing here\" /></div>')}`, 'error', 'page-scope EmptyState') },\n ]),\n // Built 28 September: both apps drew the protocol's text tree by hand, and drifted apart.\n // A file that reads the protocol and draws a quote or a numbered list itself is a third copy.\n ticket('UIG-30', [\n { what: 'the installed package has RichText', run: () => h.contains(installed, /\\bRichText\\b/, 'the installed @estiva-app/ui exports RichText') },\n { what: \"no file draws the protocol's text tree by hand\", run: () => {\n const sources = h.listFiles(at('src'), (n) => /\\.tsx$/.test(n) && !/\\.(test|stories)\\.tsx$/.test(n))\n const own = sources.filter((f) => { const text = h.read(f); return /from ['\"]@estiva-app\\/protocol['\"]/.test(text) && /<(?:blockquote|ol)\\b/.test(text) })\n return own.length ? h.FAIL(`draws the text tree itself (${own.join(', ')}): pass the tree to RichText`) : h.PASS('formatted text is drawn by RichText only')\n } },\n ]),\n // UIG-33, Katerina's picks of 28 September: a row that is one link is `Link` with `cover`, and a\n // chip that is a link is `Chip` with `href`. Before, both apps stretched a link over its row by\n // hand (`after:absolute`) and rounded a Link round a chip, each under an escape.\n ticket('UIG-33', [\n { what: 'the installed package has Link cover and Chip href', run: all(h, [\n () => h.contains(at('node_modules/@estiva-app/ui/dist/Link.d.ts'), /\\bcover\\?: boolean/, 'the installed Link takes cover'),\n () => h.contains(at('node_modules/@estiva-app/ui/dist/Chip.d.ts'), /\\bhref\\?: string/, 'the installed Chip takes href'),\n ], 'the installed Link takes cover and Chip takes href') },\n { what: 'no link is stretched over its row by hand', run: () => {\n const sources = h.listFiles(at('src'), (n) => /\\.tsx$/.test(n) && !/\\.(test|stories)\\.tsx$/.test(n))\n const own = sources.filter((f) => /<(?:Link|a)\\b[^>]*\\bafter:(?:absolute|inset-0)\\b/.test(h.read(f)))\n return own.length ? h.FAIL(`stretches a link by hand (${own.join(', ')}): give the Link cover`) : h.PASS('every whole-row link is Link with cover')\n } },\n ]),\n // Katerina's ruling of 17 September (docs/GATES.md \u00A723): one copy, in the package. An app made\n // by create-estiva-app passes this from its first commit; Peek and Ship do once UIG-32 lands.\n ticket('UIG-32', [\n { what: 'the gate pieces come from the package, and no repo keeps a copy', run: all(h, [\n () => h.contains(at('eslint.gates.config.js'), /from '@estiva-app\\/ui\\/gates'/, 'the gate config imports @estiva-app/ui/gates'),\n () => h.hook('.claude/settings.json', '@estiva-app/ui/dist/gates/cli.js'),\n // `estiva-gates status` where npm can find the command; by path where it cannot,\n // because the install is in the app's folder and the script is in the repo's top one (Ship).\n () => h.contains('package.json', /\"gates:status\":\\s*\"[^\"]*(?:estiva-gates|@estiva-app\\/ui\\/dist\\/gates\\/cli\\.js)[^\"]*status/, \"gates:status runs the package's engine\"),\n () => (h.exists('scripts/gates-status.mjs') ? h.FAIL('scripts/gates-status.mjs is a copy of the status engine: run estiva-gates status instead') : h.PASS('no copy of the status engine')),\n ], 'the gate config, the hook and gates:status are the package\\'s; no copy of the engine') },\n ]),\n ticket('UIG-37', [\n { what: 'a TypeScript eslint-disable comment breaks neither the gate nor the token lint', run: all(h, [\n probe(typescriptDirective, 'none'),\n tokenProbe(typescriptDirective, 'none'),\n ], `${[GATES, ...tokenConfigs].join(', ')}: a TypeScript directive is no error`) },\n { what: 'a token lint on its own is the package\\'s tokenConfig, not built by hand', run: () =>\n (h.exists(at('eslint.tokens.config.js'))\n ? h.contains(at('eslint.tokens.config.js'), /\\btokenConfig\\(/, 'eslint.tokens.config.js runs tokenConfig from @estiva-app/ui/gates')\n : h.PASS('no token lint on its own')) },\n ]),\n ]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,uBAAuB;AAC9B,SAAS,UAAU,wBAAwB;AAC3C,OAAO,YAAY;AAwBZ,SAAS,SAAS,EAAE,WAAW,MAAM,IAAyC,CAAC,GAAkB;AACtG,SAAO;AAAA,IACL,GAAI,aAAa,YAAY,OAAO,QAAQ,UAAU,OAAO,QAAQ;AAAA;AAAA;AAAA,IAGrE,OAAO,aAAa,YAAY,CAAC,cAAc,IAAI,CAAC,0CAA0C;AAAA,IAC9F,SAAS,CAAC,aAAa;AAAA,IACvB,iBAAiB;AAAA,MACf,QAAQ;AAAA,MACR,eAAe,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE;AAAA,IAC/C;AAAA,EACF;AACF;AAOO,SAAS,WAAW,EAAE,WAAW,OAAO,QAAQ,CAAC,GAAG,UAAU,CAAC,EAAE,IAAuB,CAAC,GAAoB;AAClH,SAAO;AAAA,IACL,EAAE,SAAS,CAAC,GAAG,oBAAoB,GAAG,OAAO,EAAE;AAAA,IAC/C;AAAA,MACE,SAAS;AAAA,QACP,GAAG;AAAA,QACH,GAAG;AAAA,QACH,sBAAsB;AAAA,QACtB,gBAAgB;AAAA,QAChB,iBAAiB;AAAA,QACjB,eAAe;AAAA,QACf,gBAAgB;AAAA,MAClB;AAAA;AAAA;AAAA;AAAA,MAIA,eAAe,EAAE,+BAA+B,MAAM;AAAA,IACxD;AAAA,IACA,SAAS,EAAE,SAAS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AAK,IAAI,CAAC,wBAAwB,IAAI,EAAE,KAAK,yCAAyC;AAAA,MACpJ,EAAE;AAAA,IACJ,CAAC;AAAA;AAAA;AAAA,IAGD,OAAO,UAAU;AAAA,MACf,EAAE,MAAM,mEAAmE,KAAK,IAAI,GAAG;AAAA,QACrF,MAAM,EAAE,SAAS,GAAG,wBAAwB,GAAG,iCAAiC,8CAA8C;AAAA,QAC9H,MAAM,EAAE,KAAK,yBAAyB,kCAAkC;AAAA;AAAA;AAAA,QAGxE,MAAM,EAAE,SAAS,gBAAgB,6FAA6F,wCAAwC;AAAA,QACtK,MAAO,EAAE,OAAO,0BAA0B,IAAI,EAAE,KAAK,0FAA0F,IAAI,EAAE,KAAK,8BAA8B;AAAA,MAC1L,GAAG,qFAAsF,EAAE;AAAA,IAC7F,CAAC;AAAA,IACD,OAAO,UAAU;AAAA,MACf,EAAE,MAAM,kFAAkF,KAAK,IAAI,GAAG;AAAA,QACpG,MAAM,qBAAqB,MAAM;AAAA,QACjC,WAAW,qBAAqB,MAAM;AAAA,MACxC,GAAG,GAAG,CAAC,OAAO,GAAG,YAAY,EAAE,KAAK,IAAI,CAAC,sCAAsC,EAAE;AAAA,MACjF,EAAE,MAAM,2EAA4E,KAAK,MACtF,EAAE,OAAO,GAAG,yBAAyB,CAAC,IACnC,EAAE,SAAS,GAAG,yBAAyB,GAAG,mBAAmB,oEAAoE,IACjI,EAAE,KAAK,0BAA0B,EAAG;AAAA,IAC5C,CAAC;AAAA,EACH;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The token contract, read inside a class list joined by hand (UIG-42):
|
|
3
|
+
*
|
|
4
|
+
* <div className={['text-sm', open && 'bg-gray-100'].join(' ')} />
|
|
5
|
+
*
|
|
6
|
+
* The Tailwind plugin stops at a function call, so it never reads the list in
|
|
7
|
+
* front of `.join(' ')`, and no setting can make it: a call it is told about is
|
|
8
|
+
* read at its arguments, which here is the `' '`. This rule reads the list and
|
|
9
|
+
* tests each class against the same patterns, with the same messages, as the
|
|
10
|
+
* rule it stands in for. It registers once per rule it mirrors, so an error
|
|
11
|
+
* stays an error and a warning a warning (`token-joined/classes`, `/values`,
|
|
12
|
+
* `/spacing`).
|
|
13
|
+
*
|
|
14
|
+
* A list joined with anything but one space is not a class list, and a
|
|
15
|
+
* sentence built this way passes unless one of its words is itself such a
|
|
16
|
+
* class, as in `'set text-sm here'`. Only strings written in the list are
|
|
17
|
+
* read, directly or behind `cond && …`, `a ? … : …` and a template's fixed
|
|
18
|
+
* parts; a list worked out while it runs cannot be read.
|
|
19
|
+
*/
|
|
20
|
+
import type { ESLint } from 'eslint';
|
|
21
|
+
/** One pattern and its message, the shape `no-restricted-classes` takes. `$0` is the class. */
|
|
22
|
+
export interface Restriction {
|
|
23
|
+
pattern: string;
|
|
24
|
+
message: string;
|
|
25
|
+
}
|
|
26
|
+
/** The plugin, as the token lint registers it: one rule, under three names. */
|
|
27
|
+
export declare const tokenJoinedPlugin: ESLint.Plugin;
|
|
28
|
+
//# sourceMappingURL=token-joined.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token-joined.d.ts","sourceRoot":"","sources":["../../src/gates/token-joined.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,MAAM,EAAQ,MAAM,QAAQ,CAAA;AAE1C,+FAA+F;AAC/F,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;CAChB;AAmED,+EAA+E;AAC/E,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAgG,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-lint.d.ts","sourceRoot":"","sources":["../../src/gates/token-lint.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"token-lint.d.ts","sourceRoot":"","sources":["../../src/gates/token-lint.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAO5C,8BAA8B;AAC9B,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,SAAS,CAAA;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,uFAAuF;IACvF,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,0FAA0F;IAC1F,QAAQ,CAAC,EAAE,aAAa,CAAA;CACzB;AAED,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IACrC,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,qDAAqD;AACrD,eAAO,MAAM,kBAAkB,UAAkD,CAAA;AAEjF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAA+D,CAAA;AAuCvH;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EAAE,cAAqC,EAAE,QAAgB,EAAE,GAAE,gBAAqB,GAAG,MAAM,CAAC,MAAM,CAqC3H;AA8BD;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAgB,EAAE,GAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAM,GAAG,MAAM,CAAC,MAAM,CAwExG;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,KAAU,EAAE,OAAY,EAAE,GAAG,OAAO,EAAE,GAAE,kBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,CAa9G"}
|
package/package.json
CHANGED
package/registry.json
CHANGED
package/src/EmptyState.mdx
CHANGED
|
@@ -94,7 +94,7 @@ It does these by itself. Write none of them around it.
|
|
|
94
94
|
|
|
95
95
|
| It does | So you never write | Refused when written by hand |
|
|
96
96
|
|---|---|---|
|
|
97
|
-
| As a `page`, fills the room it is given and centres itself in it | centring, or padding around it | a `page` inside a `ScrollArea`, where it cannot centre (`estiva/no-handmade-empty-state`) |
|
|
97
|
+
| As a `page`, fills the room it is given and centres itself in it | centring, or padding around it | a box of its own that centres or pads a `page`, and a `page` inside a `ScrollArea`, where it cannot centre (`estiva/no-handmade-empty-state`) |
|
|
98
98
|
| Says a list is empty, in place of its rows | a paragraph or span of your own saying so | `estiva/no-handmade-empty-state` |
|
|
99
99
|
| Draws its one action, an outlined Button, under the line when you pass `action` | a button of your own under the line | |
|
|
100
100
|
|
|
@@ -52,6 +52,8 @@ const jsx = (body: string) => component(` return (\n${body}\n )`)
|
|
|
52
52
|
const scrolled = (imports: string, body: string) =>
|
|
53
53
|
`import { ScrollArea, EmptyState } from '@estiva-app/ui'\n${imports}\nexport function Probe({ rows }: { rows: string[] }) {\n return (\n${body}\n )\n}\n`
|
|
54
54
|
const handmade = [{ messageId: 'handmade' }]
|
|
55
|
+
/** A component that draws `body`, with the app's own EmptyState imported. */
|
|
56
|
+
const pageIn = (body: string) => `import { EmptyState } from '@/components/ui/EmptyState'\nexport function Probe() {\n return (\n${body}\n )\n}\n`
|
|
55
57
|
|
|
56
58
|
tester.run('no-handmade-empty-state', noHandmadeEmptyState, {
|
|
57
59
|
valid: [
|
|
@@ -100,6 +102,17 @@ tester.run('no-handmade-empty-state', noHandmadeEmptyState, {
|
|
|
100
102
|
{ name: 'a page state inside a ScrollArea whose content fills it', filename: app, code: scrolled('', '<ScrollArea className="flex-1" contentClassName="flex min-h-full flex-col">{rows.length === 0 && <EmptyState message="Nothing here yet." />}</ScrollArea>') },
|
|
101
103
|
{ name: 'a scope that is decided at run time is not judged', filename: app, code: scrolled('', '<ScrollArea className="flex-1"><EmptyState scope={rows.length ? "section" : "page"} message="Nothing here yet." /></ScrollArea>') },
|
|
102
104
|
{ name: "a component that hands its className to a section state (Ship's Activity), followed and fine", filename: app, code: scrolled("import { Activity } from '@/components/Activity'", '<ScrollArea className="flex-1" contentClassName="px-6"><section><Activity items={rows} /></section></ScrollArea>') },
|
|
105
|
+
|
|
106
|
+
// UIG-42: a box around a page state. The column it asks for, and a section's inset, pass.
|
|
107
|
+
{ name: 'a page state in the flex column it asks for (Peek FilePage.tsx:315)', filename: app, code: pageIn('<div className="flex min-h-screen flex-col"><EmptyState message="Nothing here." /></div>') },
|
|
108
|
+
{ name: "a section state in a box that gives it the rows' inset (Katerina, 14 September)", filename: app, code: pageIn('<div className="px-2 py-1"><EmptyState scope="section" message="Nothing starred." /></div>') },
|
|
109
|
+
{ name: 'a page state that is not alone in its padded box (Ship ProjectsView.tsx:30)', filename: app, code: pageIn('<div className="flex flex-1 flex-col gap-4 px-6 py-5"><h2>Projects</h2><EmptyState message="No projects yet." /></div>') },
|
|
110
|
+
{ name: "props spread in may carry the scope, so it is not judged (the package's EmptyState story)", filename: app, code: pageIn('<div className="p-4"><EmptyState {...({ scope: "section" } as const)} /></div>') },
|
|
111
|
+
{
|
|
112
|
+
name: 'a box kept with a reason',
|
|
113
|
+
filename: app,
|
|
114
|
+
code: pageIn('<>\n{/* @estiva-escape(no-handmade-empty-state): a probe that keeps its box */}\n<div className="p-4"><EmptyState /></div>\n</>'),
|
|
115
|
+
},
|
|
103
116
|
],
|
|
104
117
|
invalid: [
|
|
105
118
|
// the hand-made line, each way it stands in for a list
|
|
@@ -122,10 +135,19 @@ tester.run('no-handmade-empty-state', noHandmadeEmptyState, {
|
|
|
122
135
|
errors: [{ messageId: 'escapeWithoutReason' }, ...handmade],
|
|
123
136
|
},
|
|
124
137
|
|
|
138
|
+
// UIG-42: a box that places a page state. Peek's direct-message view, and the starter's home page before UIG-10's fix.
|
|
139
|
+
{ name: 'a box that centres a page state', filename: app, code: pageIn('<div className="flex-1 flex items-center justify-center h-full"><EmptyState /></div>'), errors: [{ messageId: 'boxedPage', data: { what: 'centres' } }] },
|
|
140
|
+
{
|
|
141
|
+
name: 'a box that centres and pads it, from the package',
|
|
142
|
+
filename: app,
|
|
143
|
+
code: "import { EmptyState } from '@estiva-app/ui'\nexport function Probe() {\n return (\n <main className=\"flex justify-center px-6 py-16\">\n <EmptyState message=\"Nothing here yet.\" />\n </main>\n )\n}\n",
|
|
144
|
+
errors: [{ messageId: 'boxedPage', data: { what: 'centres and pads' } }],
|
|
145
|
+
},
|
|
146
|
+
|
|
125
147
|
// the wrong scope
|
|
126
148
|
{ name: 'a page state straight inside a ScrollArea', filename: app, code: scrolled('', '<ScrollArea className="min-h-0 flex-1">{rows.length === 0 && <EmptyState message="Nothing here yet." />}</ScrollArea>'), errors: [{ messageId: 'wrongScope' }] },
|
|
127
149
|
{ name: 'scope="page" said out loud', filename: app, code: scrolled('', '<ScrollArea className="flex-1" contentClassName="flex flex-col gap-3 p-4"><EmptyState scope="page" message="Nothing here yet." /></ScrollArea>'), errors: [{ messageId: 'wrongScope' }] },
|
|
128
|
-
{ name: "through the app's wrapper, one box down", filename: app, code: "import { ScrollArea } from '@estiva-app/ui'\nimport { EmptyState } from '@/components/ui/EmptyState'\nexport function Probe() {\n return <ScrollArea className=\"flex-1\"><div className=\"p-4\"><EmptyState message=\"Nothing said about this yet.\" /></div></ScrollArea>\n}\n", errors: [{ messageId: 'wrongScope' }] },
|
|
150
|
+
{ name: "through the app's wrapper, one box down", filename: app, code: "import { ScrollArea } from '@estiva-app/ui'\nimport { EmptyState } from '@/components/ui/EmptyState'\nexport function Probe() {\n return <ScrollArea className=\"flex-1\"><div className=\"p-4\"><EmptyState message=\"Nothing said about this yet.\" /></div></ScrollArea>\n}\n", errors: [{ messageId: 'boxedPage', data: { what: 'pads' } }, { messageId: 'wrongScope' }] },
|
|
129
151
|
{
|
|
130
152
|
name: 'the file conversation at 7f22e5e~1: a view drawn in another file, scrolled here — both its states',
|
|
131
153
|
filename: app,
|
|
@@ -165,6 +165,16 @@ function standsInForAList(element: Node): boolean {
|
|
|
165
165
|
/** A content box that fills its viewport: `min-h-full` or `h-full` on `contentClassName`. */
|
|
166
166
|
const FILLS = /^(?:min-h-full|h-full)$/
|
|
167
167
|
|
|
168
|
+
/** What a box does that a page-scope EmptyState already does itself: centre, or leave room round it. */
|
|
169
|
+
const CENTRES = /^(?:justify-center|items-center|content-center|place-(?:items|content)-center)$/
|
|
170
|
+
const PADS = /^p[xytrblse]?-/
|
|
171
|
+
|
|
172
|
+
/** The only element a box holds, when it holds one and nothing else but blank space. */
|
|
173
|
+
function onlyElement(box: Node): Node | undefined {
|
|
174
|
+
const kids = children(box, 'children').filter((kid) => !(kid.type === 'JSXText' && !String(kid.value).trim()))
|
|
175
|
+
return kids.length === 1 && kids[0].type === 'JSXElement' ? kids[0] : undefined
|
|
176
|
+
}
|
|
177
|
+
|
|
168
178
|
function isPageScope(opening: Node): boolean {
|
|
169
179
|
const scope = attributeOf(opening, 'scope')
|
|
170
180
|
if (!scope) return true
|
|
@@ -265,6 +275,13 @@ const fileName = (file: string) => file.replace(/\\/g, '/').split('/').pop()
|
|
|
265
275
|
* file and scrolled in another. A `contentClassName` with `min-h-full` or
|
|
266
276
|
* `h-full` gives the state its room, and passes.
|
|
267
277
|
*
|
|
278
|
+
* **A box that places it** (UIG-42). A plain box holding only a page-scope
|
|
279
|
+
* `EmptyState` and centring or padding it does the part's own job, and a box
|
|
280
|
+
* like that pinned the starter's home page 64px from the top (UIG-10). A box
|
|
281
|
+
* that is only the flex column the state asks for passes, and so does any box
|
|
282
|
+
* round a `section` state, which takes its inset from the box (Katerina, 14
|
|
283
|
+
* September).
|
|
284
|
+
*
|
|
268
285
|
* Not judged: the package's `EmptyState` and a part's own lines (a
|
|
269
286
|
* `FieldLine`, a palette's empty row) — a part is already a part.
|
|
270
287
|
*/
|
|
@@ -278,6 +295,8 @@ export const noHandmadeEmptyState: Rule.RuleModule = {
|
|
|
278
295
|
'A line saying there is nothing is an EmptyState. Use `EmptyState` from @estiva-app/ui: `scope="section"` inside a section, `scope="page"` for a whole page.',
|
|
279
296
|
wrongScope:
|
|
280
297
|
'A page-scope EmptyState inside a ScrollArea sits at the top of its pane, not the middle: the ScrollArea\'s content is only as tall as what is in it. Use `scope="section"` when the pane has anything else on it; when the whole pane is empty, draw the page EmptyState in place of the ScrollArea, not inside it.',
|
|
298
|
+
boxedPage:
|
|
299
|
+
'This box {{what}} a page-scope EmptyState, which centres itself in the room a flex column gives it and takes no padding. A box that places it can push it out of the middle, as the starter\'s home page did (UIG-10). Draw the EmptyState straight into the column, with `className="h-full"` outside a flex column.',
|
|
281
300
|
wrongScopeVia:
|
|
282
301
|
'`{{component}}` draws a page-scope EmptyState ({{where}}) inside this ScrollArea, where it sits at the top of its pane, not the middle: the ScrollArea\'s content is only as tall as what is in it. Use `scope="section"` there when the pane has anything else on it; when the whole pane is empty, draw the page EmptyState in place of the ScrollArea, not inside it.',
|
|
283
302
|
...ESCAPE_MESSAGES,
|
|
@@ -300,8 +319,25 @@ export const noHandmadeEmptyState: Rule.RuleModule = {
|
|
|
300
319
|
const opening = child(element, 'openingElement') as Node
|
|
301
320
|
const tag = tagName(element)
|
|
302
321
|
|
|
303
|
-
// Shape 1: a plain box holding only a "nothing" line, where a list would be.
|
|
304
322
|
if (tag && /^[a-z]/.test(tag)) {
|
|
323
|
+
// Shape 3 (UIG-42): a plain box around a page-scope EmptyState that centres or pads it.
|
|
324
|
+
const only = facts && onlyElement(element)
|
|
325
|
+
const inner = only && (child(only, 'openingElement') as Node)
|
|
326
|
+
// Props spread in (`{...args}`) may carry the scope, so it is not judged.
|
|
327
|
+
const spread = inner && children(inner, 'attributes').some((a) => a.type === 'JSXSpreadAttribute')
|
|
328
|
+
if (inner && !spread && isPart(bindingOfTag(child(inner, 'name'), facts!.locals), 'EmptyState') && isPageScope(inner)) {
|
|
329
|
+
const className = attributeOf(opening, 'className')
|
|
330
|
+
const own = className ? classesOf(child(className, 'value'), scopeOf).map((c) => c.replace(/^(?:[^:\s[\]]+:)+/, '')) : []
|
|
331
|
+
const centres = own.some((c) => CENTRES.test(c))
|
|
332
|
+
const pads = own.some((c) => PADS.test(c))
|
|
333
|
+
if ((centres || pads) && !isEscaped(context, opening)) {
|
|
334
|
+
const what = centres && pads ? 'centres and pads' : centres ? 'centres' : 'pads'
|
|
335
|
+
context.report({ loc: opening.loc as NonNullable<Rule.Node['loc']>, messageId: 'boxedPage', data: { what } })
|
|
336
|
+
}
|
|
337
|
+
return
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Shape 1: a plain box holding only a "nothing" line, where a list would be.
|
|
305
341
|
const words = onlyWords(element)
|
|
306
342
|
if (!words || words.length > SHORT) return
|
|
307
343
|
if (!standsInForAList(element)) return
|
package/src/gates/app-checks.ts
CHANGED
|
@@ -57,6 +57,7 @@ export const APP_TICKET_TITLES: Record<string, string> = {
|
|
|
57
57
|
'UIG-30': 'RichText — one component that draws a message\'s text, for both apps',
|
|
58
58
|
'UIG-32': 'Peek and Ship take their gate pieces from the package',
|
|
59
59
|
'UIG-37': 'The gates refuse a TypeScript eslint-disable comment — know the rule names, rules off',
|
|
60
|
+
'UIG-42': "What the gate can't see yet — a box around a part, a screen drawn by hand, two blind spots in the token check",
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/** Run several checks as one: the first that does not pass is the answer. */
|
|
@@ -254,6 +255,12 @@ export function appChecks(h: GateHelpers, { app = '.', page, chain = { ref: 'UIG
|
|
|
254
255
|
return probe(code, 'none', undefined, 'src/components/__gates_probe__.test.tsx', config)()
|
|
255
256
|
}), 'a test file is not checked for hand-written values, while source is') },
|
|
256
257
|
]),
|
|
258
|
+
// Built 28 September: the token check's two blind spots, and a box that places a page EmptyState.
|
|
259
|
+
ticket('UIG-42', [
|
|
260
|
+
{ what: 'a class behind an arbitrary variant is an error', run: tokenProbe(component('<div className="group-hover/row:bg-gray-100">x</div>'), 'error') },
|
|
261
|
+
{ what: 'a class list joined by hand is read', run: tokenProbe(component("<div className={['text-sm', 'p-2'].join(' ')}>x</div>"), 'error') },
|
|
262
|
+
{ what: 'a box that centres a page EmptyState is an error naming it', run: probe(`import { EmptyState } from '@estiva-app/ui'\n${component('<div className="flex items-center justify-center"><EmptyState message="Nothing here" /></div>')}`, 'error', 'page-scope EmptyState') },
|
|
263
|
+
]),
|
|
257
264
|
// Built 28 September: both apps drew the protocol's text tree by hand, and drifted apart.
|
|
258
265
|
// A file that reads the protocol and draws a quote or a numbered list itself is a third copy.
|
|
259
266
|
ticket('UIG-30', [
|
package/src/gates/gate-config.ts
CHANGED
|
@@ -21,6 +21,7 @@ import betterTailwindcss from 'eslint-plugin-better-tailwindcss'
|
|
|
21
21
|
import { parser as typescriptParser } from 'typescript-eslint'
|
|
22
22
|
import estiva from '../eslint/index'
|
|
23
23
|
import { KNOWN_PLUGINS, TOKEN_LINT_IGNORES } from './token-lint'
|
|
24
|
+
import { tokenJoinedPlugin } from './token-joined'
|
|
24
25
|
import { tokenStylePlugin } from './token-style'
|
|
25
26
|
|
|
26
27
|
export interface GateConfigOptions {
|
|
@@ -72,6 +73,7 @@ export function gateConfig({ audience = 'app', quiet = {}, ignores = [] }: GateC
|
|
|
72
73
|
'token-values': betterTailwindcss,
|
|
73
74
|
'token-spacing': betterTailwindcss,
|
|
74
75
|
'token-style': tokenStylePlugin,
|
|
76
|
+
'token-joined': tokenJoinedPlugin,
|
|
75
77
|
},
|
|
76
78
|
// Every other config's directives are unused here, because their rules are
|
|
77
79
|
// off here. Reporting them would be this config complaining about the
|
package/src/gates/gates.test.ts
CHANGED
|
@@ -91,6 +91,32 @@ describe('tokenLint and tokenValues', () => {
|
|
|
91
91
|
expect(await lintWith(gateConfig(), `// eslint-disable-next-line token-style/no-token-style -- @estiva-escape: a colour the probe keeps\n${kept}`, 'src/Probe.tsx')).toEqual([])
|
|
92
92
|
})
|
|
93
93
|
|
|
94
|
+
it('read a class behind an arbitrary variant or a `!` (UIG-42)', async () => {
|
|
95
|
+
for (const name of ['[&_pre]:text-sm', 'group-hover/row:bg-gray-100', 'data-[state=open]:bg-[#fff]', 'group-hover/row:bg-bg-surface/50', '!text-sm']) {
|
|
96
|
+
const messages = await lintWith([tokenLint(), tokenValues()], component(`<div className="${name}">x</div>`), 'src/Probe.tsx')
|
|
97
|
+
expect(messages.filter((m) => m.ruleId === 'better-tailwindcss/no-restricted-classes'), name).toEqual([expect.objectContaining({ severity: 2 })])
|
|
98
|
+
}
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('read a class list joined by hand, with the same messages and levels (UIG-42)', async () => {
|
|
102
|
+
const code = `import { cn } from '@estiva-app/ui'\nconst look = ['text-sm', open ? 'rounded-[3px]' : '', \`h-[240px] \${size}\`].filter(Boolean).join(' ')\n${component("<div className={cn(look, ['bg-gray-100'].join(' '))}>x</div>")}`
|
|
103
|
+
const messages = (await lintWith([tokenLint(), tokenValues()], code, 'src/Probe.tsx')).filter((m) => m.ruleId?.startsWith('token-joined/'))
|
|
104
|
+
expect(messages.map((m) => [m.ruleId, m.severity, m.line])).toEqual([
|
|
105
|
+
['token-joined/classes', 2, 2],
|
|
106
|
+
['token-joined/values', 2, 2],
|
|
107
|
+
['token-joined/spacing', 1, 2],
|
|
108
|
+
['token-joined/classes', 2, 4],
|
|
109
|
+
])
|
|
110
|
+
expect(messages[0].message).toContain("Tailwind's type ramp")
|
|
111
|
+
expect(messages[1].message).toContain('rounded-[3px] is a corner written by hand')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
it('leave a sentence joined with spaces, and a list joined with anything else', async () => {
|
|
115
|
+
// Peek's prompt hint (src/lib/promptApi.ts) is built this way.
|
|
116
|
+
const code = "export const hint = ['Reply with only a JSON object, no prose and no code fence.', `It must have exactly these keys: ${keys}.`].join(' ')\nexport const keys = ['text-sm', 'bg-gray-100'].join(', ')\n"
|
|
117
|
+
expect(await lintWith([tokenLint(), tokenValues()], code, 'src/lib/probe.ts')).toEqual([])
|
|
118
|
+
})
|
|
119
|
+
|
|
94
120
|
it('leave a test file to its test', async () => {
|
|
95
121
|
const messages = await lintWith([tokenLint(), tokenValues()], component('<div style={{ color: "red" }}>x</div>'), 'src/Probe.test.tsx')
|
|
96
122
|
expect(messages.filter((m) => m.severity === 2)).toEqual([])
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The token contract, read inside a class list joined by hand (UIG-42):
|
|
3
|
+
*
|
|
4
|
+
* <div className={['text-sm', open && 'bg-gray-100'].join(' ')} />
|
|
5
|
+
*
|
|
6
|
+
* The Tailwind plugin stops at a function call, so it never reads the list in
|
|
7
|
+
* front of `.join(' ')`, and no setting can make it: a call it is told about is
|
|
8
|
+
* read at its arguments, which here is the `' '`. This rule reads the list and
|
|
9
|
+
* tests each class against the same patterns, with the same messages, as the
|
|
10
|
+
* rule it stands in for. It registers once per rule it mirrors, so an error
|
|
11
|
+
* stays an error and a warning a warning (`token-joined/classes`, `/values`,
|
|
12
|
+
* `/spacing`).
|
|
13
|
+
*
|
|
14
|
+
* A list joined with anything but one space is not a class list, and a
|
|
15
|
+
* sentence built this way passes unless one of its words is itself such a
|
|
16
|
+
* class, as in `'set text-sm here'`. Only strings written in the list are
|
|
17
|
+
* read, directly or behind `cond && …`, `a ? … : …` and a template's fixed
|
|
18
|
+
* parts; a list worked out while it runs cannot be read.
|
|
19
|
+
*/
|
|
20
|
+
import type { ESLint, Rule } from 'eslint'
|
|
21
|
+
|
|
22
|
+
/** One pattern and its message, the shape `no-restricted-classes` takes. `$0` is the class. */
|
|
23
|
+
export interface Restriction {
|
|
24
|
+
pattern: string
|
|
25
|
+
message: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Node {
|
|
29
|
+
type: string
|
|
30
|
+
[key: string]: unknown
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const isOneSpace = (node: Node | undefined) => node?.type === 'Literal' && node.value === ' '
|
|
34
|
+
|
|
35
|
+
/** `.join` on a list, through any `.filter(…)` between them. */
|
|
36
|
+
function joinedList(call: Node): Node | undefined {
|
|
37
|
+
const callee = call.callee as Node
|
|
38
|
+
if (callee.type !== 'MemberExpression' || callee.computed || (callee.property as Node).name !== 'join') return undefined
|
|
39
|
+
if ((call.arguments as Node[]).length !== 1 || !isOneSpace((call.arguments as Node[])[0])) return undefined
|
|
40
|
+
let list = callee.object as Node
|
|
41
|
+
while (list.type === 'CallExpression' && (list.callee as Node).type === 'MemberExpression' && ((list.callee as Node).property as Node).name === 'filter') {
|
|
42
|
+
list = (list.callee as Node).object as Node
|
|
43
|
+
}
|
|
44
|
+
return list.type === 'ArrayExpression' ? list : undefined
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The strings written in one item of the list, each with the node an escape sits above. */
|
|
48
|
+
function stringsIn(node: Node | null, out: { node: Node; text: string }[] = []) {
|
|
49
|
+
if (!node) return out
|
|
50
|
+
if (node.type === 'Literal' && typeof node.value === 'string') out.push({ node, text: node.value })
|
|
51
|
+
else if (node.type === 'TemplateLiteral') for (const quasi of node.quasis as Node[]) out.push({ node: quasi, text: String((quasi.value as { cooked: string }).cooked ?? '') })
|
|
52
|
+
else if (node.type === 'ConditionalExpression') stringsIn(node.consequent as Node, out), stringsIn(node.alternate as Node, out)
|
|
53
|
+
else if (node.type === 'LogicalExpression') {
|
|
54
|
+
if (node.operator !== '&&') stringsIn(node.left as Node, out)
|
|
55
|
+
stringsIn(node.right as Node, out)
|
|
56
|
+
} else if (node.type === 'TSAsExpression' || node.type === 'TSSatisfiesExpression') stringsIn(node.expression as Node, out)
|
|
57
|
+
return out
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const joinedListRule: Rule.RuleModule = {
|
|
61
|
+
meta: {
|
|
62
|
+
type: 'problem',
|
|
63
|
+
docs: { description: 'The token contract, inside a class list joined with .join(" ")' },
|
|
64
|
+
schema: [
|
|
65
|
+
{
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: { restrict: { type: 'array', items: { type: 'object', properties: { pattern: { type: 'string' }, message: { type: 'string' } }, required: ['pattern', 'message'] } } },
|
|
68
|
+
required: ['restrict'],
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
create(context) {
|
|
74
|
+
const { restrict } = context.options[0] as { restrict: Restriction[] }
|
|
75
|
+
const rules = restrict.map(({ pattern, message }) => ({ pattern: new RegExp(pattern), message }))
|
|
76
|
+
return {
|
|
77
|
+
CallExpression(ruleNode: Rule.Node) {
|
|
78
|
+
const list = joinedList(ruleNode as unknown as Node)
|
|
79
|
+
if (!list) return
|
|
80
|
+
for (const item of list.elements as (Node | null)[]) {
|
|
81
|
+
for (const { node, text } of stringsIn(item)) {
|
|
82
|
+
for (const name of text.split(/\s+/)) {
|
|
83
|
+
const rule = name && rules.find(({ pattern }) => pattern.test(name))
|
|
84
|
+
if (rule) context.report({ node: node as unknown as Rule.Node, message: rule.message.replaceAll('$0', name) })
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** The plugin, as the token lint registers it: one rule, under three names. */
|
|
94
|
+
export const tokenJoinedPlugin: ESLint.Plugin = { rules: { classes: joinedListRule, values: joinedListRule, spacing: joinedListRule } }
|