@multiplatform.one/config 9.16.1 → 10.0.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.
Files changed (52) hide show
  1. package/design-lint.mjs +29 -6
  2. package/lib/index.js +4 -4
  3. package/lib/{storybook-BpaziEtP.js → storybook-BRZwQLAM.js} +150 -9
  4. package/lib/storybook.js +1 -1
  5. package/lib/{tamaguiWorkspacePaths-DR3dud79.js → tamaguiWorkspacePaths-BFMQNk1l.js} +8 -5
  6. package/lib/{vite-CgiDLR6V.js → vite-DaBjbGS0.js} +40 -52
  7. package/lib/vite.js +4 -4
  8. package/lib/{vitest-B2vcGrZM.js → vitest-NTT7k5jB.js} +97 -10
  9. package/lib/vitest.js +2 -2
  10. package/lib/{workspacePublicPackages-DN-1LPcH.js → workspacePublicPackages-z0fVhgGN.js} +121 -8
  11. package/lint.mjs +874 -52
  12. package/oxlint.mjs +26 -1
  13. package/package.json +6 -6
  14. package/press-lint.mjs +86 -5
  15. package/spec-registry.mjs +15 -0
  16. package/src/lint.spec.ts +696 -12
  17. package/src/movedDepAliases.spec.ts +73 -0
  18. package/src/movedDepAliases.ts +91 -0
  19. package/src/nativeBlockScoping.spec.ts +12 -14
  20. package/src/nativeOnlyDepStubs.spec.ts +178 -0
  21. package/src/nativeOnlyDepStubs.ts +215 -0
  22. package/src/noVoicelessText.rule.spec.ts +1 -1
  23. package/src/noVoicelessText.spec.ts +1 -1
  24. package/src/oxlint.spec.ts +5 -5
  25. package/src/phosphorNativeInk.spec.ts +17 -18
  26. package/src/phosphorTokenColor.spec.ts +35 -0
  27. package/src/phosphorTokenColor.ts +8 -5
  28. package/src/press-lint.spec.ts +64 -3
  29. package/src/react-native.config.cjs +9 -0
  30. package/src/shims/phosphorThemeInk.js +6 -1
  31. package/src/shims/svgTouchSound.web.js +23 -0
  32. package/src/singletonDepAliases.spec.ts +99 -14
  33. package/src/singletonDepAliases.ts +102 -7
  34. package/src/storybook.spec.ts +0 -3
  35. package/src/storybook.ts +17 -6
  36. package/src/vite.nativeEntries.spec.ts +21 -20
  37. package/src/vite.spec.ts +11 -20
  38. package/src/vite.ts +44 -68
  39. package/src/vitest.spec.ts +142 -4
  40. package/src/vitest.ts +106 -8
  41. package/types/movedDepAliases.d.ts +8 -0
  42. package/types/movedDepAliases.d.ts.map +1 -0
  43. package/types/nativeOnlyDepStubs.d.ts +41 -0
  44. package/types/nativeOnlyDepStubs.d.ts.map +1 -0
  45. package/types/phosphorTokenColor.d.ts.map +1 -1
  46. package/types/singletonDepAliases.d.ts +55 -3
  47. package/types/singletonDepAliases.d.ts.map +1 -1
  48. package/types/storybook.d.ts.map +1 -1
  49. package/types/vite.d.ts +10 -1
  50. package/types/vite.d.ts.map +1 -1
  51. package/types/vitest.d.ts +46 -1
  52. package/types/vitest.d.ts.map +1 -1
package/lint.mjs CHANGED
@@ -101,7 +101,7 @@ import { createRequire } from "node:module";
101
101
  import { dirname, join, relative } from "node:path";
102
102
  import { pathToFileURL } from "node:url";
103
103
  import { DRAWING_PRAGMA, isDrawingFile, readDrawingRegistry } from "./drawing-registry.mjs";
104
- import { findHexEscapes } from "./oxlint.mjs";
104
+ import { findHexEscapes, findPseudoPropEscapes } from "./oxlint.mjs";
105
105
  import { findTitleCaseEscapes } from "./design-lint.mjs";
106
106
  import {
107
107
  exportedPressClaimants,
@@ -110,6 +110,7 @@ import {
110
110
  } from "./press-lint.mjs";
111
111
  import {
112
112
  readHexEscapeRegistry,
113
+ readPseudoPropEscapeRegistry,
113
114
  readSizeRecipeEscapeRegistry,
114
115
  readTitleCaseEscapeRegistry,
115
116
  } from "./spec-registry.mjs";
@@ -427,19 +428,15 @@ function checkTransitionTokens() {
427
428
  }
428
429
 
429
430
  function readThemeMatrix() {
430
- const builder = tryRequire("@tamagui/theme-builder");
431
- const v5 = tryRequire("@tamagui/themes/v5");
431
+ const builder = tryRequire("@tamagui/themes/builder");
432
432
  const src = readPublicSource("theme/src/theme/createThemes.ts");
433
- if (!builder?.createThemes || !v5?.defaultChildrenThemes || !src) return {};
433
+ if (!builder?.createThemes || !src) return {};
434
434
  const childrenHues = src.match(/const childrenHues = \[([^\]]+)\]/)?.[1];
435
435
  if (!childrenHues) return {};
436
- const palette = { palette: { dark: v5.defaultDarkPalette, light: v5.defaultLightPalette } };
437
- const childrenThemes = Object.fromEntries(
438
- [...childrenHues.matchAll(/"([a-z]+)"/g)].map(([, name]) => [name, palette]),
439
- );
440
- for (const key of keysOfBlock(sliceBlock(src, "const childrenThemes =", "\n };"), 4)) {
441
- childrenThemes[key] = palette;
442
- }
436
+ const children = [
437
+ ...[...childrenHues.matchAll(/"([a-z]+)"/g)].map(([, name]) => name),
438
+ ...keysOfBlock(sliceBlock(src, "const childrenThemes =", "\n }"), 4),
439
+ ];
443
440
  const templatesOf = (name) =>
444
441
  Object.fromEntries(
445
442
  [
@@ -448,15 +445,25 @@ function readThemeMatrix() {
448
445
  ),
449
446
  ].map((match) => [match[1], { template: match[2] }]),
450
447
  );
448
+ const states = templatesOf("houseGrandChildrenThemes");
449
+ const components = templatesOf("houseComponentThemes");
451
450
  try {
452
- return builder.createThemes({
453
- templates: v5.v5Templates,
454
- componentThemes: templatesOf("houseComponentThemes"),
455
- grandChildrenThemes: templatesOf("houseGrandChildrenThemes"),
456
- base: palette,
457
- childrenThemes,
458
- accent: palette,
459
- });
451
+ return builder.createThemes(
452
+ { color: {} },
453
+ {
454
+ light: { scheme: "light" },
455
+ dark: { scheme: "dark" },
456
+ children: {
457
+ accent: { children: components },
458
+ ...Object.fromEntries(
459
+ children.map((name) => [name, { children: { ...states, ...components } }]),
460
+ ),
461
+ ...states,
462
+ ...components,
463
+ },
464
+ },
465
+ { getTheme: () => ({}) },
466
+ );
460
467
  } catch {
461
468
  return {};
462
469
  }
@@ -468,33 +475,50 @@ function readThemeNames() {
468
475
  return new Set(names.flatMap((name) => [name, ...name.split("_").slice(1)]));
469
476
  }
470
477
 
478
+ function kebabThemeKey(key) {
479
+ return key
480
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
481
+ .replace(/([A-Za-z])(\d)/g, "$1-$2")
482
+ .toLowerCase();
483
+ }
484
+
471
485
  export function readThemeKeys() {
472
486
  /** @type {Set<string>} */
473
487
  const keys = new Set();
474
- const v5 = tryRequire("@tamagui/themes/v5");
488
+ const colors = tryRequire("@tamagui/colors");
475
489
  const src = readPublicSource("theme/src/theme/createThemes.ts");
476
490
  const builderSrc = readPublicSource("theme/src/theme/defaults/builderOptions.ts");
477
- const matrix = readThemeMatrix();
478
- if (!Object.keys(matrix).length || !v5?.defaultChildrenThemes || !builderSrc) return keys;
479
- for (const theme of Object.values(matrix)) {
480
- for (const key of Object.keys(theme)) keys.add(key);
491
+ const templatesSrc = readPublicSource("theme/src/theme/v5Templates.ts");
492
+ const rampsSrc = readPublicSource("theme/src/theme/ramps.ts");
493
+ const palettesSrc = readPublicSource("theme/src/theme/v5Palettes.ts");
494
+ if (!colors || !src || !builderSrc || !templatesSrc || !rampsSrc || !palettesSrc) return keys;
495
+ for (const k of keysOfBlock(sliceBlock(templatesSrc, "const makeSurface", "\n };"), 6)) {
496
+ keys.add(k);
481
497
  }
482
- for (const theme of Object.values(v5.defaultChildrenThemes)) {
483
- for (const scheme of ["light", "dark"]) {
484
- for (const key of Object.keys(theme[scheme])) keys.add(key);
485
- }
498
+ for (const k of keysOfBlock(sliceBlock(templatesSrc, "const base = {", "\n };"), 4)) {
499
+ keys.add(k);
500
+ const step = k.match(/^color-([1-9]\d*)$/)?.[1];
501
+ if (step) keys.add(`accent-${step}`);
502
+ }
503
+ const rampHues = rampsSrc.match(/export const themeRampHues = \[([^\]]+)\]/)?.[1] ?? "";
504
+ for (const [, hue] of rampHues.matchAll(/"([a-z]+)"/g)) {
505
+ for (const key of Object.keys(colors[hue] ?? {})) keys.add(kebabThemeKey(key));
506
+ }
507
+ const neutral = palettesSrc.match(/export const neutralPalette = \[([^\]]+)\]/)?.[1] ?? "";
508
+ [...neutral.matchAll(/"[^"]*"/g)].forEach((_, index) => keys.add(`neutral-${index + 1}`));
509
+ for (const k of keysOfBlock(sliceBlock(src, "export interface Shadows", "\n}"), 2)) {
510
+ keys.add(kebabThemeKey(k));
486
511
  }
487
- for (const k of keysOfBlock(sliceBlock(src, "export interface Shadows", "\n}"), 2)) keys.add(k);
488
- keys.add("shadowColor");
512
+ keys.add("shadow-color");
489
513
  const syntaxHues = src.match(/const syntaxInkHues = \[([^\]]+)\]/)?.[1] ?? "";
490
514
  for (const [, hue] of syntaxHues.matchAll(/"([a-z]+)"/g)) {
491
- keys.add(`syntax${hue[0].toUpperCase()}${hue.slice(1)}`);
515
+ keys.add(`syntax-${hue}`);
492
516
  }
493
517
  for (const hue of keysOfBlock(sliceBlock(src, "const radixHues =", "} as const"), 2)) {
494
- for (let step = 1; step <= 12; step++) keys.add(`${hue}${step}`);
518
+ for (let step = 1; step <= 12; step++) keys.add(`${hue}-${step}`);
495
519
  }
496
520
  const postPass = src.match(/export const postPassThemeKeys = \[([^\]]+)\]/)?.[1] ?? "";
497
- for (const [, key] of postPass.matchAll(/"([A-Za-z0-9]+)"/g)) keys.add(key);
521
+ for (const [, key] of postPass.matchAll(/"([A-Za-z0-9-]+)"/g)) keys.add(key);
498
522
  for (const k of keysOfBlock(sliceBlock(builderSrc, "function getBaseTheme", "\n}"), 4))
499
523
  keys.add(k);
500
524
  return keys;
@@ -542,7 +566,7 @@ function readFontSizeSteps() {
542
566
  */
543
567
  function checkStyleTokens() {
544
568
  const helpers = tryRequire("@tamagui/helpers");
545
- const themesPkg = tryRequire("@tamagui/themes");
569
+ const themesPkg = tryRequire("@tamagui/themes/v5") ?? tryRequire("@tamagui/themes");
546
570
  const shorthandsPkg = tryRequire("@tamagui/shorthands");
547
571
  const themeKeys = readThemeKeys();
548
572
  const fontSizeSteps = readFontSizeSteps();
@@ -574,22 +598,54 @@ function checkStyleTokens() {
574
598
  }
575
599
  byProp.set("fontSize", new Set([...themeKeys, ...fontSizeSteps]));
576
600
  // Shorthands are the same prop by another name (`bg`, `br`, `fos`, …).
601
+ const colorProps = new Set(Object.keys(helpers.tokenCategories.color ?? {}));
577
602
  for (const [short, long] of Object.entries(shorthandsPkg?.shorthands ?? {})) {
578
603
  const resolvable = byProp.get(long);
579
604
  if (resolvable) byProp.set(short, resolvable);
605
+ if (colorProps.has(long)) colorProps.add(short);
580
606
  }
581
607
  const props = [...byProp.keys()].sort((a, b) => b.length - a.length).join("|");
582
- const re = new RegExp(
583
- `\\b(${props})=(?:"\\$([A-Za-z0-9]+)"|\\{\\s*"\\$([A-Za-z0-9]+)"\\s*\\})`,
584
- "g",
585
- );
608
+ const re = new RegExp(`(?<![\\w-])(${props})=(?:"([^"\\n]*)"|\\{\\s*"([^"\\n]*)"\\s*\\})`, "g");
586
609
  const violations = scanLiterals(re, (m) => {
587
- const token = m[2] ?? m[3];
588
- return byProp.get(m[1])?.has(token) ? undefined : `${m[1]}="$${token}"`;
610
+ const value = m[2] ?? m[3];
611
+ const resolvable = byProp.get(m[1]) ?? new Set();
612
+ return unresolvedStyleWords(value, resolvable, colorProps.has(m[1])).length
613
+ ? `${m[1]}="${value}"`
614
+ : undefined;
589
615
  });
590
616
  return { violations, ok: true };
591
617
  }
592
618
 
619
+ const flatModifierChain = /^(?:[@A-Za-z][\w/@-]*:)+/;
620
+ const themeKeyShape = /^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)+|[a-z]+\d+|[a-z]+[A-Z][A-Za-z0-9]*)$/;
621
+
622
+ /**
623
+ * The words of a style value that name a token or theme key nothing defines.
624
+ * A value is a v2 `$token` or a v3 flat value: an optional base and
625
+ * `modifier:payload` clauses, space separated. A `$` word anywhere must
626
+ * resolve. A bare word is checked only on a colour prop and only when it is
627
+ * shaped like a theme key (kebab, a ramp step, camelCase), because a bare miss
628
+ * on purpose is literal CSS (`transparent`, `red`, `currentColor`).
629
+ * @param {string} value
630
+ * @param {Set<string>} resolvable
631
+ * @param {boolean} isColor
632
+ */
633
+ function unresolvedStyleWords(value, resolvable, isColor) {
634
+ const known = (name) => {
635
+ const dot = name.indexOf(".");
636
+ return resolvable.has(name) || (dot > 0 && resolvable.has(name.slice(dot + 1)));
637
+ };
638
+ return value
639
+ .split(/\s+/)
640
+ .map((word) => word.replace(flatModifierChain, ""))
641
+ .filter((word) => {
642
+ if (word.startsWith("$")) return /^\$[A-Za-z0-9.-]+$/.test(word) && !known(word.slice(1));
643
+ if (!isColor || word === "currentColor") return false;
644
+ const name = word.replace(/^[a-z]+\./, "");
645
+ return themeKeyShape.test(name) && !known(word);
646
+ });
647
+ }
648
+
593
649
  /** Flag `theme="literal"` naming a theme that was never built. */
594
650
  function checkThemeNames() {
595
651
  const valid = readThemeNames();
@@ -599,6 +655,14 @@ function checkThemeNames() {
599
655
  const name = m[1] ?? m[2];
600
656
  return valid.has(name) ? undefined : `theme="${name}"`;
601
657
  });
658
+ const themeTag =
659
+ /<Theme\b(?:\s(?:=>|[^>])*?)?\sname=(?:"([A-Za-z][A-Za-z0-9_]*)"|\{\s*"([A-Za-z][A-Za-z0-9_]*)"\s*\})/g;
660
+ violations.push(
661
+ ...scanLiterals(themeTag, (m) => {
662
+ const name = m[1] ?? m[2];
663
+ return valid.has(name) ? undefined : `<Theme name="${name}">`;
664
+ }),
665
+ );
602
666
  return { violations, ok: true };
603
667
  }
604
668
 
@@ -694,7 +758,11 @@ function checkAnimationProps() {
694
758
  // truncates the tag and hides everything after it from this check.
695
759
  for (const tag of src.matchAll(/<[A-Z][\w.]*(?:\s(?:=>|[^>])*)?>/gs)) {
696
760
  const t = tag[0];
697
- if (!/\b(enterStyle|exitStyle)=/.test(t)) continue;
761
+ if (
762
+ !/\b(enterStyle|exitStyle)=/.test(t) &&
763
+ !/=\s*\{?\s*["'][^"'\n]*?(?<![\w/-])(?:enter|exit):(?![\s"'])/.test(t)
764
+ )
765
+ continue;
698
766
  if (/\btransition(?:[=:]|Props\()/.test(t)) continue;
699
767
  const line = src.slice(0, tag.index).split("\n").length;
700
768
  driverless.push(`${rel}:${line} — enter/exitStyle with no \`transition\` driver (LC-24)`);
@@ -2465,11 +2533,328 @@ function checkOneTabBar() {
2465
2533
  * @param {RunConventionChecksOptions} [options]
2466
2534
  * @returns {number} 0 when clean, 1 when any check failed
2467
2535
  */
2536
+ // ── Non-style props in a styled() variant value (LC-303) ─
2537
+
2538
+ /** Ratchet for LC-303: sites not yet moved, per file. */
2539
+ const VARIANT_ATTR_BASELINES = "docs/variant-attr-baselines.json";
2540
+
2541
+ /**
2542
+ * The attributes a variant value drops, each one measured twice: it reaches
2543
+ * the DOM from the `styled()` options object AND from the call site, and is
2544
+ * absent when the identical key sits in a variant value. The value says which
2545
+ * target the pair was measured on, because that is where moving it pays:
2546
+ *
2547
+ * styled(View, { role: "button", tabIndex: 0 }) -> role="button" tabindex="0"
2548
+ * styled(View, { variants: { x: { true: { role: "button" } } } }) -> no attribute
2549
+ *
2550
+ * Keys NOT in this map on purpose, each one a false positive the first draft
2551
+ * produced:
2552
+ * - `className` and every hyphenated key (`data-*`, `aria-*`) survive a
2553
+ * variant value on web, which is what `radiusClassProps` rides
2554
+ * (`{ "data-radius-class": … }` as a variant value in DotIndicator).
2555
+ * - `disabled`, `autoFocus` and `focusable` are absent from the options
2556
+ * object and from the call site alike — Tamagui consumes them as
2557
+ * behaviour — so a move fixes nothing and flagging one sends a lane after
2558
+ * an attribute that was never going to render.
2559
+ * - `numberOfLines` and `nativeID` reach no DOM attribute on either target.
2560
+ * Extend the map only with a key whose pair has been rendered both ways.
2561
+ *
2562
+ * `title`, `type`, `placeholder`, `href` and `scope` are in the map although
2563
+ * `StyledOptions` refuses them on a View base: they are written there with a
2564
+ * cast, as `HeaderCell`'s `...({ scope: "col" } as { scope?: string })` is,
2565
+ * and they land. The type is no gate for any of them on the path that matters
2566
+ * either — the one live site in this repo declares a plain `const` and only
2567
+ * later hands it to a variant, so nothing is ever checked against the style
2568
+ * type and no cast was needed to write it.
2569
+ */
2570
+ const VARIANT_DROPPED_ATTRS = new Map([
2571
+ ["tabIndex", "web"],
2572
+ ["role", "web"],
2573
+ ["name", "web"],
2574
+ ["id", "web"],
2575
+ ["title", "web"],
2576
+ ["type", "web"],
2577
+ ["htmlFor", "web"],
2578
+ ["placeholder", "web"],
2579
+ ["href", "web"],
2580
+ ["scope", "web"],
2581
+ ["testID", "web and native"],
2582
+ ["accessibilityLabel", "native"],
2583
+ ["accessibilityRole", "native"],
2584
+ ]);
2585
+
2586
+ /**
2587
+ * Files worth parsing: any `styled(` call. The first draft also required a
2588
+ * `variants` key, which was right for the variant-value half and wrong for the
2589
+ * bag half — a context-less options object with no variants at all is the
2590
+ * shape the compiler flattens most readily, and Alert sailed through the
2591
+ * filter while carrying exactly it.
2592
+ */
2593
+ const VARIANT_ATTR_CANDIDATE_RE = /\bstyled\s*\(/;
2594
+
2595
+ /**
2596
+ * The keys whose whole job is the element's semantics, so losing one is an
2597
+ * accessibility defect rather than a cosmetic one. These are the keys the
2598
+ * check also refuses in a `styled()` OPTIONS OBJECT that has no `context`,
2599
+ * because the compiler drops a context-less bag's non-style keys from any
2600
+ * usage it can flatten. The rest of `VARIANT_DROPPED_ATTRS` is deliberately
2601
+ * absent here: `name` in an options object is Tamagui's component-name option
2602
+ * and `className` is how a house marker class is set, both correct uses that a
2603
+ * bag-level sweep of the whole vocabulary would flag 44 times over.
2604
+ */
2605
+ const BAG_HAZARD_ATTRS = new Set(["role", "tabIndex", "accessibilityRole", "accessibilityLabel"]);
2606
+
2607
+ /**
2608
+ * react-gnome renders GTK widgets. A `role` or `render` in a styled() bag
2609
+ * under one of these paths is read by the gnome shim and reaches no DOM and no
2610
+ * native view, so neither half of the rule applies to it.
2611
+ */
2612
+ const VARIANT_ATTR_GNOME_RE = /(^|\/)gnome\//;
2613
+
2614
+ /**
2615
+ * A spec or story is where the dead form has to be written: the render that
2616
+ * proves a variant value drops the attribute must put one there, and so must
2617
+ * the gate's own witness. Neither ships.
2618
+ */
2619
+ const VARIANT_ATTR_EXEMPT_RE = /\.(spec|test|stories)\.[jt]sx?$/;
2620
+
2621
+ /**
2622
+ * Every `VARIANT_DROPPED_ATTRS` key written inside a `styled()` variant value,
2623
+ * by AST rather than by brace depth: a variant value holds nested objects, a
2624
+ * props object two lines above looks identical to a regex, and the one live
2625
+ * site in this repo reaches its variant through a named constant. Resolved one
2626
+ * hop: an object literal, a spread of an object literal, either branch of a
2627
+ * spread conditional, and a module-local `const` naming one.
2628
+ *
2629
+ * @param {any} ts
2630
+ * @param {string} src
2631
+ * @param {string} filePath
2632
+ * @returns {{ line: number, key: string, where: string }[]}
2633
+ */
2634
+ function styledVariantAttrSites(ts, src, filePath) {
2635
+ const sites = [];
2636
+ const sf = ts.createSourceFile(filePath, src, ts.ScriptTarget.Latest, true, ts.ScriptKind.TSX);
2637
+ const lineOf = (pos) => sf.getLineAndCharacterOfPosition(pos).line + 1;
2638
+ const unwrap = (node) => {
2639
+ let n = node;
2640
+ while (
2641
+ n &&
2642
+ (ts.isParenthesizedExpression(n) ||
2643
+ ts.isAsExpression(n) ||
2644
+ ts.isSatisfiesExpression(n) ||
2645
+ ts.isNonNullExpression(n))
2646
+ ) {
2647
+ n = n.expression;
2648
+ }
2649
+ return n;
2650
+ };
2651
+ const keyOf = (node) => {
2652
+ const name = node.name;
2653
+ if (!name) return undefined;
2654
+ if (ts.isIdentifier(name)) return name.text;
2655
+ if (ts.isStringLiteral(name) || ts.isNoSubstitutionTemplateLiteral(name)) return name.text;
2656
+ return undefined;
2657
+ };
2658
+
2659
+ /** @type {Map<string, any>} */
2660
+ const locals = new Map();
2661
+ const collect = (node) => {
2662
+ if (
2663
+ ts.isVariableDeclaration(node) &&
2664
+ node.name &&
2665
+ ts.isIdentifier(node.name) &&
2666
+ node.initializer
2667
+ ) {
2668
+ const init = unwrap(node.initializer);
2669
+ if (init && ts.isObjectLiteralExpression(init)) locals.set(node.name.text, init);
2670
+ }
2671
+ ts.forEachChild(node, collect);
2672
+ };
2673
+ collect(sf);
2674
+
2675
+ const readValue = (obj, where, seen) => {
2676
+ for (const prop of obj.properties) {
2677
+ if (ts.isSpreadAssignment(prop)) {
2678
+ const spread = unwrap(prop.expression);
2679
+ if (!spread) continue;
2680
+ const branches = ts.isConditionalExpression(spread)
2681
+ ? [unwrap(spread.whenTrue), unwrap(spread.whenFalse)]
2682
+ : [spread];
2683
+ for (const branch of branches) {
2684
+ if (!branch) continue;
2685
+ if (ts.isObjectLiteralExpression(branch)) readValue(branch, where, seen);
2686
+ else if (ts.isIdentifier(branch) && locals.has(branch.text) && !seen.has(branch.text)) {
2687
+ readValue(
2688
+ locals.get(branch.text),
2689
+ `${where} via ...${branch.text}`,
2690
+ new Set([...seen, branch.text]),
2691
+ );
2692
+ }
2693
+ }
2694
+ continue;
2695
+ }
2696
+ const key = keyOf(prop);
2697
+ if (key && VARIANT_DROPPED_ATTRS.has(key))
2698
+ sites.push({ line: lineOf(prop.getStart(sf)), key, where });
2699
+ }
2700
+ };
2701
+
2702
+ const visit = (node) => {
2703
+ if (ts.isCallExpression(node)) {
2704
+ const callee = node.expression;
2705
+ const isStyled =
2706
+ (ts.isIdentifier(callee) && callee.text === "styled") ||
2707
+ (ts.isPropertyAccessExpression(callee) &&
2708
+ ts.isIdentifier(callee.expression) &&
2709
+ callee.expression.text === "styled" &&
2710
+ callee.name.text !== "dynamic");
2711
+ if (isStyled) {
2712
+ const options = unwrap(node.arguments[1]);
2713
+ if (options && ts.isObjectLiteralExpression(options)) {
2714
+ const guarded = options.properties.some(
2715
+ (prop) => ts.isPropertyAssignment(prop) && keyOf(prop) === "context",
2716
+ );
2717
+ if (!guarded) {
2718
+ for (const prop of options.properties) {
2719
+ if (!ts.isPropertyAssignment(prop) && !ts.isShorthandPropertyAssignment(prop))
2720
+ continue;
2721
+ const key = keyOf(prop);
2722
+ if (key && BAG_HAZARD_ATTRS.has(key))
2723
+ sites.push({ line: lineOf(prop.getStart(sf)), key, where: "the options object" });
2724
+ }
2725
+ }
2726
+ for (const prop of options.properties) {
2727
+ if (!ts.isPropertyAssignment(prop) || keyOf(prop) !== "variants") continue;
2728
+ const variants = unwrap(prop.initializer);
2729
+ if (!variants || !ts.isObjectLiteralExpression(variants)) continue;
2730
+ for (const variant of variants.properties) {
2731
+ if (!ts.isPropertyAssignment(variant)) continue;
2732
+ const variantName = keyOf(variant) ?? "?";
2733
+ const cases = unwrap(variant.initializer);
2734
+ if (!cases || !ts.isObjectLiteralExpression(cases)) continue;
2735
+ for (const one of cases.properties) {
2736
+ if (!ts.isPropertyAssignment(one)) continue;
2737
+ const caseName = keyOf(one) ?? "?";
2738
+ const value = unwrap(one.initializer);
2739
+ const where = `variants.${variantName}.${caseName}`;
2740
+ if (!value) continue;
2741
+ if (ts.isObjectLiteralExpression(value)) readValue(value, where, new Set());
2742
+ else if (ts.isIdentifier(value) && locals.has(value.text)) {
2743
+ readValue(
2744
+ locals.get(value.text),
2745
+ `${where} = ${value.text}`,
2746
+ new Set([value.text]),
2747
+ );
2748
+ }
2749
+ }
2750
+ }
2751
+ }
2752
+ }
2753
+ }
2754
+ }
2755
+ ts.forEachChild(node, visit);
2756
+ };
2757
+ visit(sf);
2758
+ return sites;
2759
+ }
2760
+
2761
+ /**
2762
+ * LC-303: a DOM or React Native attribute written inside a
2763
+ * `styled()` variant value never reaches the element. Tamagui 3 resolves a
2764
+ * variant value through the style pipeline, which keeps what it recognises as
2765
+ * style and discards the rest, so the component renders, the attribute is
2766
+ * simply not there, and a spec that only checks the component rendered sees
2767
+ * nothing wrong. `role` and `accessibilityLabel` make that an accessibility
2768
+ * hole rather than a cosmetic one: a screen reader gets nothing.
2769
+ *
2770
+ * The fix is a move, not a rewrite, and the placement is the CALL SITE: it is
2771
+ * the only one that lands on web and native with the compiler on and off. The
2772
+ * `styled()` options object is not a safe destination on its own — under the
2773
+ * Tamagui vite plugin its non-style keys are dropped from any usage the
2774
+ * compiler can flatten, which is why `styled(View, { role: "note" })` rendered
2775
+ * as `<A />` emits a bare div while `<A onPress={fn} />` keeps the attribute.
2776
+ * The house components that default an attribute in their options object get
2777
+ * away with it because a `context` or an always-present handler blocks
2778
+ * flattening; a new one would not. A key that belongs to one variant case
2779
+ * moves to the call site that sets that variant.
2780
+ *
2781
+ * Sites still awaiting a move are counted per file in
2782
+ * `docs/variant-attr-baselines.json`, which only ever shrinks.
2783
+ */
2784
+ function checkStyledVariantAttrs() {
2785
+ /** @type {string[]} */
2786
+ const violations = [];
2787
+ const baselinePath = join(ROOT, VARIANT_ATTR_BASELINES);
2788
+ /** @type {Record<string, number>} */
2789
+ let baseline = {};
2790
+ if (existsSync(baselinePath)) {
2791
+ const raw = JSON.parse(readFileSync(baselinePath, "utf8"));
2792
+ if (raw && typeof raw.sites === "object") baseline = raw.sites;
2793
+ }
2794
+ /** @type {Record<string, number>} */
2795
+ const counted = {};
2796
+ /** @type {string[]} */
2797
+ const candidates = [];
2798
+
2799
+ const collect = (filePath) => {
2800
+ if (!RETIRED_SCANNED_RE.test(filePath) || filePath.endsWith(".d.ts")) return;
2801
+ if (VARIANT_ATTR_EXEMPT_RE.test(filePath)) return;
2802
+ if (VARIANT_ATTR_GNOME_RE.test(relative(ROOT, filePath).replaceAll("\\", "/"))) return;
2803
+ const src = readFileSync(filePath, "utf8");
2804
+ if (!VARIANT_ATTR_CANDIDATE_RE.test(src)) return;
2805
+ candidates.push(filePath);
2806
+ };
2807
+ for (const dir of [PUBLIC_DIR, PACKAGES_DIR, APPS_DIR, FEATURES_DIR]) walkFiles(dir, collect);
2808
+ if (!candidates.length) return violations;
2809
+
2810
+ let ts;
2811
+ try {
2812
+ // The parser is this package's own dependency, not the consumer tree's
2813
+ // content, so it resolves from here and not from the scanned root.
2814
+ ts = createRequire(import.meta.url)("typescript");
2815
+ } catch {
2816
+ return [
2817
+ `typescript could not be resolved from @multiplatform.one/config, so ${candidates.length} styled() file(s) went unparsed — install it rather than let this check go quiet`,
2818
+ ];
2819
+ }
2820
+
2821
+ for (const filePath of candidates) {
2822
+ const rel = relative(ROOT, filePath).replaceAll("\\", "/");
2823
+ const src = readFileSync(filePath, "utf8");
2824
+ const lines = src.split("\n");
2825
+ let open = 0;
2826
+ for (const site of styledVariantAttrSites(ts, src, filePath)) {
2827
+ open += 1;
2828
+ if (open > (baseline[rel] ?? 0)) {
2829
+ violations.push(
2830
+ site.where === "the options object"
2831
+ ? `${rel}:${site.line} — \`${site.key}\` in a styled() options object with no \`context\` is dropped from every usage the compiler can flatten; write it at the call site (LC-303)\n ${(lines[site.line - 1] ?? "").trim()}`
2832
+ : `${rel}:${site.line} — \`${site.key}\` in ${site.where} reaches no element on ${VARIANT_DROPPED_ATTRS.get(site.key)}; write it at the call site (LC-303)\n ${(lines[site.line - 1] ?? "").trim()}`,
2833
+ );
2834
+ }
2835
+ }
2836
+ if (open > 0) counted[rel] = open;
2837
+ }
2838
+
2839
+ for (const [rel, allowed] of Object.entries(baseline)) {
2840
+ const now = counted[rel] ?? 0;
2841
+ if (now < allowed) {
2842
+ violations.push(
2843
+ `${VARIANT_ATTR_BASELINES}: ${rel} is down to ${now} from ${allowed} — lower the ratchet`,
2844
+ );
2845
+ }
2846
+ }
2847
+ return violations;
2848
+ }
2849
+
2468
2850
  // ── Layout rules (LC-101 … LC-103, FZ-7158 WP-h) ──────────────────────────
2469
2851
 
2470
2852
  /** Ratchet for the layout rules that land on a tree already breaking them. */
2471
2853
  const LAYOUT_BASELINES = "docs/layout-rule-baselines.json";
2472
2854
 
2855
+ /** Ratchet for FZ-10849 V3-CLAUSE: sites not yet converted, per file. */
2856
+ const PSEUDO_PROP_BASELINES = "docs/pseudo-prop-baselines.json";
2857
+
2473
2858
  /**
2474
2859
  * `null` when the baseline file is absent (a scaffolded project prunes
2475
2860
  * docs/), and the layout checks then skip, like the spec registries.
@@ -2540,7 +2925,7 @@ function checkOneSidebar() {
2540
2925
  }
2541
2926
 
2542
2927
  const SPREAD_JUSTIFY_RE =
2543
- /justifyContent(?:\s*=\s*\{?\s*|\s*:\s*)["'](space-between|space-around|space-evenly)["']/g;
2928
+ /justifyContent(?:\s*=\s*\{?\s*|\s*:\s*)["'](?:[^"'\n]*?[\s:])?(space-between|space-around|space-evenly)(?=["'\s])/g;
2544
2929
 
2545
2930
  /**
2546
2931
  * LC-102 HUG-CONTENT: rows and columns hug their content; a spread
@@ -2589,6 +2974,10 @@ function checkHugContent() {
2589
2974
  const PHONE_HIDE_RE = /\$max-(?:xs|sm|md)\s*=\s*\{\{\s*display\s*:\s*["']none["']/;
2590
2975
  const WIDE_REVEAL_RE = /\$(?:sm|md|lg)\s*=\s*\{\{\s*display\s*:\s*["'](?!none)/;
2591
2976
  const HIDDEN_ATTR_RE = /\sdisplay\s*=\s*(?:\{\s*)?["']none["']/;
2977
+ const FLAT_PHONE_HIDE_RE =
2978
+ /\sdisplay\s*=\s*(?:\{\s*)?["'][^"'\n]*?(?<![\w/-])max-(?:xs|sm|md):none(?![\w-])/;
2979
+ const FLAT_WIDE_REVEAL_RE =
2980
+ /\sdisplay\s*=\s*(?:\{\s*)?["']none\s[^"'\n]*?(?<![\w/-])(?:sm|md|lg):(?!none(?![\w-]))/;
2592
2981
 
2593
2982
  /**
2594
2983
  * LC-103 RESPONSIVE-PARITY: a phone shows the same information. An element
@@ -2611,7 +3000,10 @@ function checkResponsiveParity() {
2611
3000
  if (mask[start] !== 1) continue;
2612
3001
  const tag = openingTag(src, mask, start);
2613
3002
  const hidesOnPhone =
2614
- PHONE_HIDE_RE.test(tag) || (HIDDEN_ATTR_RE.test(tag) && WIDE_REVEAL_RE.test(tag));
3003
+ PHONE_HIDE_RE.test(tag) ||
3004
+ FLAT_PHONE_HIDE_RE.test(tag) ||
3005
+ FLAT_WIDE_REVEAL_RE.test(tag) ||
3006
+ (HIDDEN_ATTR_RE.test(tag) && WIDE_REVEAL_RE.test(tag));
2615
3007
  if (!hidesOnPhone) continue;
2616
3008
  const lineStart = src.lastIndexOf("\n", start - 1);
2617
3009
  const prevLineStart = src.lastIndexOf("\n", lineStart - 1);
@@ -2634,6 +3026,7 @@ function checkAccentSolidOwners() {
2634
3026
  "public/theme/src/theme/readableColor.ts",
2635
3027
  "public/theme/src/theme/fillContrast.ts",
2636
3028
  "public/theme/src/theme/v3TokenRoles.ts",
3029
+ "public/theme/src/theme/v5Templates.ts",
2637
3030
  ]);
2638
3031
  const violations = [];
2639
3032
  const scan = (filePath) => {
@@ -2643,9 +3036,9 @@ function checkAccentSolidOwners() {
2643
3036
  if (owners.has(rel)) return;
2644
3037
  const src = readFileSync(filePath, "utf8");
2645
3038
  const live = nonCommentOffsets(src);
2646
- for (const match of src.matchAll(/accentBackground/g)) {
3039
+ for (const match of src.matchAll(/accent-background|accentBackground/g)) {
2647
3040
  if (live[match.index] === 1) {
2648
- violations.push(`${rel}:${lineAt(src, match.index)} — accentBackground outside its owners`);
3041
+ violations.push(`${rel}:${lineAt(src, match.index)} — ${match[0]} outside its owners`);
2649
3042
  }
2650
3043
  }
2651
3044
  };
@@ -2683,7 +3076,7 @@ function checkNativePressOwner() {
2683
3076
  for (const { abs, rel, src } of files)
2684
3077
  for (const hit of findNestedPressClaimants(src, abs, imported))
2685
3078
  violations.push(
2686
- `${rel}:${hit.line} — <${hit.tag}> claims the press inside <${hit.owner}>; move its press look to the owner's group ("$group-<name>-press")`,
3079
+ `${rel}:${hit.line} — <${hit.tag}> claims the press inside <${hit.owner}>; move its press look to the owner's group ("group-press/<name>:")`,
2687
3080
  );
2688
3081
  return violations;
2689
3082
  }
@@ -2697,11 +3090,425 @@ function checkNativeFocusWithin() {
2697
3090
  const src = readFileSync(filePath, "utf8");
2698
3091
  const rel = relative(ROOT, filePath).replaceAll("\\", "/");
2699
3092
  for (const hit of findNativeFocusWithin(src, filePath))
2700
- violations.push(`${rel}:${hit.line} — focusWithinStyle renders on native; gate it on isWeb`);
3093
+ violations.push(
3094
+ `${rel}:${hit.line} — a focus-within look renders on native; gate it on isWeb`,
3095
+ );
2701
3096
  });
2702
3097
  return violations;
2703
3098
  }
2704
3099
 
3100
+ // ── FZ-10849 V3-CLAUSE: the v2 pseudo-style props are inert ───────────────
3101
+
3102
+ /**
3103
+ * The Tamagui 2 pseudo-style props, each with the Tamagui 3 clause that
3104
+ * replaces it. The clause names are kebab-case: `@tamagui/style-grammar`
3105
+ * types them `CoreStateModifierName = "hover" | "press" | "focus" |
3106
+ * "focus-visible" | "focus-within" | "disabled" | "enter" | "exit"`, and
3107
+ * `createComponent` reads `conditionalStates.has("focus-visible")`. A
3108
+ * camel-cased `focusVisible:` clause is inert too, so the spelling matters.
3109
+ */
3110
+ const V2_PSEUDO_PROPS = new Map([
3111
+ ["hoverStyle", "hover:"],
3112
+ ["pressStyle", "press:"],
3113
+ ["focusStyle", "focus:"],
3114
+ ["focusVisibleStyle", "focus-visible:"],
3115
+ ["focusWithinStyle", "focus-within:"],
3116
+ ["enterStyle", "enter:"],
3117
+ ["exitStyle", "exit:"],
3118
+ ]);
3119
+
3120
+ /**
3121
+ * v2's eighth pseudo prop, `disabledStyle`, is deliberately NOT on that list:
3122
+ * MPO's own knob set owns the name (`knobs.ts:255`, a `DisabledStyle` of
3123
+ * `keepLabel` / `dimWhole`), and all 17 occurrences in the tree are that knob,
3124
+ * not a Tamagui prop. Banning it reported every preset, recipe and story
3125
+ * control as a defect. `fillStyle` and `timestampStyle` are house knobs the
3126
+ * same way; no other `*Style` knob name collides.
3127
+ */
3128
+
3129
+ /**
3130
+ * `hoverStyle={…}` as a JSX attribute, and `hoverStyle:` / `"hoverStyle":` as
3131
+ * an object key, which is how it reaches `styled()` options and a knob
3132
+ * fragment. `[:=]` not `:`, because the attribute form is the common one;
3133
+ * `(?!=)` keeps `hoverStyle ===` out.
3134
+ */
3135
+ const V2_PSEUDO_KEY_RE = new RegExp(
3136
+ `(?:^|[\\s{,(])(["']?)(${[...V2_PSEUDO_PROPS.keys()].join("|")})\\1\\??\\s*[:=](?!=)`,
3137
+ "g",
3138
+ );
3139
+
3140
+ /**
3141
+ * The modifier vocabulary a `$`-prefixed prop could name, from the grammar's
3142
+ * own table (`@tamagui/style-grammar`, guides/flat-values.mdx "Modifiers"):
3143
+ * the v5 config's media keys, `gt*` and `max*` media forms, a theme, a
3144
+ * platform, a group state, and the interaction and presence states.
3145
+ *
3146
+ * It is a closed list on purpose. `styled-components` marks a transient prop
3147
+ * the same way (`$variant`, `$useTheme`, `$small`), and `public/connectkit`
3148
+ * and the vendored `public/web3/src/connectkit` are styled-components
3149
+ * packages with no Tamagui dependency at all: matching `$<anything>` reported
3150
+ * 58 of those as Tamagui defects.
3151
+ */
3152
+ const DOLLAR_MODIFIERS = [
3153
+ "xxxs",
3154
+ "xxs",
3155
+ "xs",
3156
+ "sm",
3157
+ "md",
3158
+ "lg",
3159
+ "xl",
3160
+ "xxl",
3161
+ "touchable",
3162
+ "hoverable",
3163
+ "short",
3164
+ "tall",
3165
+ "hover",
3166
+ "press",
3167
+ "focus",
3168
+ "focusVisible",
3169
+ "focus-visible",
3170
+ "focusWithin",
3171
+ "focus-within",
3172
+ "disabled",
3173
+ "enter",
3174
+ "exit",
3175
+ "dark",
3176
+ "light",
3177
+ "web",
3178
+ "native",
3179
+ "ios",
3180
+ "android",
3181
+ ];
3182
+
3183
+ /** `$sm={{…}}`, `$max-md:`, `$gtSm=`, `$theme-dark=`, `$group-hover=`. */
3184
+ const DOLLAR_PROP_RE = new RegExp(
3185
+ `(?:^|[\\s{,(])(["']?)\\$(${DOLLAR_MODIFIERS.join("|")}|gt[A-Z]\\w*|max-[\\w-]+|max[A-Z]\\w*|theme-[\\w-]+|platform-[\\w-]+|group(?:-[\\w-]+|[A-Z]\\w*))\\1\\s*[:=]`,
3186
+ "g",
3187
+ );
3188
+
3189
+ /**
3190
+ * A file the `$`-prop half can apply to at all: it has to be reaching a
3191
+ * Tamagui component for a `$` prop to have been meant as a modifier.
3192
+ */
3193
+ const STYLES_FROM_TAMAGUI_RE = /from\s*["'](?:tamagui|@tamagui\/|@multiplatform\.one\/)/;
3194
+
3195
+ /** Files the rule itself needs to name the props: the lint tooling and its specs. */
3196
+ const PSEUDO_PROP_TOOLING_RE = /(?:^|\/)public\/config\//;
3197
+
3198
+ /**
3199
+ * Two more v3 silent-drop shapes. One detector pass, because they are one
3200
+ * family: the authored spelling still typechecks, still renders, and emits
3201
+ * nothing, so only a lint rule sees them.
3202
+ *
3203
+ * 1. A DOTTED token value. `paddingHorizontal="$2.5"` reaches the DOM as the
3204
+ * literal `$2.5`, which is not CSS, so the element gets no padding at all.
3205
+ * The `$token` resolution check above does not catch it: `2.5` and `3.5`
3206
+ * ARE registry keys, so they resolve and pass, while `0.75` happens to fail
3207
+ * for the unrelated reason that it is not a key. Every dotted spelling is
3208
+ * dead regardless of whether it resolves, which is why this is its own rule.
3209
+ * The replacement is the same step spelled the v3 way, kebab and bare:
3210
+ * `"$1.5"` is `"1-5"` and `"$0.75"` is `"0-75"`, both real scale keys.
3211
+ * 2. `name` as a `styled()` OPTION. v3 has no such option: it falls into
3212
+ * `...defaultProps` and emits no class, so `.is_<Name>` never exists.
3213
+ * `displayName` is the replacement for the React devtools name, and that is
3214
+ * ALL it buys: it does not bring the class back. Proven by render —
3215
+ * `styled(View, { name })`, `styled(View, { displayName })` and a bare
3216
+ * `styled(View, {})` all emit exactly `is_View`, and `.is_<Name>` appears in
3217
+ * none of them. A selector that needs a per-component class writes
3218
+ * `className` by hand, the way `public/table-primitives/src/index.tsx` does
3219
+ * at eight sites, which is why the table specs still match on `.is_Table`.
3220
+ * On an input-like base the dead option is worse than cosmetic: it reaches
3221
+ * the DOM as the form field's `name`, so removing it changes submission.
3222
+ *
3223
+ * `name:` cannot be found with a regex. Data objects, CSF story exports, zod
3224
+ * schemas and i18n tables are full of `name:` keys, and one package held 74
3225
+ * raw hits with every real call site already correct. So this walks from each
3226
+ * `styled(` to its matching paren and reports only keys at brace depth 1,
3227
+ * which is the options object itself.
3228
+ */
3229
+ const DOTTED_TOKEN_RE = /(?:^|[\s{,(])([a-zA-Z][\w]*)\s*[:=]\s*\{?\s*["']\$(\d+\.\d+)["']/g;
3230
+
3231
+ /**
3232
+ * Props a size or space token is meaningful on, so a `price: "$2.50"` in a
3233
+ * data fixture is not read as a style. Narrow on purpose: this names the
3234
+ * geometry props, not every style prop.
3235
+ */
3236
+ const TOKEN_GEOMETRY_PROPS = new Set([
3237
+ "borderBottomWidth",
3238
+ "borderLeftWidth",
3239
+ "borderRadius",
3240
+ "borderRightWidth",
3241
+ "borderTopWidth",
3242
+ "borderWidth",
3243
+ "bottom",
3244
+ "columnGap",
3245
+ "flexBasis",
3246
+ "fontSize",
3247
+ "gap",
3248
+ "height",
3249
+ "left",
3250
+ "letterSpacing",
3251
+ "lineHeight",
3252
+ "margin",
3253
+ "marginBottom",
3254
+ "marginHorizontal",
3255
+ "marginLeft",
3256
+ "marginRight",
3257
+ "marginTop",
3258
+ "marginVertical",
3259
+ "maxHeight",
3260
+ "maxWidth",
3261
+ "minHeight",
3262
+ "minWidth",
3263
+ "outlineOffset",
3264
+ "outlineWidth",
3265
+ "padding",
3266
+ "paddingBottom",
3267
+ "paddingHorizontal",
3268
+ "paddingLeft",
3269
+ "paddingRight",
3270
+ "paddingTop",
3271
+ "paddingVertical",
3272
+ "right",
3273
+ "rowGap",
3274
+ "shadowRadius",
3275
+ "size",
3276
+ "top",
3277
+ "width",
3278
+ "x",
3279
+ "y",
3280
+ ]);
3281
+
3282
+ /**
3283
+ * 3. `tag`. v3 renamed it to `render`, and the old spelling is inert: `tag="button"`
3284
+ * renders a `div`. `render="button"` and `render={<button />}` both render the
3285
+ * button; the element form is the only one that can carry attributes, which is
3286
+ * how a Text keeps an href (`render={<a href={link} />}`).
3287
+ *
3288
+ * Only the JSX ATTRIBUTE form is flagged. `tag:` as an object key is a data
3289
+ * field in this repo far more often than a style prop — a tag-name map in
3290
+ * `layouts/tags.tsx`, a route identifier in router, a `data-tag` selector in
3291
+ * rich-text — and matching it reported 35 of those as defects against one
3292
+ * real site.
3293
+ */
3294
+ const TAG_PROP_RE = /(?:^|\s)tag=(?!=)/g;
3295
+
3296
+ function findStyledNameOptions(src) {
3297
+ /** @type {number[]} */
3298
+ const sites = [];
3299
+ let control = 0;
3300
+ for (const call of src.matchAll(/\bstyled\(/g)) {
3301
+ let depth = 0;
3302
+ let quote = null;
3303
+ let i = call.index + call[0].length - 1;
3304
+ let end = -1;
3305
+ while (i < src.length) {
3306
+ const ch = src[i];
3307
+ if (quote) {
3308
+ if (ch === "\\") {
3309
+ i += 2;
3310
+ continue;
3311
+ }
3312
+ if (ch === quote) quote = null;
3313
+ } else if (ch === '"' || ch === "'" || ch === "`") quote = ch;
3314
+ else if (ch === "(") depth += 1;
3315
+ else if (ch === ")") {
3316
+ depth -= 1;
3317
+ if (depth === 0) {
3318
+ end = i;
3319
+ break;
3320
+ }
3321
+ }
3322
+ i += 1;
3323
+ }
3324
+ if (end < 0) continue;
3325
+ const start = call.index + call[0].length;
3326
+ const body = src.slice(start, end);
3327
+ let braces = 0;
3328
+ for (const token of body.matchAll(/[{}]|\bname\s*:|\bdisplayName\s*:/g)) {
3329
+ const text = token[0];
3330
+ if (text === "{") braces += 1;
3331
+ else if (text === "}") braces -= 1;
3332
+ else if (braces === 1) {
3333
+ if (text.startsWith("displayName")) control += 1;
3334
+ else sites.push(start + token.index);
3335
+ }
3336
+ }
3337
+ }
3338
+ return { sites: [...new Set(sites)], control };
3339
+ }
3340
+
3341
+ /**
3342
+ * FZ-10849 V3-CLAUSE: Tamagui 3 removed every v2 pseudo-style prop and every
3343
+ * `$`-prefixed style prop. They are not errors. They typecheck, they render,
3344
+ * and they contribute NOTHING — proven by render, not by trusting the dev
3345
+ * warning in `@tamagui/web/dist/esm/helpers/getSplitStyles.mjs`:
3346
+ *
3347
+ * opacity={1} ["is_View","_o-1507267812"]
3348
+ * opacity={1} hoverStyle={{opacity:0.5}} ["is_View","_o-1507267812"] identical
3349
+ * opacity="1 hover:0.5" ["is_View","_o-776209076"] + :hover rule
3350
+ *
3351
+ * A key inside `styled()` options goes the same way, and `focusVisibleStyle`
3352
+ * is not even in Tamagui's warning list, so it fails with no console hint.
3353
+ * That makes a green typecheck worthless here, which is why this is a lint
3354
+ * rule and not a type.
3355
+ *
3356
+ * One flat clause per style property replaces them:
3357
+ * `<View bg="background hover:background-hover" p="4 sm:6" />`. A transform
3358
+ * offset needs its unit in the clause (`y="0px enter:-25px"`); a bare number
3359
+ * resolves as a space token and emits unitless, which drops the transform.
3360
+ *
3361
+ * A value no clause can express keeps the prop with a
3362
+ * `pseudo-prop-escape: <reason>` comment on the line or the one above, and
3363
+ * every escape must be a row in the spec's `## Pseudo-prop escapes` table.
3364
+ * Sites still awaiting conversion are counted per file in
3365
+ * `docs/pseudo-prop-baselines.json`, which only ever shrinks.
3366
+ */
3367
+ function checkV2PseudoProps() {
3368
+ /** @type {string[]} */
3369
+ const violations = [];
3370
+ const baselinePath = join(ROOT, PSEUDO_PROP_BASELINES);
3371
+ /** @type {Record<string, number>} */
3372
+ let baseline = {};
3373
+ if (existsSync(baselinePath)) {
3374
+ const raw = JSON.parse(readFileSync(baselinePath, "utf8"));
3375
+ if (raw && typeof raw.sites === "object") baseline = raw.sites;
3376
+ }
3377
+ let registry;
3378
+ try {
3379
+ registry = readPseudoPropEscapeRegistry(join(ROOT, "docs/theme-propagation-spec.md"));
3380
+ } catch (error) {
3381
+ return [`pseudo-prop escape registry: ${error instanceof Error ? error.message : error}`];
3382
+ }
3383
+ /** @type {Map<string, boolean>} */
3384
+ const declared = new Map();
3385
+ if (registry.present) {
3386
+ for (const { file, reason } of registry.escapes) declared.set(`${file}\n${reason}`, false);
3387
+ }
3388
+ /** @type {Record<string, number>} */
3389
+ const counted = {};
3390
+
3391
+ const scan = (filePath) => {
3392
+ if (!RETIRED_SCANNED_RE.test(filePath) || filePath.endsWith(".d.ts")) return;
3393
+ const rel = relative(ROOT, filePath).replaceAll("\\", "/");
3394
+ if (PSEUDO_PROP_TOOLING_RE.test(`/${rel}`)) return;
3395
+ const src = readFileSync(filePath, "utf8");
3396
+ if (!/Style\s*[:=]|\$[a-z]|\$\d+\.\d|\bstyled\(|(?:^|\s)tag=/m.test(src)) return;
3397
+ const code = codeOffsets(src);
3398
+ const lines = src.split("\n");
3399
+ const escapedLines = new Set();
3400
+ /** @type {Map<number, string>} */
3401
+ const reasonAt = new Map();
3402
+ for (const { line, reason } of findPseudoPropEscapes(src)) {
3403
+ for (const at of [line, line + 1]) {
3404
+ escapedLines.add(at);
3405
+ if (!reasonAt.has(at)) reasonAt.set(at, reason);
3406
+ }
3407
+ }
3408
+
3409
+ /** @type {Map<number, string>} */
3410
+ const hits = new Map();
3411
+ for (const match of src.matchAll(V2_PSEUDO_KEY_RE)) {
3412
+ const index = (match.index ?? 0) + match[0].indexOf(match[2]);
3413
+ if (code[index] !== 1) continue;
3414
+ hits.set(
3415
+ index,
3416
+ `\`${match[2]}\` emits nothing; write the \`${V2_PSEUDO_PROPS.get(
3417
+ match[2],
3418
+ )}\` clause on the style's own property`,
3419
+ );
3420
+ }
3421
+ if (STYLES_FROM_TAMAGUI_RE.test(src)) {
3422
+ for (const match of src.matchAll(DOLLAR_PROP_RE)) {
3423
+ const index = (match.index ?? 0) + match[0].indexOf("$");
3424
+ // A quoted key — `{ "$max-sm": {…} }` — is just as inert and is how two
3425
+ // live sites hid from the first draft of this check. The `$` then sits
3426
+ // inside a string, so the code test reads the character before the
3427
+ // opening quote, which is the one in code.
3428
+ if (code[match[1] ? index - 2 : index] !== 1) continue;
3429
+ if (src[index - 1] === "$" || src[index - 1] === ".") continue;
3430
+ const clause = match[2].replace(/^gt([A-Z])/, (_, c) => `gt${c}`);
3431
+ hits.set(
3432
+ index,
3433
+ `\`$${match[2]}\` emits nothing; write the \`${clause}:\` clause on the style's own property`,
3434
+ );
3435
+ }
3436
+ }
3437
+
3438
+ for (const match of src.matchAll(DOTTED_TOKEN_RE)) {
3439
+ const index = (match.index ?? 0) + match[0].indexOf("$");
3440
+ // The `$` is inside the quoted value, so the code test reads the prop
3441
+ // name, which is the part in code.
3442
+ if (code[(match.index ?? 0) + match[0].indexOf(match[1])] !== 1) continue;
3443
+ if (!TOKEN_GEOMETRY_PROPS.has(match[1])) continue;
3444
+ hits.set(
3445
+ index,
3446
+ `\`${match[1]}="$${match[2]}"\` emits nothing; a dotted token reaches the DOM verbatim, so the property is dropped — the v3 scale key is kebab and bare: \`${match[1]}="${match[2].replace(".", "-")}"\``,
3447
+ );
3448
+ }
3449
+ if (STYLES_FROM_TAMAGUI_RE.test(src)) {
3450
+ for (const match of src.matchAll(TAG_PROP_RE)) {
3451
+ const index = (match.index ?? 0) + match[0].indexOf("tag");
3452
+ if (code[index] !== 1) continue;
3453
+ hits.set(
3454
+ index,
3455
+ '`tag` is gone in v3 and renders the base element instead; write `render` — `render="button"`, or `render={<a href={link} />}` when the element carries attributes',
3456
+ );
3457
+ }
3458
+ }
3459
+ const styledNames = findStyledNameOptions(src);
3460
+ for (const index of styledNames.sites) {
3461
+ if (code[index] !== 1) continue;
3462
+ hits.set(
3463
+ index,
3464
+ "`name` is not a `styled()` option in v3; it falls into `...defaultProps`, so it emits no class and, on an input-like base, reaches the DOM as the form field's `name` — rename it to `displayName`, and write `className` by hand where a selector needs the class",
3465
+ );
3466
+ }
3467
+
3468
+ let open = 0;
3469
+ for (const [index, what] of [...hits].sort((a, b) => a[0] - b[0])) {
3470
+ const line = lineAt(src, index);
3471
+ if (escapedLines.has(line)) {
3472
+ const reason = reasonAt.get(line) ?? "";
3473
+ if (!reason) {
3474
+ violations.push(`${rel}:${line} — pseudo-prop-escape with no written reason`);
3475
+ continue;
3476
+ }
3477
+ const key = `${rel}\n${reason}`;
3478
+ if (!registry.present) continue;
3479
+ if (declared.has(key)) {
3480
+ declared.set(key, true);
3481
+ continue;
3482
+ }
3483
+ violations.push(`${rel}:${line} — undeclared escape "${reason}"`);
3484
+ continue;
3485
+ }
3486
+ open += 1;
3487
+ if (open > (baseline[rel] ?? 0)) {
3488
+ violations.push(`${rel}:${line} — ${what}\n ${lines[line - 1].trim()}`);
3489
+ }
3490
+ }
3491
+ if (open > 0) counted[rel] = open;
3492
+ };
3493
+
3494
+ for (const dir of [PUBLIC_DIR, PACKAGES_DIR, APPS_DIR, FEATURES_DIR]) walkFiles(dir, scan);
3495
+
3496
+ for (const [rel, allowed] of Object.entries(baseline)) {
3497
+ const now = counted[rel] ?? 0;
3498
+ if (now < allowed) {
3499
+ violations.push(
3500
+ `${PSEUDO_PROP_BASELINES}: ${rel} is down to ${now} from ${allowed} — lower the ratchet`,
3501
+ );
3502
+ }
3503
+ }
3504
+ for (const [key, seen] of declared) {
3505
+ if (seen) continue;
3506
+ const [file, reason] = key.split("\n");
3507
+ violations.push(`${file} — declared escape "${reason}" has no comment in the code (stale row)`);
3508
+ }
3509
+ return violations;
3510
+ }
3511
+
2705
3512
  /**
2706
3513
  * Run structural convention checks over a consumer tree.
2707
3514
  *
@@ -2727,6 +3534,7 @@ export function runConventionChecks(options = {}) {
2727
3534
  const nativeDomCalls = checkNativeDomCalls();
2728
3535
  const graphVars = checkGraphVarsCoverage();
2729
3536
  const retiredScaleKnobs = checkRetiredScaleKnobs();
3537
+ const variantAttrs = checkStyledVariantAttrs();
2730
3538
  const overlayOwnership = checkOverlayOwnership();
2731
3539
  const accentSolidOwners = checkAccentSolidOwners();
2732
3540
  const tokens = checkTransitionTokens();
@@ -2740,6 +3548,7 @@ export function runConventionChecks(options = {}) {
2740
3548
  const nativePressOwner = checkNativePressOwner();
2741
3549
  const nativeFocusWithin = checkNativeFocusWithin();
2742
3550
  const oneTabBar = checkOneTabBar();
3551
+ const v2PseudoProps = checkV2PseudoProps();
2743
3552
  let failed = false;
2744
3553
 
2745
3554
  for (const [rule, list] of /** @type {const} */ ([
@@ -2756,17 +3565,21 @@ export function runConventionChecks(options = {}) {
2756
3565
  responsiveParity,
2757
3566
  ],
2758
3567
  [
2759
- 'Convention (FZ-7792 NATIVE-PRESS-OWNER, check 17): one view owns a press. On native, a view with pressStyle or focusVisibleStyle and no handler claims the touch, and React Native gives it to the deepest claimant, so a pressable\'s onPress never runs when the tap lands on that child. Put `group="<name>"` on the pressable and move the child\'s press look to `"$group-<name>-press"`.',
3568
+ "Convention (FZ-7792 NATIVE-PRESS-OWNER, check 17): one view owns a press. On native, a view with a press, active or focus-visible look (a press:, active: or focus-visible: clause, or v2 pressStyle / focusVisibleStyle) and no handler claims the touch, and React Native gives it to the deepest claimant, so a pressable's onPress never runs when the tap lands on that child. Put `group=\"<name>\"` on the pressable and move the child's press look to a `group-press/<name>:` clause.",
2760
3569
  nativePressOwner,
2761
3570
  ],
2762
3571
  [
2763
- "Convention (FZ-8991 NATIVE-FOCUS-WITHIN, check 18): no focusWithinStyle on native. Tamagui then gives every descendant focus events, a label inside a pressable takes the touch, and its onPress never runs. The ring follows keyboard focus: spread it as `{...(isWeb ? { focusWithinStyle: ring } : undefined)}`.",
3572
+ 'Convention (FZ-8991 NATIVE-FOCUS-WITHIN, check 18): no focus-within look on native (a focus-within: clause or v2 focusWithinStyle). Tamagui then gives every descendant focus events, a label inside a pressable takes the touch, and its onPress never runs. The ring follows keyboard focus: spread it as `{...(isWeb ? { outlineColor: "focus-within:accent-color" } : undefined)}`.',
2764
3573
  nativeFocusWithin,
2765
3574
  ],
2766
3575
  [
2767
3576
  "Convention (LC-150 TAB-BAR-ANATOMY): one bottom tab bar for every MPO app. A phone app renders TabBar from @multiplatform.one/components with items (an icon component and a label) and nothing else; the bar owns its metrics and the theme its colours. An app-local tab bar, a navigator's own tab bar, or tabBar* styling options fork the look.",
2768
3577
  oneTabBar,
2769
3578
  ],
3579
+ [
3580
+ 'Convention (FZ-10849 V3-CLAUSE): Tamagui 3 removed the v2 pseudo-style props and every `$`-prefixed style prop. They still typecheck and still render, and they emit NOTHING, so neither tsc nor a passing spec catches one. Write one flat clause per style property instead: `<View bg="background hover:background-hover" p="4 sm:6" />`. Clause names are kebab — `focus-visible:`, never `focusVisible:`, which is inert too. A transform offset carries its unit (`y="0px enter:-25px"`); a bare number resolves as a space token and emits unitless, which drops the transform. A value no clause can express keeps the prop with a `pseudo-prop-escape: <reason>` comment plus a row in docs/theme-propagation-spec.md `## Pseudo-prop escapes`; sites awaiting conversion are counted in docs/pseudo-prop-baselines.json, which only shrinks.',
3581
+ v2PseudoProps,
3582
+ ],
2770
3583
  ])) {
2771
3584
  if (!list.length) continue;
2772
3585
  failed = true;
@@ -2909,7 +3722,7 @@ export function runConventionChecks(options = {}) {
2909
3722
  if (accentSolidOwners.length) {
2910
3723
  failed = true;
2911
3724
  console.error(
2912
- "Convention (LC-05 ONE-EMPHASIS): the accent solid paints the primary CTA, the checked Switch track, progress fills and current/checked marks only, through `componentColors.indicator.mark` or `formSelectedColors.mark`. A selected, current or highlighted fill takes `componentColors.selection` / `formSelectionColors`; a data-identity default takes `useChartPalette().single`; accent text takes `$accentColor`.\n",
3725
+ "Convention (LC-05 ONE-EMPHASIS): the accent solid paints the primary CTA, the checked Switch track, progress fills and current/checked marks only, through `componentColors.indicator.mark` or `formSelectedColors.mark`. A selected, current or highlighted fill takes `componentColors.selection` / `formSelectionColors`; a data-identity default takes `useChartPalette().single`; accent text takes `$accent-color`.\n",
2913
3726
  );
2914
3727
  for (const msg of accentSolidOwners) console.error(` ${msg}`);
2915
3728
  console.error("");
@@ -2932,6 +3745,15 @@ export function runConventionChecks(options = {}) {
2932
3745
  console.error("");
2933
3746
  }
2934
3747
 
3748
+ if (variantAttrs.length) {
3749
+ failed = true;
3750
+ console.error(
3751
+ "Convention (LC-303 ATTRIBUTE-AT-THE-CALL-SITE): a DOM or React Native attribute written inside a `styled()` variant value reaches no element. Tamagui 3 resolves a variant value through the style pipeline, which keeps style and discards the rest, so the component still renders and only the attribute is missing \u2014 a spec that checks the component rendered sees nothing wrong, and on `role` or `accessibilityLabel` that is an accessibility hole. The fix is a move, and the destination is the CALL SITE: that is the one placement that lands on web and native with the Tamagui compiler on and off. The options object is not safe on its own, because the compiler drops its non-style keys from any usage it can flatten. A key that belongs to one variant case moves to the call site that sets that variant.\n",
3752
+ );
3753
+ for (const msg of variantAttrs) console.error(` ${msg}`);
3754
+ console.error("");
3755
+ }
3756
+
2935
3757
  if (retiredScaleKnobs.length) {
2936
3758
  failed = true;
2937
3759
  console.error(
@@ -2980,7 +3802,7 @@ export function runConventionChecks(options = {}) {
2980
3802
  if (styleTokens.violations.length) {
2981
3803
  failed = true;
2982
3804
  console.error(
2983
- "Convention: a `$token` style literal must resolve — as a theme key ($color11, $borderColor, $accentBackground, a Radix ramp step), as a token in the prop's own scale (radius/size/zIndex/color), or as a space token. None of those matched, so Tamagui drops the prop and the style never applies.\n",
3805
+ "Convention: a `$token` style literal must resolve — as a theme key ($color-11, $border-color, $accent-background, a Radix ramp step), as a token in the prop's own scale (radius/size/zIndex/color), or as a space token. None of those matched, so Tamagui drops the prop and the style never applies.\n",
2984
3806
  );
2985
3807
  for (const msg of styleTokens.violations) console.error(` ${msg}`);
2986
3808
  console.error("");
@@ -2989,7 +3811,7 @@ export function runConventionChecks(options = {}) {
2989
3811
  if (themeNames.violations.length) {
2990
3812
  failed = true;
2991
3813
  console.error(
2992
- 'Convention: theme="…" must name a built theme or sub-theme (a scheme like light/dark, a hue like blue/red/green, a semantic child like error/warning/success, accent, or a state like active/alt1/alt2). An unbuilt name silently inherits the PARENT theme, so the element renders untinted.\n',
3814
+ 'Convention: theme="…" and <Theme name="…"> must name a built theme or sub-theme (a scheme like light/dark, a hue like blue/red/green, a semantic child like error/warning/success, accent, or a state like active/alt1/alt2). An unbuilt name silently inherits the PARENT theme, so the element renders untinted.\n',
2993
3815
  );
2994
3816
  for (const msg of themeNames.violations) console.error(` ${msg}`);
2995
3817
  console.error("");